Скрипт добавления зон для tinydns
June 16th, 2009
Для добавления одной зоны:
#!/bin/bash
DIR="/service/srvdns/root"
cd $DIR
if [ "x$1" = "x" ]; then
echo "Usage: domain.com owner ip"
exit
fi
if [ "x$2" = "x" ]; then
echo "Usage: domain.com owner ip"
exit
fi
if [ "x$3" = "x" ]; then
echo "Usage: domain.com owner ip"
exit
fi
domainexist=`cat $DIR/data | grep -c $1`
if [ $domainexist != "0" ]; then
echo "$1 already exist. Exit."
exit
fi
sed -e "s/domain.com/$1/g" "$DIR/domain.com" > "$DIR/tmpfile"
sed -e "s/owner/$2/g" "$DIR/tmpfile" > "$DIR/tmpfile2"
sed -e "s/serverip/$3/g" "$DIR/tmpfile2" >> "$DIR/data"
rm $DIR/tmpfile
rm $DIR/tmpfile2
make
DIR="/service/srvdns/root"
cd $DIR
if [ "x$1" = "x" ]; then
echo "Usage: domain.com owner ip"
exit
fi
if [ "x$2" = "x" ]; then
echo "Usage: domain.com owner ip"
exit
fi
if [ "x$3" = "x" ]; then
echo "Usage: domain.com owner ip"
exit
fi
domainexist=`cat $DIR/data | grep -c $1`
if [ $domainexist != "0" ]; then
echo "$1 already exist. Exit."
exit
fi
sed -e "s/domain.com/$1/g" "$DIR/domain.com" > "$DIR/tmpfile"
sed -e "s/owner/$2/g" "$DIR/tmpfile" > "$DIR/tmpfile2"
sed -e "s/serverip/$3/g" "$DIR/tmpfile2" >> "$DIR/data"
rm $DIR/tmpfile
rm $DIR/tmpfile2
make
Для добавления нескольких зон из файла-списка:
#!/bin/bash
DIR="/service/srvdns/root"
cd $DIR
if [ "x$1" = "x" ]; then
echo "Usage: owner ip"
exit
fi
if [ "x$2" = "x" ]; then
echo "Usage: owner ip"
exit
fi
cat $DIR/domainsfile | while read domain; do
domainexist=`cat $DIR/data | grep -c $domain`
if [ $domainexist != "0" ]; then
echo "$domain already exist. Skipped."
continue
fi
sed -e "s/domain.com/$domain/g" "$DIR/domain.com" > "$DIR/tmpfile"
sed -e "s/owner/$1/g" "$DIR/tmpfile" > "$DIR/tmpfile2"
sed -e "s/serverip/$2/g" "$DIR/tmpfile2" >> "$DIR/data"
rm $DIR/tmpfile
rm $DIR/tmpfile2
done
make
DIR="/service/srvdns/root"
cd $DIR
if [ "x$1" = "x" ]; then
echo "Usage: owner ip"
exit
fi
if [ "x$2" = "x" ]; then
echo "Usage: owner ip"
exit
fi
cat $DIR/domainsfile | while read domain; do
domainexist=`cat $DIR/data | grep -c $domain`
if [ $domainexist != "0" ]; then
echo "$domain already exist. Skipped."
continue
fi
sed -e "s/domain.com/$domain/g" "$DIR/domain.com" > "$DIR/tmpfile"
sed -e "s/owner/$1/g" "$DIR/tmpfile" > "$DIR/tmpfile2"
sed -e "s/serverip/$2/g" "$DIR/tmpfile2" >> "$DIR/data"
rm $DIR/tmpfile
rm $DIR/tmpfile2
done
make
Где файл domain.com такой:
###########################
#owner: domain.com
.domain.com::ns1.domainserver.com.:2500
&domain.com::ns2.domainserver.com.:2500
@domain.com::mail.domain.com.:10:2500
+domain.com:serverip:2500
+*.domain.com:serverip:2500
#owner: domain.com
.domain.com::ns1.domainserver.com.:2500
&domain.com::ns2.domainserver.com.:2500
@domain.com::mail.domain.com.:10:2500
+domain.com:serverip:2500
+*.domain.com:serverip:2500
