annotate scripts/check_db_safety @ 1260:f5ad11b817f1 draft default tip master

switched to using the git subdomain for git repo url
author epoch <epoch@hack.thebackupbox.net>
date Sat, 09 Oct 2021 09:21:28 +0000
parents 2dcb03d77b03
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
41b330b11a33 coded a tinydns datafile generator
Nick <nick@somerandomnick.ano>
parents:
diff changeset
1 #!/bin/sh
1204
2dcb03d77b03 scripts/check_db_safety: don't complain so much about missing things
cathugger <cathugger@cock.li>
parents: 1166
diff changeset
2 if [ "$(ls db/dom/ 2>/dev/null | tr -d 'a-z0-9\n\-' | wc -c | tr -d ' \t')" != 0 ]; then
12
41b330b11a33 coded a tinydns datafile generator
Nick <nick@somerandomnick.ano>
parents:
diff changeset
3 echo "There's a bad TLD. You probably don't want to run any shell scripts." >&2
41b330b11a33 coded a tinydns datafile generator
Nick <nick@somerandomnick.ano>
parents:
diff changeset
4 exit 1
41b330b11a33 coded a tinydns datafile generator
Nick <nick@somerandomnick.ano>
parents:
diff changeset
5 fi
41b330b11a33 coded a tinydns datafile generator
Nick <nick@somerandomnick.ano>
parents:
diff changeset
6 for tld in db/dom/* ; do
1204
2dcb03d77b03 scripts/check_db_safety: don't complain so much about missing things
cathugger <cathugger@cock.li>
parents: 1166
diff changeset
7 [ -e "$tld" ] || continue
2dcb03d77b03 scripts/check_db_safety: don't complain so much about missing things
cathugger <cathugger@cock.li>
parents: 1166
diff changeset
8 if [ "$(ls $tld/ 2>/dev/null| tr -d 'a-z0-9\n\-' | wc -c | tr -d ' \t')" != 0 ]; then
12
41b330b11a33 coded a tinydns datafile generator
Nick <nick@somerandomnick.ano>
parents:
diff changeset
9 tld="$(basename $tld)"
41b330b11a33 coded a tinydns datafile generator
Nick <nick@somerandomnick.ano>
parents:
diff changeset
10 echo "There's a bad domain under $tld." >&2
41b330b11a33 coded a tinydns datafile generator
Nick <nick@somerandomnick.ano>
parents:
diff changeset
11 echo "You probably don't want to run any shell scripts." >&2
41b330b11a33 coded a tinydns datafile generator
Nick <nick@somerandomnick.ano>
parents:
diff changeset
12 exit 1
41b330b11a33 coded a tinydns datafile generator
Nick <nick@somerandomnick.ano>
parents:
diff changeset
13 fi
41b330b11a33 coded a tinydns datafile generator
Nick <nick@somerandomnick.ano>
parents:
diff changeset
14 for dom in $tld/* ; do
1204
2dcb03d77b03 scripts/check_db_safety: don't complain so much about missing things
cathugger <cathugger@cock.li>
parents: 1166
diff changeset
15 [ -e "$dom" ] || continue
2dcb03d77b03 scripts/check_db_safety: don't complain so much about missing things
cathugger <cathugger@cock.li>
parents: 1166
diff changeset
16 if [ "$(ls $dom/ns/ 2>/dev/null | tr -d 'A-Fa-z0-9\n.:\-' | wc -c | tr -d ' \t')" != 0 ]; then
12
41b330b11a33 coded a tinydns datafile generator
Nick <nick@somerandomnick.ano>
parents:
diff changeset
17 domain="$(basename $dom).$(basename $tld)"
41b330b11a33 coded a tinydns datafile generator
Nick <nick@somerandomnick.ano>
parents:
diff changeset
18 echo "There's a bad nameserver under $domain." >&2
41b330b11a33 coded a tinydns datafile generator
Nick <nick@somerandomnick.ano>
parents:
diff changeset
19 echo "You probably don't want to run any shell scripts." >&2
532
c9a7817b5f1d reverting IPv6 changes because too much new complexity and no real benefit
Nick <nick@somerandomnick.ano>
parents: 78
diff changeset
20 exit 1
12
41b330b11a33 coded a tinydns datafile generator
Nick <nick@somerandomnick.ano>
parents:
diff changeset
21 fi
41b330b11a33 coded a tinydns datafile generator
Nick <nick@somerandomnick.ano>
parents:
diff changeset
22 for ns in $dom/ns/* ; do
1204
2dcb03d77b03 scripts/check_db_safety: don't complain so much about missing things
cathugger <cathugger@cock.li>
parents: 1166
diff changeset
23 [ -e "$ns" ] || continue
1145
b19ced4435be allow ipv6 addresses as nameserver
SeekingFor <nobody@nowhere>
parents: 896
diff changeset
24 if [ "$(cat $ns | tr -d 'A-Fa-f0-9.:\r\n' | wc -c | tr -d ' \t')" != 0 ]; then
12
41b330b11a33 coded a tinydns datafile generator
Nick <nick@somerandomnick.ano>
parents:
diff changeset
25 domain="$(basename $dom).$(basename $tld)"
41b330b11a33 coded a tinydns datafile generator
Nick <nick@somerandomnick.ano>
parents:
diff changeset
26 nsname="$(basename $ns)"
41b330b11a33 coded a tinydns datafile generator
Nick <nick@somerandomnick.ano>
parents:
diff changeset
27 echo "There's a bad nameserver IP under $domain, for" >&2
41b330b11a33 coded a tinydns datafile generator
Nick <nick@somerandomnick.ano>
parents:
diff changeset
28 echo " $nsname" >&2
41b330b11a33 coded a tinydns datafile generator
Nick <nick@somerandomnick.ano>
parents:
diff changeset
29 echo "You probably don't want to run any shell scripts." >&2
532
c9a7817b5f1d reverting IPv6 changes because too much new complexity and no real benefit
Nick <nick@somerandomnick.ano>
parents: 78
diff changeset
30 exit 1
12
41b330b11a33 coded a tinydns datafile generator
Nick <nick@somerandomnick.ano>
parents:
diff changeset
31 fi
41b330b11a33 coded a tinydns datafile generator
Nick <nick@somerandomnick.ano>
parents:
diff changeset
32 done
41b330b11a33 coded a tinydns datafile generator
Nick <nick@somerandomnick.ano>
parents:
diff changeset
33 done
41b330b11a33 coded a tinydns datafile generator
Nick <nick@somerandomnick.ano>
parents:
diff changeset
34 done
1204
2dcb03d77b03 scripts/check_db_safety: don't complain so much about missing things
cathugger <cathugger@cock.li>
parents: 1166
diff changeset
35 if [ "$(ls db/ip/ 2>/dev/null | tr -d 'A-F0-9\n' | wc -c | tr -d ' \t')" != 0 ]; then
13
059b5f3d7808 added rDNS to tinydns datafile generation
Nick <nick@somerandomnick.ano>
parents: 12
diff changeset
36 echo "There's a bad first octet. You probably don't want to run any shell scripts." >&2
059b5f3d7808 added rDNS to tinydns datafile generation
Nick <nick@somerandomnick.ano>
parents: 12
diff changeset
37 exit 1
059b5f3d7808 added rDNS to tinydns datafile generation
Nick <nick@somerandomnick.ano>
parents: 12
diff changeset
38 for first in db/ip/* ; do
1204
2dcb03d77b03 scripts/check_db_safety: don't complain so much about missing things
cathugger <cathugger@cock.li>
parents: 1166
diff changeset
39 [ -e "$first" ] || continue
2dcb03d77b03 scripts/check_db_safety: don't complain so much about missing things
cathugger <cathugger@cock.li>
parents: 1166
diff changeset
40 if [ "$(ls $first/ 2>/dev/null | tr -d 'A-F0-9\n' | wc -c | tr -d ' \t')" != 0 ]; then
13
059b5f3d7808 added rDNS to tinydns datafile generation
Nick <nick@somerandomnick.ano>
parents: 12
diff changeset
41 echo "There's a bad second octet under $first." >&2
059b5f3d7808 added rDNS to tinydns datafile generation
Nick <nick@somerandomnick.ano>
parents: 12
diff changeset
42 echo "You probably don't want to run any shell scripts." >&2
059b5f3d7808 added rDNS to tinydns datafile generation
Nick <nick@somerandomnick.ano>
parents: 12
diff changeset
43 exit 1
059b5f3d7808 added rDNS to tinydns datafile generation
Nick <nick@somerandomnick.ano>
parents: 12
diff changeset
44 for second in $first/* ; do
1204
2dcb03d77b03 scripts/check_db_safety: don't complain so much about missing things
cathugger <cathugger@cock.li>
parents: 1166
diff changeset
45 [ -e "$second" ] || continue
2dcb03d77b03 scripts/check_db_safety: don't complain so much about missing things
cathugger <cathugger@cock.li>
parents: 1166
diff changeset
46 if [ "$(ls $second/ 2>/dev/null | tr -d 'A-F0-9\n' | wc -c | tr -d ' \t')" != 0 ]; then
13
059b5f3d7808 added rDNS to tinydns datafile generation
Nick <nick@somerandomnick.ano>
parents: 12
diff changeset
47 echo "There's a bad third octet under $second." >&2
059b5f3d7808 added rDNS to tinydns datafile generation
Nick <nick@somerandomnick.ano>
parents: 12
diff changeset
48 echo "You probably don't want to run any shell scripts." >&2
059b5f3d7808 added rDNS to tinydns datafile generation
Nick <nick@somerandomnick.ano>
parents: 12
diff changeset
49 exit 1
059b5f3d7808 added rDNS to tinydns datafile generation
Nick <nick@somerandomnick.ano>
parents: 12
diff changeset
50 fi
059b5f3d7808 added rDNS to tinydns datafile generation
Nick <nick@somerandomnick.ano>
parents: 12
diff changeset
51 for third in $second/* ; do
1204
2dcb03d77b03 scripts/check_db_safety: don't complain so much about missing things
cathugger <cathugger@cock.li>
parents: 1166
diff changeset
52 [ -e "$third" ] || continue
2dcb03d77b03 scripts/check_db_safety: don't complain so much about missing things
cathugger <cathugger@cock.li>
parents: 1166
diff changeset
53 if [ "$(ls $third/ns/ 2>/dev/null | tr -d 'a-z0-9\n.\-' | wc -c | tr -d ' \t')" != 0 ]; then
13
059b5f3d7808 added rDNS to tinydns datafile generation
Nick <nick@somerandomnick.ano>
parents: 12
diff changeset
54 ip="$(basename $first).$(basename $second).$(basename $third).0/24"
059b5f3d7808 added rDNS to tinydns datafile generation
Nick <nick@somerandomnick.ano>
parents: 12
diff changeset
55 echo "There's a bad nameserver under $ip." >&2
059b5f3d7808 added rDNS to tinydns datafile generation
Nick <nick@somerandomnick.ano>
parents: 12
diff changeset
56 echo "You probably don't want to run any shell scripts." >&2
532
c9a7817b5f1d reverting IPv6 changes because too much new complexity and no real benefit
Nick <nick@somerandomnick.ano>
parents: 78
diff changeset
57 exit 1
13
059b5f3d7808 added rDNS to tinydns datafile generation
Nick <nick@somerandomnick.ano>
parents: 12
diff changeset
58 fi
059b5f3d7808 added rDNS to tinydns datafile generation
Nick <nick@somerandomnick.ano>
parents: 12
diff changeset
59 for ns in $third/ns/* ; do
1204
2dcb03d77b03 scripts/check_db_safety: don't complain so much about missing things
cathugger <cathugger@cock.li>
parents: 1166
diff changeset
60 [ -e "$ns" ] || continue
78
f37d8fca5548 more OpenBSD fixes (again, thanks Quintum)
Nick <nick@somerandomnick.ano>
parents: 77
diff changeset
61 if [ "$(cat $ns | tr -d '0-9.\n' | wc -c | tr -d ' \t')" != 0 ]; then
13
059b5f3d7808 added rDNS to tinydns datafile generation
Nick <nick@somerandomnick.ano>
parents: 12
diff changeset
62 ip="$(basename $first).$(basename $second).$(basename $third).0/24"
059b5f3d7808 added rDNS to tinydns datafile generation
Nick <nick@somerandomnick.ano>
parents: 12
diff changeset
63 nsname="$(basename $ns)"
059b5f3d7808 added rDNS to tinydns datafile generation
Nick <nick@somerandomnick.ano>
parents: 12
diff changeset
64 echo "There's a bad nameserver IP under $ip, for" >&2
059b5f3d7808 added rDNS to tinydns datafile generation
Nick <nick@somerandomnick.ano>
parents: 12
diff changeset
65 echo " $nsname" >&2
059b5f3d7808 added rDNS to tinydns datafile generation
Nick <nick@somerandomnick.ano>
parents: 12
diff changeset
66 echo "You probably don't want to run any shell scripts." >&2
532
c9a7817b5f1d reverting IPv6 changes because too much new complexity and no real benefit
Nick <nick@somerandomnick.ano>
parents: 78
diff changeset
67 exit 1
13
059b5f3d7808 added rDNS to tinydns datafile generation
Nick <nick@somerandomnick.ano>
parents: 12
diff changeset
68 fi
059b5f3d7808 added rDNS to tinydns datafile generation
Nick <nick@somerandomnick.ano>
parents: 12
diff changeset
69 done
059b5f3d7808 added rDNS to tinydns datafile generation
Nick <nick@somerandomnick.ano>
parents: 12
diff changeset
70 done
059b5f3d7808 added rDNS to tinydns datafile generation
Nick <nick@somerandomnick.ano>
parents: 12
diff changeset
71 done
059b5f3d7808 added rDNS to tinydns datafile generation
Nick <nick@somerandomnick.ano>
parents: 12
diff changeset
72 fi
059b5f3d7808 added rDNS to tinydns datafile generation
Nick <nick@somerandomnick.ano>
parents: 12
diff changeset
73 done
059b5f3d7808 added rDNS to tinydns datafile generation
Nick <nick@somerandomnick.ano>
parents: 12
diff changeset
74 fi