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 umount ${named_chrootdir}/dev 2>/dev/null
62 devfs_domount ${named_chrootdir}/dev devfsrules_hide_all
63 devfs -m ${named_chrootdir}/dev rule apply path null unhide
64 devfs -m ${named_chrootdir}/dev rule apply path random unhide
66 # Copy local timezone information if it is not up to date.
68 if [ -f /etc/localtime ]; then
69 cmp -s /etc/localtime "${named_chrootdir}/etc/localtime" || \
70 cp -p /etc/localtime "${named_chrootdir}/etc/localtime"
74 # Make symlinks to the correct pid file
78 checkyesno named_symlink_enable &&
79 ln -fs "${named_chrootdir}${pidfile}" ${pidfile}
84 if [ -n "${named_chrootdir}" -a -c ${named_chrootdir}/dev/null ]; then
85 umount ${named_chrootdir}/dev 2>/dev/null || true
93 # Is the user using a sandbox?
95 if [ -n "$named_chrootdir" ]; then
96 rc_flags="$rc_flags -t $named_chrootdir"
97 confgen_chroot="-t${named_chrootdir} -u bind"
98 checkyesno named_chroot_autoupdate && chroot_autoupdate
100 named_symlink_enable=NO
103 # Create an rndc.key file for the user if none exists
105 if [ ! -f "${named_chrootdir}/etc/namedb/rndc.key" -a \
106 ! -f "${named_chrootdir}/etc/namedb/rndc.conf" ]; then
107 rndc-confgen -a -b256 ${confgen_chroot}
112 # The following variable requires that rc.conf be loaded first
114 required_dirs="$named_chrootdir" # if it is set, it must exist
115 pidfile="${named_pidfile:-/var/run/${name}/pid}"