Home | History | Annotate | Line # | Download | only in rc.d
named revision 1.8
      1 #!/bin/sh
      2 #
      3 # $NetBSD: named,v 1.8 2001/10/11 07:10:08 lukem Exp $
      4 #
      5 
      6 # PROVIDE: named
      7 # REQUIRE: SERVERS
      8 
      9 . /etc/rc.subr
     10 
     11 name="named"
     12 rcvar=$name
     13 command="/usr/sbin/${name}"
     14 pidfile="/var/run/${name}.pid"
     15 start_precmd="named_precmd"
     16 extra_commands="reload"
     17 required_dirs="$named_chrootdir"	# if it is set, it must exist
     18 
     19 named_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 	ln -fs "${named_chrootdir}/var/run/named.pid" /var/run/named.pid
     50 	ln -fs "${named_chrootdir}/var/run/ndc" /var/run/ndc
     51 
     52 	#	Change run_rc_commands()'s internal copy of $named_flags
     53 	#
     54 	_flags="-u named -g named -t ${named_chrootdir} $_flags"
     55 }
     56 
     57 load_rc_config $name
     58 run_rc_command "$1"
     59