1998-10-05 22:01:57 +04:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
1998-12-15 04:00:53 +03:00
|
|
|
# $NetBSD: named-bootconf.sh,v 1.5 1998/12/15 01:00:53 tron Exp $
|
1998-10-05 22:01:57 +04:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
# 3. All advertising materials mentioning features or use of this software
|
|
|
|
# must display the following acknowledgement:
|
|
|
|
# This product includes software developed by the NetBSD
|
|
|
|
# Foundation, Inc. and its contributors.
|
|
|
|
# 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
# contributors may be used to endorse or promote products derived
|
|
|
|
# from this software without specific prior written permission.
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
1998-12-14 18:39:12 +03:00
|
|
|
if [ ${OPTIONFILE-X} = X ]; then
|
|
|
|
OPTIONFILE=/tmp/.options.`date +%s`.$$
|
|
|
|
ZONEFILE=/tmp/.zones.`date +%s`.$$
|
1998-12-15 04:00:53 +03:00
|
|
|
COMMENTFILE=/tmp/.comments.`date +%s`.$$
|
|
|
|
export OPTIONFILE ZONEFILE COMMENTFILE
|
|
|
|
touch $OPTIONFILE $ZONEFILE $COMMENTFILE
|
1998-12-14 18:39:12 +03:00
|
|
|
DUMP=1
|
1998-10-05 22:01:57 +04:00
|
|
|
else
|
1998-12-14 18:39:12 +03:00
|
|
|
DUMP=0
|
1998-10-05 22:01:57 +04:00
|
|
|
fi
|
|
|
|
|
1998-12-14 18:39:12 +03:00
|
|
|
while read CMD ARGS; do
|
|
|
|
case $CMD in
|
|
|
|
\; )
|
1998-12-15 04:00:53 +03:00
|
|
|
echo \# $ARGS >>$COMMENTFILE
|
1998-12-14 18:39:12 +03:00
|
|
|
;;
|
|
|
|
cache )
|
|
|
|
set - X $ARGS
|
|
|
|
shift
|
|
|
|
if [ $# -eq 2 ]; then
|
|
|
|
(echo ""
|
1998-12-15 04:00:53 +03:00
|
|
|
cat $COMMENTFILE
|
1998-12-14 18:39:12 +03:00
|
|
|
echo "zone \"$1\" {"
|
|
|
|
echo " type hint;"
|
|
|
|
echo " file \"$2\";"
|
|
|
|
echo "};") >>$ZONEFILE
|
1998-12-15 04:00:53 +03:00
|
|
|
rm -f $COMMENTFILE
|
|
|
|
touch $COMMENTFILE
|
1998-12-14 18:39:12 +03:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
directory )
|
|
|
|
set - X $ARGS
|
|
|
|
shift
|
1998-12-15 04:00:53 +03:00
|
|
|
if [ $# -eq 1 ]; then
|
|
|
|
(cat $COMMENTFILE
|
|
|
|
echo " directory \"$1\";") >>$OPTIONFILE
|
|
|
|
rm -f $COMMENTFILE
|
|
|
|
touch $COMMENTFILE
|
|
|
|
|
1998-12-14 18:39:12 +03:00
|
|
|
DIRECTORY=$1
|
|
|
|
export DIRECTORY
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
forwarders )
|
1998-12-15 04:00:53 +03:00
|
|
|
(cat $COMMENTFILE
|
|
|
|
echo " forwarders {"
|
1998-12-14 18:39:12 +03:00
|
|
|
for ARG in $ARGS; do
|
|
|
|
echo " $ARG;"
|
|
|
|
done
|
|
|
|
echo " };") >>$OPTIONFILE
|
1998-12-15 04:00:53 +03:00
|
|
|
rm -f $COMMENTFILE
|
|
|
|
touch $COMMENTFILE
|
1998-12-14 18:39:12 +03:00
|
|
|
;;
|
|
|
|
include )
|
|
|
|
if [ "$ARGS" != "" ]; then
|
|
|
|
(cd ${DIRECTORY-.}; cat $ARGS) | $0
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
limit )
|
|
|
|
set - X $ARGS
|
|
|
|
shift
|
|
|
|
if [ $# -eq 2 ]; then
|
1998-12-15 04:00:53 +03:00
|
|
|
cat $COMMENTFILE >>$OPTIONFILE
|
1998-12-14 18:39:12 +03:00
|
|
|
case $1 in
|
|
|
|
datasize | files | transfers-in | transfers-per-ns )
|
|
|
|
echo " $1 $2;" >>$OPTIONFILE
|
|
|
|
;;
|
|
|
|
esac
|
1998-12-15 04:00:53 +03:00
|
|
|
rm -f $COMMENTFILE
|
|
|
|
touch $COMMENTFILE
|
1998-12-14 18:39:12 +03:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
options )
|
1998-12-15 04:00:53 +03:00
|
|
|
cat $COMMENTFILE >>$OPTIONFILE
|
1998-12-14 18:39:12 +03:00
|
|
|
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
|
1998-12-15 04:00:53 +03:00
|
|
|
rm -f $COMMENTFILE
|
|
|
|
touch $COMMENTFILE
|
1998-12-14 18:39:12 +03:00
|
|
|
;;
|
|
|
|
primary|primary/* )
|
|
|
|
case $CMD in
|
|
|
|
primary/CHAOS )
|
|
|
|
class="chaos "
|
|
|
|
;;
|
|
|
|
primary/HS )
|
|
|
|
class="hesiod "
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
set - X $ARGS
|
|
|
|
shift
|
|
|
|
if [ $# -eq 2 ]; then
|
|
|
|
(echo ""
|
1998-12-15 04:00:53 +03:00
|
|
|
cat $COMMENTFILE
|
1998-12-14 18:39:12 +03:00
|
|
|
echo "zone \"$1\" ${class}{"
|
|
|
|
echo " type master;"
|
|
|
|
echo " file \"$2\";"
|
|
|
|
echo "};") >>$ZONEFILE
|
1998-12-15 04:00:53 +03:00
|
|
|
rm -f $COMMENTFILE
|
|
|
|
touch $COMMENTFILE
|
1998-12-14 18:39:12 +03:00
|
|
|
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 ""
|
1998-12-15 04:00:53 +03:00
|
|
|
cat $COMMENTFILE
|
1998-12-14 18:39:12 +03:00
|
|
|
echo "zone \"$ZONE\" ${class}{"
|
|
|
|
echo " type slave;"
|
|
|
|
echo " file \"$2\";"
|
|
|
|
echo " masters {"
|
|
|
|
for PRIMARY in $PRIMARIES; do
|
|
|
|
echo " $PRIMARY;"
|
|
|
|
done
|
|
|
|
echo " };"
|
|
|
|
echo "};") >>$ZONEFILE
|
1998-12-15 04:00:53 +03:00
|
|
|
rm -f $COMMENTFILE
|
|
|
|
touch $COMMENTFILE
|
1998-12-14 18:39:12 +03:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
slave )
|
1998-12-15 04:00:53 +03:00
|
|
|
cat $COMMENTFILE >>$OPTIONFILE
|
1998-12-14 18:39:12 +03:00
|
|
|
echo " forward only;" >>$OPTIONFILE
|
1998-12-15 04:00:53 +03:00
|
|
|
rm -f $COMMENTFILE
|
|
|
|
touch $COMMENTFILE
|
1998-12-14 18:39:12 +03:00
|
|
|
;;
|
|
|
|
sortlist )
|
1998-12-15 04:00:53 +03:00
|
|
|
(cat $COMMENTFILE
|
|
|
|
echo " topology {"
|
1998-12-14 18:39:12 +03:00
|
|
|
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
|
1998-12-15 04:00:53 +03:00
|
|
|
rm -f $COMMENTFILE
|
|
|
|
touch $COMMENTFILE
|
1998-12-14 18:39:12 +03:00
|
|
|
;;
|
|
|
|
tcplist | xfrnets )
|
1998-12-15 04:00:53 +03:00
|
|
|
(cat $COMMENTFILE
|
|
|
|
echo " allow-transfer {"
|
1998-12-14 18:39:12 +03:00
|
|
|
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
|
1998-12-15 04:00:53 +03:00
|
|
|
rm -f $COMMENTFILE
|
|
|
|
touch $COMMENTFILE
|
1998-12-14 18:39:12 +03:00
|
|
|
;;
|
|
|
|
esac
|
1998-10-05 22:01:57 +04:00
|
|
|
done
|
|
|
|
|
1998-12-14 18:39:12 +03:00
|
|
|
if [ $DUMP -eq 1 ]; then
|
1998-12-15 04:00:53 +03:00
|
|
|
echo ""
|
|
|
|
echo "options {"
|
|
|
|
cat $OPTIONFILE
|
|
|
|
echo "};"
|
|
|
|
cat $ZONEFILE $COMMENTFILE
|
1998-10-05 22:01:57 +04:00
|
|
|
|
1998-12-15 04:00:53 +03:00
|
|
|
rm -f $OPTIONFILE $ZONEFILE $COMMENTFILE
|
1998-10-05 22:01:57 +04:00
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|