annotate scripts/nameserver_autogen/bind_tld_zonefile.sh @ 1148:5c239f21ff7e draft

fixed a bug where I used a literal instead of one of the user defined variables (thx mkz)
author epoch <epoch@hacking.allowed.org>
date Mon, 04 Nov 2013 11:56:20 +0000
parents c95369b825a2
children 135e7c234e24
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
1138
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
15 echo -n "generating ipv4 reverse lookup zonefile for 1/8..."
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
16
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
17 echo "; this zonefile genreated on: `date`" > "$RDNS_ZONEFILE"
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
18 echo '$TTL 3600' >> "$RDNS_ZONEFILE"
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
19 echo '@ IN SOA localhost. root.localhost. ('`date +" %Y%m%d%H"`' 60 300 3600000 3600 )' >> "$RDNS_ZONEFILE"
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
20 echo '@ IN NS localhost.' >> "$RDNS_ZONEFILE"
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
21 echo 'localhost. IN A 127.0.0.1' >> "$RDNS_ZONEFILE"
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
22
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
23 for i in `ls ${RESDB_PATH}/db/ip/01/*/*/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
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
36 echo "; this zonefile genreated on: `date`" > "$ANO_ZONEFILE"
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
37 echo '$TTL 3600' >> "$ANO_ZONEFILE"
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
38 echo '@ IN SOA localhost. root.localhost. ('`date +" %Y%m%d%H"`' 60 300 3600000 3600 )' >> "$ANO_ZONEFILE"
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
39 echo '@ IN NS localhost.' >> "$ANO_ZONEFILE"
c95369b825a2 whoisd... don't remember.
epoch <epoch@hacking.allowed.org>
parents: 1120
diff changeset
40 echo 'localhost. IN A 127.0.0.1' >> "$ANO_ZONEFILE"
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.