openbsd-ports/net/bind9/files/bind9-enable
2001-12-16 23:19:16 +00:00

144 lines
3.1 KiB
Bash

#!/bin/sh
#
# $OpenBSD: bind9-enable,v 1.10 2001/12/16 23:19:16 jakob Exp $
#
# this script replaces OpenBSD named files with the corresponding
# files from BIND v9.
PREFIX=y0y0y0
BINDIR=/usr/sbin
CHROOT=/var/named
config=${CHROOT}/etc/named.conf
if [ `id -u` -ne 0 ]; then
echo "You must be root to run this script."
exit
fi
echo "This script will replace OpenBSD BIND v4 with BIND v9"
echo ""
echo -n "Are you sure you want to do this (y/[n])? "
read answer
echo ""
if [ X$answer != Xy ]; then
echo "exit"
exit
fi
######################################################################
if [ -e /usr/sbin/named.dist ]; then
echo "BIND v4 already preserved, not saving old files."
echo ""
elif [ ! -e /var/named/named-xfer ]; then
echo "Couldn't find BIND v4 files, not saving old files."
echo ""
else
echo "Trying to save BIND v4 files:"
for file in \
/usr/sbin/addr \
/usr/sbin/dig \
/usr/sbin/dnsquery \
/usr/sbin/host \
/usr/sbin/named \
/usr/sbin/named.reload \
/usr/sbin/named.restart \
/usr/sbin/ndc \
/usr/sbin/nslookup \
/usr/share/man/cat1/dig.0 \
/usr/share/man/cat1/dnsquery.0 \
/usr/share/man/cat1/host.0 \
/usr/share/man/cat8/named-xfer.0 \
/usr/share/man/cat8/named.0 \
/usr/share/man/cat8/named.reload.0 \
/usr/share/man/cat8/named.restart.0 \
/usr/share/man/cat8/ndc.0 \
/usr/share/man/cat8/nslookup.0 \
/usr/share/misc/nslookup.help \
/var/named/named-xfer
do
if [ -f $file ]; then
echo " $file"
mv -f $file $file.dist
fi
done
echo ""
fi
######################################################################
echo "Creating soft links for binaries:"
for file in \
dig host nslookup nsupdate
do
echo " $BINDIR/$file -> $PREFIX/bin/$file"
rm -f $BINDIR/$file
ln -s $PREFIX/bin/$file $BINDIR/$file
done
for file in \
named rndc lwresd \
dnssec-keygen dnssec-makekeyset dnssec-signkey dnssec-signzone \
named-checkconf named-checkzone \
rndc-confgen
do
echo " $BINDIR/$file -> $PREFIX/sbin/$file"
rm -f $BINDIR/$file
ln -s $PREFIX/sbin/$file $BINDIR/$file
done
echo ""
######################################################################
echo "Setup directory structure:"
if [ ! -d ${CHROOT} ]; then
echo " ${CHROOT}"
install -d -o root -g wheel -m 755 ${CHROOT}/var
fi
echo " ${CHROOT}/dev"
if [ ! -d ${CHROOT}/dev ]; then
install -d -o root -g wheel -m 755 ${CHROOT}/dev
fi
pax -r -w -pe \
/dev/null \
/dev/random \
/dev/srandom \
/dev/urandom \
/dev/prandom \
/dev/arandom \
${CHROOT}
if [ ! -d ${CHROOT}/var ]; then
echo " ${CHROOT}/var"
install -d -o root -g wheel -m 755 ${CHROOT}/var
fi
if [ ! -d ${CHROOT}/var/run ]; then
echo " ${CHROOT}/var/run"
install -d -o named -g wheel -m 755 ${CHROOT}/var/run
fi
if [ ! -d ${CHROOT}/var/tmp ]; then
echo " ${CHROOT}/var/tmp"
install -d -o named -g wheel -m 755 ${CHROOT}/var/tmp
fi
echo ""
######################################################################
echo "Symlink $config:"
if [ ! -L $config -a ! -e $config ]; then
echo " $config->../named.conf"
ln -s ../named.conf $config
else
echo " not needed"
fi
echo ""