etc/services - sync with NetBSD-8
[minix.git] / external / bsd / bind / dist / bin / tests / bigtest / buildzones.sh
blobac85d13d6902ac8fbb0aab8133be31e6b94aac14
1 #!/bin/bash
3 # Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
5 # Permission to use, copy, modify, and/or distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 # AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 # PERFORMANCE OF THIS SOFTWARE.
17 SYSTEMTESTTOP=..
18 . ../conf.sh
20 addr=127.127.0.0
21 ttl=300
22 named=${NAMED}
23 keygen=${KEYGEN}
24 dsfromkey=${DSFROMKEY}
26 nextaddr() {
27 OLDIF="$IFS"
28 IFS="${IFS}."
29 set $1
30 IFS="$OLDIFS"
31 _a=$1 _b=$2 _c=$3 _d=$4
32 _d=$(($_d + 1))
33 case $_d in
34 256) _c=$(($_c + 1)); _d=0;;
35 esac
36 case $_c in
37 256) _b=$(($_b + 1)); _c=0;;
38 esac
39 echo $_a.$_b.$_c.$_d
42 parent() {
43 OLDIF="$IFS"
44 IFS="${IFS}."
45 set $1
46 IFS="$OLDIFS"
47 shift
48 while [ $# -ne 0 ]
50 printf %s ${1}
51 shift
52 printf %s ${1:+.}
54 done
57 blackhole() {
58 echo 'options {'
59 echo ' port 5300;'
60 echo " listen-on { $1; };"
61 echo " query-source $1;"
62 echo " notify-source $1;"
63 echo " transfer-source $1;"
64 echo ' key-directory "keys";'
65 echo " recursion ${2:-no};"
66 echo ' pid-file "pids/'"${addr}"'.pid";'
67 echo ' blackhole { 127.127.0.0; };'
68 echo '};'
71 refuse() {
72 echo 'options {'
73 echo ' port 5300;'
74 echo " listen-on { $1; };"
75 echo " query-source $1;"
76 echo " notify-source $1;"
77 echo " transfer-source $1;"
78 echo ' key-directory "keys";'
79 echo " recursion ${2:-no};"
80 echo ' pid-file "pids/'"${addr}"'.pid";'
81 echo ' allow-query { !127.127.0.0; any; };'
82 echo '};'
85 options() {
86 echo 'options {'
87 echo ' port 5300;'
88 echo " listen-on { $1; };"
89 echo " query-source $1;"
90 echo " notify-source $1;"
91 echo " transfer-source $1;"
92 echo ' key-directory "keys";'
93 echo " recursion ${2:-no};"
94 echo ' pid-file "pids/'"${addr}"'.pid";'
95 echo '};'
98 controls() {
99 echo 'include "rndc.key";'
100 echo "controls { inet $addr port 9953 allow { any; } keys { "rndc-key"; }; };"
103 delay() {
104 _s=$1
105 OLDIF="$IFS"
106 IFS="${IFS}/"
107 set ${2:-.}
108 IFS="$OLDIFS"
110 case $1 in
111 .) _d=;;
112 *) _d=$1;;
113 esac
114 case $_s in
115 1) echo -T delay=${_d:-100};;
116 2) echo -T delay=${2:-50};;
117 3) echo -T delay=${3:-150};;
118 4) echo -T delay=${4:-250};;
119 5) echo -T delay=${5:-125};;
120 6) echo -T delay=${6:-25};;
121 7) echo -T delay=${7:-75};;
122 8) echo -T delay=${8:-125};;
123 9) echo -T delay=${9:-10};;
124 10) echo -T delay=${10:-40};;
125 11) echo -T delay=${11:-80};;
126 12) echo -T delay=${12:-90};;
127 *) echo -T delay=50;;
128 esac
131 trusted-keys () {
132 awk '$3 == "DNSKEY" {
133 b = ""; for (i=7; i <= NF; i++) { b = b $i; };
134 print "trusted-keys { \""$1"\"",$4,$5,$6,"\""b"\"; };" };'
137 signed-zone () {
138 echo "zone "'"'"${1:-.}"'"'" {"
139 echo " type master;"
140 echo " file "'"'"master/${2}.db"'"'";"
141 echo " auto-dnssec maintain;"
142 echo " allow-update { any; };"
143 echo "};"
146 unsigned-zone () {
147 echo "zone "'"'"${1:-.}"'"'" {"
148 echo " type master;"
149 echo " file "'"'"master/${2}.db"'"'";"
150 echo "};"
153 slave-zone () {
154 echo "zone "'"'"${zone:-.}"'"'" {"
155 echo " type slave;"
156 echo " masters { ${master}; };"
157 echo "};"
160 rm -rf servers master keys setup teardown run
161 mkdir -p servers
162 mkdir -p master
163 mkdir -p keys
165 echo "ifconfig lo0 $addr netmask 0xffffffff alias" >> setup
166 echo "ifconfig lo0 $addr -alias" >> teardown
167 controls $addr > named.conf
168 options $addr yes >> named.conf
169 echo 'zone "." { type hint; file "master/hint.db"; };' >> named.conf
171 while read zone servers nsfmt signed delay blackhole refuse flags
174 case "${zone}" in
175 .) file=root zone=;;
176 *) file="$zone";;
177 esac
178 if [ "${zone}" != "" ] ; then
179 p=$(parent $zone)
180 case "${p}" in
181 "") p=root;;
182 esac
183 else
184 p=hint
186 #echo "zone='${zone}' parent='${p}'"
187 addr=$(nextaddr $addr)
188 ns=$(printf "$nsfmt" ${i} "${zone}")
189 d=$(delay $i ${delay:-.})
191 echo "${zone}. ${ttl} soa ${ns}. hostmaster.${zone}${zone:+.} 1 3600 1200 604800 1200" >> master/${file}.db
192 echo "${zone}. ${ttl} ns ${ns}." >> master/${file}.db
193 echo "${ns}. ${ttl} a ${addr}" >> master/${file}.db
194 echo "${zone}. ${ttl} ns ${ns}." >> master/${p}.db
195 echo "${ns}. ${ttl} a ${addr}" >> master/${p}.db
196 if [ $signed = "S" ]; then
197 kskkey=`${keygen} -K keys -f KSK ${zone:-.}`
198 zskkey=`${keygen} -K keys ${zone:-.}`
199 if [ "${zone}" != "" ] ; then
200 ${dsfromkey} -T ${ttl} keys/${kskkey}.key >> master/${p}.db
201 else
202 trusted-keys < keys/${kskkey}.key >> named.conf
205 echo "ifconfig lo0 $addr netmask 0xffffffff alias" >> setup
206 echo "ifconfig lo0 $addr -alias" >> teardown
207 echo "${named} -D bigtest -c servers/${addr}.conf $d $flags" >> run
208 options ${addr} > servers/${addr}.conf
209 case ${signed} in
210 S) signed-zone ${zone:-.} ${file} >> servers/${addr}.conf;;
211 P) unsigned-zone ${zone:-.} ${file} >> servers/${addr}.conf;;
212 *) echo ${signed}; exit 1;;
213 esac
215 # slave servers
216 while [ $i -lt $servers ]
218 master=$addr
219 i=$(($i + 1))
220 ns=$(printf "$nsfmt" ${i} "${zone}")
221 d=$(delay $i ${delay:-.})
222 addr=$(nextaddr $addr)
223 echo "${zone}. ${ttl} ns ${ns}." >> master/${file}.db
224 echo "${ns}. ${ttl} a ${addr}" >> master/${file}.db
225 echo "${zone}. ${ttl} ns ${ns}." >> master/${p}.db
226 echo "${ns}. ${ttl} a ${addr}" >> master/${p}.db
227 echo "ifconfig lo0 $addr netmask 0xffffffff alias" >> setup
228 echo "ifconfig lo0 $addr -alias" >> teardown
229 echo "${named} -D bigtest -c servers/${addr}.conf $d $flags" >> run
230 if [ $i = ${refuse:-.} ]
231 then
232 refuse $addr > servers/${addr}.conf
233 elif [ $i = ${blackhole:-.} ]
234 then
235 blackhole $addr > servers/${addr}.conf
236 else
237 options $addr > servers/${addr}.conf
239 slave-zone ${zone:-.} ${master} >> servers/${addr}.conf
240 done
241 if [ "${zone}" != "" ] ; then
242 echo "www.${zone}. ${ttl} a 127.0.0.1" >> master/${file}.db
243 echo "www.${zone}. ${ttl} aaaa ::1" >> master/${file}.db
244 echo "${zone}. ${ttl} mx 10 mail.${zone}." >> master/${file}.db
245 echo "mail.${zone}. ${ttl} a 127.0.0.1" >> master/${file}.db
246 echo "mail.${zone}. ${ttl} aaaa ::1" >> master/${file}.db
247 echo "*.big.${zone}. ${ttl} txt (" >> master/${file}.db
249 while [ $i -lt 150 ]
251 echo "1234567890" >> master/${file}.db
252 i=$(($i + 1))
253 done
254 echo ")" >> master/${file}.db
255 echo "*.medium.${zone}. ${ttl} txt (" >> master/${file}.db
257 while [ $i -lt 120 ]
259 echo "1234567890" >> master/${file}.db
260 i=$(($i + 1))
261 done
262 echo ")" >> master/${file}.db
263 echo "*.medium.${zone}. ${ttl} txt (" >> master/${file}.db
265 while [ $i -lt 120 ]
267 echo "1234567890" >> master/${file}.db
268 i=$(($i + 1))
269 done
270 echo ")" >> master/${file}.db
272 done