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