diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/check_db_safety | 18 | ||||
-rw-r--r-- | scripts/nameserver_autogen/dnsmasq_tld_conffile | 13 | ||||
-rwxr-xr-x | scripts/nameserver_autogen/tinydns_tld_datafile | 36 |
3 files changed, 43 insertions, 24 deletions
diff --git a/scripts/check_db_safety b/scripts/check_db_safety index 7208ccb..a33bad3 100755 --- a/scripts/check_db_safety +++ b/scripts/check_db_safety @@ -1,23 +1,23 @@ #!/bin/sh -if [ "$(ls db/dom/ | tr -d 'a-z0-9\n-' | wc -c)" != 0 ]; then +if [ "$(ls db/dom/ | tr -d 'a-z0-9\n-' | wc -c | tr -d ' \t')" != 0 ]; then echo "There's a bad TLD. You probably don't want to run any shell scripts." >&2 exit 1 fi for tld in db/dom/* ; do - if [ "$(ls $tld/ | tr -d 'a-z0-9\n-' | wc -c)" != 0 ]; then + if [ "$(ls $tld/ | tr -d 'a-z0-9\n-' | wc -c | tr -d ' \t')" != 0 ]; then tld="$(basename $tld)" echo "There's a bad domain under $tld." >&2 echo "You probably don't want to run any shell scripts." >&2 exit 1 fi for dom in $tld/* ; do - if [ "$(ls $dom/ns/ | tr -d 'a-z0-9\n.-' | wc -c)" != 0 ]; then + if [ "$(ls $dom/ns/ | tr -d 'a-z0-9\n.-' | wc -c | tr -d ' \t')" != 0 ]; then domain="$(basename $dom).$(basename $tld)" echo "There's a bad nameserver under $domain." >&2 echo "You probably don't want to run any shell scripts." >&2 fi for ns in $dom/ns/* ; do - if [ "$(cat $ns | tr -d '0-9.\n' | wc -c)" != 0 ]; then + if [ "$(cat $ns | tr -d '0-9.\n' | wc -c | tr -d ' \t')" != 0 ]; then domain="$(basename $dom).$(basename $tld)" nsname="$(basename $ns)" echo "There's a bad nameserver IP under $domain, for" >&2 @@ -27,28 +27,28 @@ for tld in db/dom/* ; do done done done -if [ "$(ls db/ip/ | tr -d 'A-F0-9\n' | wc -c)" != 0 ]; then +if [ "$(ls db/ip/ | tr -d 'A-F0-9\n' | wc -c | tr -d ' \t')" != 0 ]; then echo "There's a bad first octet. You probably don't want to run any shell scripts." >&2 exit 1 for first in db/ip/* ; do - if [ "$(ls $first/ | tr -d 'A-F0-9\n' | wc -c)" != 0 ]; then + if [ "$(ls $first/ | tr -d 'A-F0-9\n' | wc -c | tr -d ' \t')" != 0 ]; then echo "There's a bad second octet under $first." >&2 echo "You probably don't want to run any shell scripts." >&2 exit 1 for second in $first/* ; do - if [ "$(ls $second/ | tr -d 'A-F0-9\n' | wc -c)" != 0 ]; then + if [ "$(ls $second/ | tr -d 'A-F0-9\n' | wc -c | tr -d ' \t')" != 0 ]; then echo "There's a bad third octet under $second." >&2 echo "You probably don't want to run any shell scripts." >&2 exit 1 fi for third in $second/* ; do - if [ "$(ls $third/ns/ | tr -d 'a-z0-9\n.-' | wc -c)" != 0 ]; then + if [ "$(ls $third/ns/ | tr -d 'a-z0-9\n.-' | wc -c | tr -d ' \t')" != 0 ]; then ip="$(basename $first).$(basename $second).$(basename $third).0/24" echo "There's a bad nameserver under $ip." >&2 echo "You probably don't want to run any shell scripts." >&2 fi for ns in $third/ns/* ; do - if [ "$(cat $ns | tr -d '0-9.\n' | wc -c)" != 0 ]; then + if [ "$(cat $ns | tr -d '0-9.\n' | wc -c | tr -d ' \t')" != 0 ]; then ip="$(basename $first).$(basename $second).$(basename $third).0/24" nsname="$(basename $ns)" echo "There's a bad nameserver IP under $ip, for" >&2 diff --git a/scripts/nameserver_autogen/dnsmasq_tld_conffile b/scripts/nameserver_autogen/dnsmasq_tld_conffile new file mode 100644 index 0000000..a9eb16c --- /dev/null +++ b/scripts/nameserver_autogen/dnsmasq_tld_conffile @@ -0,0 +1,13 @@ +#!/bin/bash +#Remember to redirect the output into some file! + +for tld in $(ls db/dom/); do + for domain in $(ls db/dom/${tld}/); do + for ns in $(cat db/dom/${tld}/${domain}/ns/*); do + STR="server=/${domain}.${tld}/${ns}" + if [ "$(grep $STR /etc/dnsmasq.conf)" = "" ]; then + echo $STR + fi + done; + done; +done diff --git a/scripts/nameserver_autogen/tinydns_tld_datafile b/scripts/nameserver_autogen/tinydns_tld_datafile index 0a1174f..a58b6be 100755 --- a/scripts/nameserver_autogen/tinydns_tld_datafile +++ b/scripts/nameserver_autogen/tinydns_tld_datafile @@ -4,22 +4,28 @@ if ! ./scripts/check_db_safety; then fi tldsrvrname="$(./scripts/conf_var tinydns__tldsrvrname uz5fvb7zdqyuz4q8ysjdfuf04kzd2lrt0l6fp4uyguxdg5tfut06ck.anons.somerandomnick.ano)" tldsrvrip="$(./scripts/conf_var tinydns__tldsrvrip 1.0.27.37)" -for tld in db/ip/* ; do - first="$(basename $tld | ./scripts/hex2dec)" - tldname="$first.in-addr.arpa" - echo "+$tldsrvrname:$tldsrvrip:3600" - echo ".$tldname::$tldsrvrname" - for ip in $tld/*/* ; do - third="$(basename $ip | ./scripts/hex2dec)" - second="$(basename $(dirname $ip) | ./scripts/hex2dec)" - first="$(basename $(dirname $(dirname $ip)) | ./scripts/hex2dec)" - domain="$third.$second.$first.in-addr.arpa" - for ns in $ip/ns/* ; do - nsip="$(cat $ns)" - nsname="$(basename $ns)" - echo "&$domain:$nsip:$nsname" +for tld in db/ip/?? ; do + if [ "x$(basename $tld)" != 'x??' ]; then + first="$(basename $tld | ./scripts/hex2dec)" + tldname="$first.in-addr.arpa" + echo "+$tldsrvrname:$tldsrvrip:3600" + echo ".$tldname::$tldsrvrname" + for ip in $tld/??/?? ; do + if [ "x$(basename $ip)" != 'x??' ]; then + third="$(basename $ip | ./scripts/hex2dec)" + second="$(basename $(dirname $ip) | ./scripts/hex2dec)" + first="$(basename $(dirname $(dirname $ip)) | ./scripts/hex2dec)" + domain="$third.$second.$first.in-addr.arpa" + for ns in $ip/ns/* ; do + nsname="$(basename $ns)" + if [ "x$nsname" != 'x*' ]; then + nsip="$(cat $ns)" + echo "&$domain:$nsip:$nsname" + fi + done + fi done - done + fi done for tld in db/dom/* ; do tldname="$(basename $tld)" |