annotate scripts/nameserver_autogen/bind_tld_zonefile.sh @ 1191:56c959ab3e05 draft

use UTC for dates, 1->21
author cathugger <cathugger@cock.li>
date Fri, 10 Mar 2017 00:46:19 +0000
parents 135e7c234e24
children dfda92fd4ec3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1120
8e01b8361e9e changed add_dom to not even bother with anything head -c -1 related. should still work.
epoch <epoch@hacking.allowed.org>
parents:
diff changeset
1 #!/bin/bash
8e01b8361e9e changed add_dom to not even bother with anything head -c -1 related. should still work.
epoch <epoch@hacking.allowed.org>
parents:
diff changeset
2 #made for bash. not sure if all /bin/sh work.
8e01b8361e9e changed add_dom to not even bother with anything head -c -1 related. should still work.
epoch <epoch@hacking.allowed.org>
parents:
diff changeset
3 #be sure to edit these variables first.
8e01b8361e9e changed add_dom to not even bother with anything head -c -1 related. should still work.
epoch <epoch@hacking.allowed.org>
parents:
diff changeset
4
1148
5c239f21ff7e fixed a bug where I used a literal instead of one of the user defined variables (thx mkz)
epoch <epoch@hacking.allowed.org>
parents: 1138
diff changeset
5 #ANO_ZONEFILE=/etc/namedb/ano
5c239f21ff7e fixed a bug where I used a literal instead of one of the user defined variables (thx mkz)
epoch <epoch@hacking.allowed.org>
parents: 1138
diff changeset
6 #RDNS_ZONEFILE=/etc/namedb/1.in-addr.arpa
5c239f21ff7e fixed a bug where I used a literal instead of one of the user defined variables (thx mkz)
epoch <epoch@hacking.allowed.org>
parents: 1138
diff changeset
7 #RESDB_PATH=/services/resdb/resdb
1120
8e01b8361e9e changed add_dom to not even bother with anything head -c -1 related. should still work.
epoch <epoch@hacking.allowed.org>
parents:
diff changeset
8
1148
5c239f21ff7e fixed a bug where I used a literal instead of one of the user defined variables (thx mkz)
epoch <epoch@hacking.allowed.org>
parents: 1138
diff changeset
9 if [ ! "$ANO_ZONEFILE" ];then
5c239f21ff7e fixed a bug where I used a literal instead of one of the user defined variables (thx mkz)
epoch <epoch@hacking.allowed.org>
parents: 1138
diff changeset
10 echo "You forgot to set some variables. read the source plzkthx."
5c239f21ff7e fixed a bug where I used a literal instead of one of the user defined variables (thx mkz)
epoch <epoch@hacking.allowed.org>
parents: 1138
diff changeset
11 exit 0;
5c239f21ff7e fixed a bug where I used a literal instead of one of the user defined variables (thx mkz)
epoch <epoch@hacking.allowed.org>
parents: 1138
diff changeset
12 fi
1120
8e01b8361e9e changed add_dom to not even bother with anything head -c -1 related. should still work.
epoch <epoch@hacking.allowed.org>
parents:
diff changeset
13
8e01b8361e9e changed add_dom to not even bother with anything head -c -1 related. should still work.
epoch <epoch@hacking.allowed.org>
parents:
diff changeset
14
1191
56c959ab3e05 use UTC for dates, 1->21
cathugger <cathugger@cock.li>
parents: 1182
diff changeset
15 echo -n "generating ipv4 reverse lookup zonefile for 21/8..."
1138
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
16
1191
56c959ab3e05 use UTC for dates, 1->21
cathugger <cathugger@cock.li>
parents: 1182
diff changeset
17 echo "; this zonefile genreated on: `date -u`" > "$RDNS_ZONEFILE"
1138
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
18 echo '$TTL 3600' >> "$RDNS_ZONEFILE"
1191
56c959ab3e05 use UTC for dates, 1->21
cathugger <cathugger@cock.li>
parents: 1182
diff changeset
19 echo '@ IN SOA @ root ('`date -u +" %Y%m%d%H"`' 60 300 3600000 3600 )' >> "$RDNS_ZONEFILE"
1182
135e7c234e24 updated them to have no out-of-zone data.
epoch <epoch@hacking.allowed.ano>
parents: 1148
diff changeset
20 echo '@ IN NS @' >> "$RDNS_ZONEFILE"
135e7c234e24 updated them to have no out-of-zone data.
epoch <epoch@hacking.allowed.ano>
parents: 1148
diff changeset
21 echo '@ IN A 127.0.0.1' >> "$RDNS_ZONEFILE"
1138
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
22
1191
56c959ab3e05 use UTC for dates, 1->21
cathugger <cathugger@cock.li>
parents: 1182
diff changeset
23 for i in `ls ${RESDB_PATH}/db/ip/15/*/*/ns/*`;do
1138
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
24 f=$(basename $i)
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
25 a=$(basename $(dirname $i))
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
26 b=$(basename $(dirname $(dirname $i)))
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
27 c=$(basename $(dirname $(dirname $(dirname $i))))
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
28 printf "%d.%d IN NS %s\n" $[0x${b}] $[0x${c}] ${f}.
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
29 done >> "$RDNS_ZONEFILE"
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
30 echo done.
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
31
1148
5c239f21ff7e fixed a bug where I used a literal instead of one of the user defined variables (thx mkz)
epoch <epoch@hacking.allowed.org>
parents: 1138
diff changeset
32 cd ${RESDB_PATH}/db/dom/ano
5c239f21ff7e fixed a bug where I used a literal instead of one of the user defined variables (thx mkz)
epoch <epoch@hacking.allowed.org>
parents: 1138
diff changeset
33
1138
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
34 echo -n generating .ano TLD zonefile...
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
35
1191
56c959ab3e05 use UTC for dates, 1->21
cathugger <cathugger@cock.li>
parents: 1182
diff changeset
36 echo "; this zonefile genreated on: `date -u`" > "$ANO_ZONEFILE"
1138
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
37 echo '$TTL 3600' >> "$ANO_ZONEFILE"
1191
56c959ab3e05 use UTC for dates, 1->21
cathugger <cathugger@cock.li>
parents: 1182
diff changeset
38 echo '@ IN SOA @ root ('`date -u +" %Y%m%d%H"`' 60 300 3600000 3600 )' >> "$ANO_ZONEFILE"
1182
135e7c234e24 updated them to have no out-of-zone data.
epoch <epoch@hacking.allowed.ano>
parents: 1148
diff changeset
39 echo '@ IN NS @' >> "$ANO_ZONEFILE"
135e7c234e24 updated them to have no out-of-zone data.
epoch <epoch@hacking.allowed.ano>
parents: 1148
diff changeset
40 echo '@ IN A 127.0.0.1' >> "$ANO_ZONEFILE"
1138
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
41
1148
5c239f21ff7e fixed a bug where I used a literal instead of one of the user defined variables (thx mkz)
epoch <epoch@hacking.allowed.org>
parents: 1138
diff changeset
42
1120
8e01b8361e9e changed add_dom to not even bother with anything head -c -1 related. should still work.
epoch <epoch@hacking.allowed.org>
parents:
diff changeset
43 for name in *;do
8e01b8361e9e changed add_dom to not even bother with anything head -c -1 related. should still work.
epoch <epoch@hacking.allowed.org>
parents:
diff changeset
44 if [ -e "${name}/ns/" ];then
8e01b8361e9e changed add_dom to not even bother with anything head -c -1 related. should still work.
epoch <epoch@hacking.allowed.org>
parents:
diff changeset
45 for server in "$name"/ns/*;do
1138
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
46 if grep '\.ano$' <<< "$name" > /dev/null;then
1120
8e01b8361e9e changed add_dom to not even bother with anything head -c -1 related. should still work.
epoch <epoch@hacking.allowed.org>
parents:
diff changeset
47 true
8e01b8361e9e changed add_dom to not even bother with anything head -c -1 related. should still work.
epoch <epoch@hacking.allowed.org>
parents:
diff changeset
48 fi
1138
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
49 if grep '\.ano$' <<< "$server" > /dev/null;then
1120
8e01b8361e9e changed add_dom to not even bother with anything head -c -1 related. should still work.
epoch <epoch@hacking.allowed.org>
parents:
diff changeset
50 true
8e01b8361e9e changed add_dom to not even bother with anything head -c -1 related. should still work.
epoch <epoch@hacking.allowed.org>
parents:
diff changeset
51 fi
8e01b8361e9e changed add_dom to not even bother with anything head -c -1 related. should still work.
epoch <epoch@hacking.allowed.org>
parents:
diff changeset
52 fqserver=`cut -d/ -f3- <<< $server`
8e01b8361e9e changed add_dom to not even bother with anything head -c -1 related. should still work.
epoch <epoch@hacking.allowed.org>
parents:
diff changeset
53 echo -e "${name}\tIN NS\t${fqserver}."
8e01b8361e9e changed add_dom to not even bother with anything head -c -1 related. should still work.
epoch <epoch@hacking.allowed.org>
parents:
diff changeset
54 for ip in `cat ${server}`;do
1138
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
55 if grep ':' <<< "$ip" > /dev/null;then
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
56 echo -e "${fqserver}.\tIN AAAA\t$ip"
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
57 else
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
58 echo -e "${fqserver}.\tIN A\t$ip"
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
59 fi
1120
8e01b8361e9e changed add_dom to not even bother with anything head -c -1 related. should still work.
epoch <epoch@hacking.allowed.org>
parents:
diff changeset
60 done
8e01b8361e9e changed add_dom to not even bother with anything head -c -1 related. should still work.
epoch <epoch@hacking.allowed.org>
parents:
diff changeset
61 done
8e01b8361e9e changed add_dom to not even bother with anything head -c -1 related. should still work.
epoch <epoch@hacking.allowed.org>
parents:
diff changeset
62 fi
1138
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
63 done >> "$ANO_ZONEFILE"
1120
8e01b8361e9e changed add_dom to not even bother with anything head -c -1 related. should still work.
epoch <epoch@hacking.allowed.org>
parents:
diff changeset
64 echo done.
8e01b8361e9e changed add_dom to not even bother with anything head -c -1 related. should still work.
epoch <epoch@hacking.allowed.org>
parents:
diff changeset
65 echo might want to send a sighup to your named now.