Home | History | Annotate | Line # | Download | only in rc.d
named revision 1.14
      1 #!/bin/sh
      2 #
      3 # $NetBSD: named,v 1.14 2004/08/13 18:08:03 mycroft Exp $
      4 #
      5 
      6 # PROVIDE: named
      7 # REQUIRE: SERVERS
      8 # BEFORE:  DAEMON
      9 # KEYWORD: chrootdir
     10 
     11 $_rc_subr_loaded . /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 	for i in null random
     53 	do
     54 		if [ ! -c "${named_chrootdir}/dev/$i" ]; then
     55 			rm -f "${named_chrootdir}/dev/$i"
     56 			(cd /dev && 
     57 			    /bin/pax -rw -pe "$i" "${named_chrootdir}/dev")
     58 		fi
     59 	done
     60 
     61 	if [ -f /etc/localtime ]; then
     62 		cmp -s /etc/localtime "${named_chrootdir}/etc/localtime" || \
     63 		    cp -p /etc/localtime "${named_chrootdir}/etc/localtime"
     64 	fi
     65 	ln -fs "${named_chrootdir}/var/run/named.pid" /var/run/named.pid
     66 
     67 	#	Change run_rc_commands()'s internal copy of $named_flags
     68 	#
     69 	rc_flags="-u named -t ${named_chrootdir} $rc_flags"
     70 }
     71 
     72 load_rc_config $name
     73 run_rc_command "$1"
     74