Mercurial > hg > anonet-resdb
comparison scripts/check_db_safety @ 1204:2dcb03d77b03 draft
scripts/check_db_safety: don't complain so much about missing things
they aren't unsafe
author | cathugger <cathugger@cock.li> |
---|---|
date | Sun, 13 May 2018 12:40:39 +0000 |
parents | e991761c3da8 |
children |
comparison
equal
deleted
inserted
replaced
1203:eeef7c9bc251 | 1204:2dcb03d77b03 |
---|---|
1 #!/bin/sh | 1 #!/bin/sh |
2 if [ "$(ls db/dom/ | tr -d 'a-z0-9\n\-' | wc -c | tr -d ' \t')" != 0 ]; then | 2 if [ "$(ls db/dom/ 2>/dev/null | tr -d 'a-z0-9\n\-' | wc -c | tr -d ' \t')" != 0 ]; then |
3 echo "There's a bad TLD. You probably don't want to run any shell scripts." >&2 | 3 echo "There's a bad TLD. You probably don't want to run any shell scripts." >&2 |
4 exit 1 | 4 exit 1 |
5 fi | 5 fi |
6 for tld in db/dom/* ; do | 6 for tld in db/dom/* ; do |
7 if [ "$(ls $tld/ | tr -d 'a-z0-9\n\-' | wc -c | tr -d ' \t')" != 0 ]; then | 7 [ -e "$tld" ] || continue |
8 if [ "$(ls $tld/ 2>/dev/null| tr -d 'a-z0-9\n\-' | wc -c | tr -d ' \t')" != 0 ]; then | |
8 tld="$(basename $tld)" | 9 tld="$(basename $tld)" |
9 echo "There's a bad domain under $tld." >&2 | 10 echo "There's a bad domain under $tld." >&2 |
10 echo "You probably don't want to run any shell scripts." >&2 | 11 echo "You probably don't want to run any shell scripts." >&2 |
11 exit 1 | 12 exit 1 |
12 fi | 13 fi |
13 for dom in $tld/* ; do | 14 for dom in $tld/* ; do |
14 if [ "$(ls $dom/ns/ | tr -d 'A-Fa-z0-9\n.:\-' | wc -c | tr -d ' \t')" != 0 ]; then | 15 [ -e "$dom" ] || continue |
16 if [ "$(ls $dom/ns/ 2>/dev/null | tr -d 'A-Fa-z0-9\n.:\-' | wc -c | tr -d ' \t')" != 0 ]; then | |
15 domain="$(basename $dom).$(basename $tld)" | 17 domain="$(basename $dom).$(basename $tld)" |
16 echo "There's a bad nameserver under $domain." >&2 | 18 echo "There's a bad nameserver under $domain." >&2 |
17 echo "You probably don't want to run any shell scripts." >&2 | 19 echo "You probably don't want to run any shell scripts." >&2 |
18 exit 1 | 20 exit 1 |
19 fi | 21 fi |
20 for ns in $dom/ns/* ; do | 22 for ns in $dom/ns/* ; do |
23 [ -e "$ns" ] || continue | |
21 if [ "$(cat $ns | tr -d 'A-Fa-f0-9.:\r\n' | wc -c | tr -d ' \t')" != 0 ]; then | 24 if [ "$(cat $ns | tr -d 'A-Fa-f0-9.:\r\n' | wc -c | tr -d ' \t')" != 0 ]; then |
22 domain="$(basename $dom).$(basename $tld)" | 25 domain="$(basename $dom).$(basename $tld)" |
23 nsname="$(basename $ns)" | 26 nsname="$(basename $ns)" |
24 echo "There's a bad nameserver IP under $domain, for" >&2 | 27 echo "There's a bad nameserver IP under $domain, for" >&2 |
25 echo " $nsname" >&2 | 28 echo " $nsname" >&2 |
27 exit 1 | 30 exit 1 |
28 fi | 31 fi |
29 done | 32 done |
30 done | 33 done |
31 done | 34 done |
32 if [ "$(ls db/ip/ | tr -d 'A-F0-9\n' | wc -c | tr -d ' \t')" != 0 ]; then | 35 if [ "$(ls db/ip/ 2>/dev/null | tr -d 'A-F0-9\n' | wc -c | tr -d ' \t')" != 0 ]; then |
33 echo "There's a bad first octet. You probably don't want to run any shell scripts." >&2 | 36 echo "There's a bad first octet. You probably don't want to run any shell scripts." >&2 |
34 exit 1 | 37 exit 1 |
35 for first in db/ip/* ; do | 38 for first in db/ip/* ; do |
36 if [ "$(ls $first/ | tr -d 'A-F0-9\n' | wc -c | tr -d ' \t')" != 0 ]; then | 39 [ -e "$first" ] || continue |
40 if [ "$(ls $first/ 2>/dev/null | tr -d 'A-F0-9\n' | wc -c | tr -d ' \t')" != 0 ]; then | |
37 echo "There's a bad second octet under $first." >&2 | 41 echo "There's a bad second octet under $first." >&2 |
38 echo "You probably don't want to run any shell scripts." >&2 | 42 echo "You probably don't want to run any shell scripts." >&2 |
39 exit 1 | 43 exit 1 |
40 for second in $first/* ; do | 44 for second in $first/* ; do |
41 if [ "$(ls $second/ | tr -d 'A-F0-9\n' | wc -c | tr -d ' \t')" != 0 ]; then | 45 [ -e "$second" ] || continue |
46 if [ "$(ls $second/ 2>/dev/null | tr -d 'A-F0-9\n' | wc -c | tr -d ' \t')" != 0 ]; then | |
42 echo "There's a bad third octet under $second." >&2 | 47 echo "There's a bad third octet under $second." >&2 |
43 echo "You probably don't want to run any shell scripts." >&2 | 48 echo "You probably don't want to run any shell scripts." >&2 |
44 exit 1 | 49 exit 1 |
45 fi | 50 fi |
46 for third in $second/* ; do | 51 for third in $second/* ; do |
47 if [ "$(ls $third/ns/ | tr -d 'a-z0-9\n.\-' | wc -c | tr -d ' \t')" != 0 ]; then | 52 [ -e "$third" ] || continue |
53 if [ "$(ls $third/ns/ 2>/dev/null | tr -d 'a-z0-9\n.\-' | wc -c | tr -d ' \t')" != 0 ]; then | |
48 ip="$(basename $first).$(basename $second).$(basename $third).0/24" | 54 ip="$(basename $first).$(basename $second).$(basename $third).0/24" |
49 echo "There's a bad nameserver under $ip." >&2 | 55 echo "There's a bad nameserver under $ip." >&2 |
50 echo "You probably don't want to run any shell scripts." >&2 | 56 echo "You probably don't want to run any shell scripts." >&2 |
51 exit 1 | 57 exit 1 |
52 fi | 58 fi |
53 for ns in $third/ns/* ; do | 59 for ns in $third/ns/* ; do |
60 [ -e "$ns" ] || continue | |
54 if [ "$(cat $ns | tr -d '0-9.\n' | wc -c | tr -d ' \t')" != 0 ]; then | 61 if [ "$(cat $ns | tr -d '0-9.\n' | wc -c | tr -d ' \t')" != 0 ]; then |
55 ip="$(basename $first).$(basename $second).$(basename $third).0/24" | 62 ip="$(basename $first).$(basename $second).$(basename $third).0/24" |
56 nsname="$(basename $ns)" | 63 nsname="$(basename $ns)" |
57 echo "There's a bad nameserver IP under $ip, for" >&2 | 64 echo "There's a bad nameserver IP under $ip, for" >&2 |
58 echo " $nsname" >&2 | 65 echo " $nsname" >&2 |