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