1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
|
#!/bin/sh
# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
#
# SPDX-License-Identifier: MPL-2.0
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, you can obtain one at https://mozilla.org/MPL/2.0/.
#
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
# $NetBSD: named-bootconf.sh,v 1.5 1998/12/15 01:00:53 tron Exp $
#
# Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Matthias Scheler.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
if [ ${OPTIONFILE-X} = X ]; then
WORKDIR=/tmp/`date +%s`.$$
( umask 077 ; mkdir $WORKDIR ) || {
echo "unable to create work directory '$WORKDIR'" >&2
exit 1
}
OPTIONFILE=$WORKDIR/options
ZONEFILE=$WORKDIR/zones
COMMENTFILE=$WORKDIR/comments
export OPTIONFILE ZONEFILE COMMENTFILE
touch $OPTIONFILE $ZONEFILE $COMMENTFILE
DUMP=1
else
DUMP=0
fi
while read CMD ARGS; do
class=
CMD=`echo "${CMD}" | tr '[A-Z]' '[a-z]'`
case $CMD in
\; )
echo \# $ARGS >>$COMMENTFILE
;;
cache )
set - X $ARGS
shift
if [ $# -eq 2 ]; then
(echo ""
cat $COMMENTFILE
echo "zone \"$1\" {"
echo " type hint;"
echo " file \"$2\";"
echo "};") >>$ZONEFILE
rm -f $COMMENTFILE
touch $COMMENTFILE
fi
;;
directory )
set - X $ARGS
shift
if [ $# -eq 1 ]; then
(cat $COMMENTFILE
echo " directory \"$1\";") >>$OPTIONFILE
rm -f $COMMENTFILE
touch $COMMENTFILE
DIRECTORY=$1
export DIRECTORY
fi
;;
forwarders )
(cat $COMMENTFILE
echo " forwarders {"
for ARG in $ARGS; do
echo " $ARG;"
done
echo " };") >>$OPTIONFILE
rm -f $COMMENTFILE
touch $COMMENTFILE
;;
include )
if [ "$ARGS" != "" ]; then
(cd ${DIRECTORY-.}; cat $ARGS) | $0
fi
;;
limit )
ARGS=`echo "${ARGS}" | tr '[A-Z]' '[a-z]'`
set - X $ARGS
shift
if [ $# -eq 2 ]; then
cat $COMMENTFILE >>$OPTIONFILE
case $1 in
datasize | files | transfers-in | transfers-per-ns )
echo " $1 $2;" >>$OPTIONFILE
;;
esac
rm -f $COMMENTFILE
touch $COMMENTFILE
fi
;;
options )
ARGS=`echo "${ARGS}" | tr '[A-Z]' '[a-z]'`
cat $COMMENTFILE >>$OPTIONFILE
for ARG in $ARGS; do
case $ARG in
fake-iquery )
echo " fake-iquery yes;" >>$OPTIONFILE
;;
forward-only )
echo " forward only;" >>$OPTIONFILE
;;
no-fetch-glue )
echo " fetch-glue no;" >>$OPTIONFILE
;;
no-recursion )
echo " recursion no;" >>$OPTIONFILE
;;
esac
done
rm -f $COMMENTFILE
touch $COMMENTFILE
;;
primary|primary/* )
case $CMD in
primary/chaos )
class="chaos "
;;
primary/hs )
class="hesiod "
;;
esac
set - X $ARGS
shift
if [ $# -eq 2 ]; then
(echo ""
cat $COMMENTFILE
echo "zone \"$1\" ${class}{"
echo " type master;"
echo " file \"$2\";"
echo "};") >>$ZONEFILE
rm -f $COMMENTFILE
touch $COMMENTFILE
fi
;;
secondary|secondary/* )
case $CMD in
secondary/chaos )
class="chaos "
;;
secondary/hs )
class="hesiod "
;;
esac
set - X $ARGS
shift
if [ $# -gt 2 ]; then
ZONE=$1
shift
PRIMARIES=$1
while [ $# -gt 2 ]; do
shift
PRIMARIES="$PRIMARIES $1"
done
(echo ""
cat $COMMENTFILE
echo "zone \"$ZONE\" ${class}{"
echo " type slave;"
echo " file \"$2\";"
echo " masters {"
for PRIMARY in $PRIMARIES; do
echo " $PRIMARY;"
done
echo " };"
echo "};") >>$ZONEFILE
rm -f $COMMENTFILE
touch $COMMENTFILE
fi
;;
stub|stub/* )
case $CMD in
stub/chaos )
class="chaos "
;;
stub/hs )
class="hesiod "
;;
esac
set - X $ARGS
shift
if [ $# -gt 2 ]; then
ZONE=$1
shift
PRIMARIES=$1
while [ $# -gt 2 ]; do
shift
PRIMARIES="$PRIMARIES $1"
done
(echo ""
cat $COMMENTFILE
echo "zone \"$ZONE\" ${class}{"
echo " type stub;"
echo " file \"$2\";"
echo " masters {"
for PRIMARY in $PRIMARIES; do
echo " $PRIMARY;"
done
echo " };"
echo "};") >>$ZONEFILE
rm -f $COMMENTFILE
touch $COMMENTFILE
fi
;;
slave )
cat $COMMENTFILE >>$OPTIONFILE
echo " forward only;" >>$OPTIONFILE
rm -f $COMMENTFILE
touch $COMMENTFILE
;;
sortlist )
(cat $COMMENTFILE
echo " topology {"
for ARG in $ARGS; do
case $ARG in
*.0.0.0 )
echo " $ARG/8;"
;;
*.0.0 )
echo " $ARG/16;"
;;
*.0 )
echo " $ARG/24;"
;;
* )
echo " $ARG;"
;;
esac
done
echo " };") >>$OPTIONFILE
rm -f $COMMENTFILE
touch $COMMENTFILE
;;
tcplist | xfrnets )
(cat $COMMENTFILE
echo " allow-transfer {"
for ARG in $ARGS; do
case $ARG in
*.0.0.0 )
echo " $ARG/8;"
;;
*.0.0 )
echo " $ARG/16;"
;;
*.0 )
echo " $ARG/24;"
;;
* )
echo " $ARG;"
;;
esac
done
echo " };") >>$OPTIONFILE
rm -f $COMMENTFILE
touch $COMMENTFILE
;;
esac
done
if [ $DUMP -eq 1 ]; then
echo ""
echo "options {"
cat $OPTIONFILE
echo "};"
cat $ZONEFILE $COMMENTFILE
rm -f $OPTIONFILE $ZONEFILE $COMMENTFILE
rmdir $WORKDIR
fi
exit 0
|