etc/services - sync with NetBSD-8
[minix.git] / external / bsd / bind / dist / contrib / scripts / named-bootconf.sh
blobcac2dcb8961d23f9ad496b5b0248351ad9a22fd6
1 #!/bin/sh
3 # Portions Copyright (C) 2004, 2006, 2007, 2012, 2014 Internet Systems Consortium, Inc. ("ISC")
4 # Portions Copyright (C) 1999-2001 Internet Software Consortium.
6 # Permission to use, copy, modify, and/or distribute this software for any
7 # purpose with or without fee is hereby granted, provided that the above
8 # copyright notice and this permission notice appear in all copies.
10 # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
11 # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
12 # AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
13 # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14 # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
15 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 # PERFORMANCE OF THIS SOFTWARE.
18 # Id: named-bootconf.sh,v 1.12 2007/06/19 23:47:07 tbox Exp
20 # NetBSD: named-bootconf.sh,v 1.5 1998/12/15 01:00:53 tron Exp
22 # Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
23 # All rights reserved.
25 # This code is derived from software contributed to The NetBSD Foundation
26 # by Matthias Scheler.
28 # Redistribution and use in source and binary forms, with or without
29 # modification, are permitted provided that the following conditions
30 # are met:
31 # 1. Redistributions of source code must retain the above copyright
32 # notice, this list of conditions and the following disclaimer.
33 # 2. Redistributions in binary form must reproduce the above copyright
34 # notice, this list of conditions and the following disclaimer in the
35 # documentation and/or other materials provided with the distribution.
37 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
38 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
39 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
40 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
41 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
42 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
43 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
44 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
45 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
47 # POSSIBILITY OF SUCH DAMAGE.
49 if [ ${OPTIONFILE-X} = X ]; then
50 WORKDIR=/tmp/`date +%s`.$$
51 ( umask 077 ; mkdir $WORKDIR ) || {
52 echo "unable to create work directory '$WORKDIR'" >&2
53 exit 1
55 OPTIONFILE=$WORKDIR/options
56 ZONEFILE=$WORKDIR/zones
57 COMMENTFILE=$WORKDIR/comments
58 export OPTIONFILE ZONEFILE COMMENTFILE
59 touch $OPTIONFILE $ZONEFILE $COMMENTFILE
60 DUMP=1
61 else
62 DUMP=0
65 while read CMD ARGS; do
66 class=
67 CMD=`echo "${CMD}" | tr '[A-Z]' '[a-z]'`
68 case $CMD in
69 \; )
70 echo \# $ARGS >>$COMMENTFILE
72 cache )
73 set - X $ARGS
74 shift
75 if [ $# -eq 2 ]; then
76 (echo ""
77 cat $COMMENTFILE
78 echo "zone \"$1\" {"
79 echo " type hint;"
80 echo " file \"$2\";"
81 echo "};") >>$ZONEFILE
82 rm -f $COMMENTFILE
83 touch $COMMENTFILE
86 directory )
87 set - X $ARGS
88 shift
89 if [ $# -eq 1 ]; then
90 (cat $COMMENTFILE
91 echo " directory \"$1\";") >>$OPTIONFILE
92 rm -f $COMMENTFILE
93 touch $COMMENTFILE
95 DIRECTORY=$1
96 export DIRECTORY
99 forwarders )
100 (cat $COMMENTFILE
101 echo " forwarders {"
102 for ARG in $ARGS; do
103 echo " $ARG;"
104 done
105 echo " };") >>$OPTIONFILE
106 rm -f $COMMENTFILE
107 touch $COMMENTFILE
109 include )
110 if [ "$ARGS" != "" ]; then
111 (cd ${DIRECTORY-.}; cat $ARGS) | $0
114 limit )
115 ARGS=`echo "${ARGS}" | tr '[A-Z]' '[a-z]'`
116 set - X $ARGS
117 shift
118 if [ $# -eq 2 ]; then
119 cat $COMMENTFILE >>$OPTIONFILE
120 case $1 in
121 datasize | files | transfers-in | transfers-per-ns )
122 echo " $1 $2;" >>$OPTIONFILE
124 esac
125 rm -f $COMMENTFILE
126 touch $COMMENTFILE
129 options )
130 ARGS=`echo "${ARGS}" | tr '[A-Z]' '[a-z]'`
131 cat $COMMENTFILE >>$OPTIONFILE
132 for ARG in $ARGS; do
133 case $ARG in
134 fake-iquery )
135 echo " fake-iquery yes;" >>$OPTIONFILE
137 forward-only )
138 echo " forward only;" >>$OPTIONFILE
140 no-fetch-glue )
141 echo " fetch-glue no;" >>$OPTIONFILE
143 no-recursion )
144 echo " recursion no;" >>$OPTIONFILE
146 esac
147 done
148 rm -f $COMMENTFILE
149 touch $COMMENTFILE
151 primary|primary/* )
152 case $CMD in
153 primary/chaos )
154 class="chaos "
156 primary/hs )
157 class="hesiod "
159 esac
160 set - X $ARGS
161 shift
162 if [ $# -eq 2 ]; then
163 (echo ""
164 cat $COMMENTFILE
165 echo "zone \"$1\" ${class}{"
166 echo " type master;"
167 echo " file \"$2\";"
168 echo "};") >>$ZONEFILE
169 rm -f $COMMENTFILE
170 touch $COMMENTFILE
173 secondary|secondary/* )
174 case $CMD in
175 secondary/chaos )
176 class="chaos "
178 secondary/hs )
179 class="hesiod "
181 esac
182 set - X $ARGS
183 shift
184 if [ $# -gt 2 ]; then
185 ZONE=$1
186 shift
187 PRIMARIES=$1
188 while [ $# -gt 2 ]; do
189 shift
190 PRIMARIES="$PRIMARIES $1"
191 done
192 (echo ""
193 cat $COMMENTFILE
194 echo "zone \"$ZONE\" ${class}{"
195 echo " type slave;"
196 echo " file \"$2\";"
197 echo " masters {"
198 for PRIMARY in $PRIMARIES; do
199 echo " $PRIMARY;"
200 done
201 echo " };"
202 echo "};") >>$ZONEFILE
203 rm -f $COMMENTFILE
204 touch $COMMENTFILE
207 stub|stub/* )
208 case $CMD in
209 stub/chaos )
210 class="chaos "
212 stub/hs )
213 class="hesiod "
215 esac
216 set - X $ARGS
217 shift
218 if [ $# -gt 2 ]; then
219 ZONE=$1
220 shift
221 PRIMARIES=$1
222 while [ $# -gt 2 ]; do
223 shift
224 PRIMARIES="$PRIMARIES $1"
225 done
226 (echo ""
227 cat $COMMENTFILE
228 echo "zone \"$ZONE\" ${class}{"
229 echo " type stub;"
230 echo " file \"$2\";"
231 echo " masters {"
232 for PRIMARY in $PRIMARIES; do
233 echo " $PRIMARY;"
234 done
235 echo " };"
236 echo "};") >>$ZONEFILE
237 rm -f $COMMENTFILE
238 touch $COMMENTFILE
241 slave )
242 cat $COMMENTFILE >>$OPTIONFILE
243 echo " forward only;" >>$OPTIONFILE
244 rm -f $COMMENTFILE
245 touch $COMMENTFILE
247 sortlist )
248 (cat $COMMENTFILE
249 echo " topology {"
250 for ARG in $ARGS; do
251 case $ARG in
252 *.0.0.0 )
253 echo " $ARG/8;"
255 *.0.0 )
256 echo " $ARG/16;"
258 *.0 )
259 echo " $ARG/24;"
262 echo " $ARG;"
264 esac
265 done
266 echo " };") >>$OPTIONFILE
267 rm -f $COMMENTFILE
268 touch $COMMENTFILE
270 tcplist | xfrnets )
271 (cat $COMMENTFILE
272 echo " allow-transfer {"
273 for ARG in $ARGS; do
274 case $ARG in
275 *.0.0.0 )
276 echo " $ARG/8;"
278 *.0.0 )
279 echo " $ARG/16;"
281 *.0 )
282 echo " $ARG/24;"
285 echo " $ARG;"
287 esac
288 done
289 echo " };") >>$OPTIONFILE
290 rm -f $COMMENTFILE
291 touch $COMMENTFILE
293 esac
294 done
296 if [ $DUMP -eq 1 ]; then
297 echo ""
298 echo "options {"
299 cat $OPTIONFILE
300 echo "};"
301 cat $ZONEFILE $COMMENTFILE
303 rm -f $OPTIONFILE $ZONEFILE $COMMENTFILE
304 rmdir $WORKDIR
307 exit 0