named revision 1.7
1#!/bin/sh
2#
3# $NetBSD: named,v 1.7 2001/03/12 16:08:38 lukem Exp $
4#
5
6# PROVIDE: named
7# REQUIRE: SERVERS
8
9. /etc/rc.subr
10
11name="named"
12rcvar=$name
13command="/usr/sbin/${name}"
14pidfile="/var/run/${name}.pid"
15start_precmd="named_precmd"
16extra_commands="reload"
17required_dirs="$named_chrootdir"	# if it is set, it must exist
18
19named_precmd()
20{
21	if [ -z "$named_chrootdir" ]; then
22		return 0;
23	fi
24
25	# If running in a chroot cage, ensure that the appropriate files
26	# exist inside the cage, as well as helper symlinks into the cage 
27	# from outside.
28	#
29	# As this is called after the is_running and required_dir checks
30	# are made in run_rc_command(), we can safely assume ${named_chrootdir}
31	# exists and named isn't running at this point (unless forcestart
32	# is used).
33	#
34
35	if [ ! -x "${named_chrootdir}/usr/libexec/named-xfer" -o \
36	    "${named_chrootdir}/usr/libexec/named-xfer" -ot \
37	    /usr/libexec/named-xfer ]; then
38		rm -f "${named_chrootdir}/usr/libexec/named-xfer"
39		cp -p /usr/libexec/named-xfer "${named_chrootdir}/usr/libexec"
40	fi
41	if [ ! -c "${named_chrootdir}/dev/null" ]; then
42		rm -f "${named_chrootdir}/dev/null"
43		( cd /dev ; /bin/pax -rw -pe null "${named_chrootdir}/dev" )
44	fi
45	if [ -f /etc/localtime ]; then
46		cmp -s /etc/localtime "${named_chrootdir}/etc/localtime" || \
47		    cp -p /etc/localtime "${named_chrootdir}/etc/localtime"
48	fi
49	if [ ! -h /var/run/named.pid ]; then
50		rm -f /var/run/named.pid
51		ln -s '../../'"${named_chrootdir}/var/run/named.pid" \
52		    /var/run/named.pid
53	fi
54	if [ ! -h /var/run/ndc ]; then
55		rm -f /var/run/ndc
56		ln -s '../../'"${named_chrootdir}/var/run/ndc" /var/run/ndc
57	fi
58
59	#	Change run_rc_commands()'s internal copy of $named_flags
60	#
61	_flags="-u named -g named -t ${named_chrootdir} $_flags"
62}
63
64load_rc_config $name
65run_rc_command "$1"
66