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