3 # $NetBSD: named,v 1.10 2002/03/22 04:33:59 thorpej Exp $
8 # REQUIRE: SERVERS cleanvar
16 start_precmd="named_precmd"
17 start_postcmd="make_symlinks"
18 stop_postcmd="named_poststop"
19 required_dirs="$named_chrootdir" # if it is set, it must exist
20 extra_commands="reload"
22 # If running in a chroot cage, ensure that the appropriate files
23 # exist inside the cage, as well as helper symlinks into the cage
26 # As this is called after the is_running and required_dir checks
27 # are made in run_rc_command(), we can safely assume ${named_chrootdir}
28 # exists and named isn't running at this point (unless forcestart
33 # Create (or update) the chroot directory structure
35 if [ -f /etc/mtree/BIND.chroot.dist ]; then
36 mtree -deU -f /etc/mtree/BIND.chroot.dist \
39 warn "/etc/mtree/BIND.chroot.dist missing,"
40 warn "chroot directory structure not updated"
43 # Create /etc/namedb symlink
45 if [ ! -L /etc/namedb ]; then
46 if [ -d /etc/namedb ]; then
47 warn "named chroot: /etc/namedb is a directory!"
48 elif [ -e /etc/namedb ]; then
49 warn "named chroot: /etc/namedb exists!"
51 ln -s ${named_chrootdir}/etc/namedb /etc/namedb
54 # Make sure it points to the right place.
55 ln -shf ${named_chrootdir}/etc/namedb /etc/namedb
59 # Mount a devfs in the chroot directory if needed
61 if [ ! -c ${named_chrootdir}/dev/random -o \
62 ! -c ${named_chrootdir}/dev/null ]; then
63 umount ${named_chrootdir}/dev 2>/dev/null
64 mount_devfs devfs ${named_chrootdir}/dev
66 devfs -m ${named_chrootdir}/dev rule apply hide
67 devfs -m ${named_chrootdir}/dev rule apply path null unhide
68 devfs -m ${named_chrootdir}/dev rule apply path random unhide
70 # Copy local timezone information if it is not up to date.
72 if [ -f /etc/localtime ]; then
73 cmp -s /etc/localtime "${named_chrootdir}/etc/localtime" || \
74 cp -p /etc/localtime "${named_chrootdir}/etc/localtime"
78 # Make symlinks to the correct pid file
82 checkyesno named_symlink_enable &&
83 ln -fs "${named_chrootdir}${pidfile}" ${pidfile}
88 if [ -n "${named_chrootdir}" -a -c ${named_chrootdir}/dev/null ]; then
89 umount ${named_chrootdir}/dev 2>/dev/null || true
97 # Is the user using a sandbox?
99 if [ -n "$named_chrootdir" ]; then
100 rc_flags="$rc_flags -t $named_chrootdir"
101 confgen_chroot="-t${named_chrootdir} -u bind"
102 checkyesno named_chroot_autoupdate && chroot_autoupdate
104 named_symlink_enable=NO
107 # Create an rndc.key file for the user if none exists
109 if [ ! -f "${named_chrootdir}/etc/namedb/rndc.key" -a \
110 ! -f "${named_chrootdir}/etc/namedb/rndc.conf" ]; then
111 rndc-confgen -a -b256 ${confgen_chroot}
116 # The following variable requires that rc.conf be loaded first
118 required_dirs="$named_chrootdir" # if it is set, it must exist
119 pidfile="${named_pidfile:-/var/run/${name}/pid}"