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