3 # $NetBSD: named,v 1.10 2002/03/22 04:33:59 thorpej Exp $
8 # REQUIRE: SERVERS cleanvar
16 command="/usr/sbin/${name}"
17 start_precmd="named_precmd"
18 start_postcmd="make_symlinks"
19 stop_postcmd="named_poststop"
20 required_dirs="$named_chrootdir" # if it is set, it must exist
21 extra_commands="reload"
23 # If running in a chroot cage, ensure that the appropriate files
24 # exist inside the cage, as well as helper symlinks into the cage
27 # As this is called after the is_running and required_dir checks
28 # are made in run_rc_command(), we can safely assume ${named_chrootdir}
29 # exists and named isn't running at this point (unless forcestart
34 # Create (or update) the chroot directory structure
36 if [ -f /etc/mtree/BIND.chroot.dist ]; then
37 mtree -deU -f /etc/mtree/BIND.chroot.dist \
40 warn "/etc/mtree/BIND.chroot.dist missing,"
41 warn "chroot directory structure not updated"
44 # Create /etc/namedb symlink
46 if [ ! -L /etc/namedb ]; then
47 if [ -d /etc/namedb ]; then
48 warn "named chroot: /etc/namedb is a directory!"
49 elif [ -e /etc/namedb ]; then
50 warn "named chroot: /etc/namedb exists!"
52 ln -s ${named_chrootdir}/etc/namedb /etc/namedb
55 # Make sure it points to the right place.
56 ln -shf ${named_chrootdir}/etc/namedb /etc/namedb
60 # Mount a devfs in the chroot directory if needed
62 umount ${named_chrootdir}/dev 2>/dev/null
63 devfs_domount ${named_chrootdir}/dev devfsrules_hide_all
64 devfs -m ${named_chrootdir}/dev rule apply path null unhide
65 devfs -m ${named_chrootdir}/dev rule apply path random unhide
67 # Copy local timezone information if it is not up to date.
69 if [ -f /etc/localtime ]; then
70 cmp -s /etc/localtime "${named_chrootdir}/etc/localtime" || \
71 cp -p /etc/localtime "${named_chrootdir}/etc/localtime"
75 # Make symlinks to the correct pid file
79 checkyesno named_symlink_enable &&
80 ln -fs "${named_chrootdir}${pidfile}" ${pidfile}
85 if [ -n "${named_chrootdir}" -a -c ${named_chrootdir}/dev/null ]; then
86 umount ${named_chrootdir}/dev 2>/dev/null || true
94 # Is the user using a sandbox?
96 if [ -n "$named_chrootdir" ]; then
97 rc_flags="$rc_flags -t $named_chrootdir"
98 confgen_chroot="-t${named_chrootdir} -u bind"
99 checkyesno named_chroot_autoupdate && chroot_autoupdate
101 named_symlink_enable=NO
104 # Create an rndc.key file for the user if none exists
106 if [ ! -f "${named_chrootdir}/etc/namedb/rndc.key" -a \
107 ! -f "${named_chrootdir}/etc/namedb/rndc.conf" ]; then
108 rndc-confgen -a -b256 ${confgen_chroot}
113 # The following variable requires that rc.conf be loaded first
115 required_dirs="$named_chrootdir" # if it is set, it must exist
116 pidfile="${named_pidfile:-/var/run/${name}/pid}"