ntpd revision 1.8
11.1Ssimonb#!/bin/sh
21.1Ssimonb#
31.8Slukem# $NetBSD: ntpd,v 1.8 2002/06/17 06:47:59 lukem Exp $
41.1Ssimonb#
51.1Ssimonb
61.1Ssimonb# PROVIDE: ntpd
71.1Ssimonb# REQUIRE: DAEMON
81.6Sthorpej# BEFORE:  LOGIN
91.1Ssimonb
101.1Ssimonb. /etc/rc.subr
111.1Ssimonb
121.1Ssimonbname="ntpd"
131.3Slukemrcvar=$name
141.1Ssimonbcommand="/usr/sbin/${name}"
151.1Ssimonbpidfile="/var/run/${name}.pid"
161.4Slukemstart_precmd="ntpd_precmd"
171.1Ssimonbrequired_files="/etc/ntp.conf"
181.4Slukem
191.4Slukemntpd_precmd()
201.4Slukem{
211.4Slukem	if [ -z "$ntpd_chrootdir" ]; then
221.4Slukem		return 0;
231.4Slukem	fi
241.4Slukem
251.4Slukem	# If running in a chroot cage, ensure that the appropriate files
261.4Slukem	# exist inside the cage, as well as helper symlinks into the cage 
271.4Slukem	# from outside.
281.4Slukem	#
291.4Slukem	# As this is called after the is_running and required_dir checks
301.4Slukem	# are made in run_rc_command(), we can safely assume ${ntpd_chrootdir}
311.4Slukem	# exists and ntpd isn't running at this point (unless forcestart
321.4Slukem	# is used).
331.7Slukem	#
341.8Slukem	# Before enabling ntpd_chrootdir, ensure that:
351.8Slukem	#	- The kernel has "pseudo-device clockctl" compiled in
361.8Slukem	#	- /dev/clockctl is present
371.4Slukem	#
381.4Slukem	if [ ! -c "${ntpd_chrootdir}/dev/clockctl" ]; then
391.4Slukem		rm -f "${ntpd_chrootdir}/dev/clockctl"
401.4Slukem		( cd /dev ; /bin/pax -rw -pe clockctl "${ntpd_chrootdir}/dev" )
411.4Slukem	fi
421.4Slukem	ln -fs "${ntpd_chrootdir}/var/db/ntp.drift" /var/db/ntp.drift
431.4Slukem
441.4Slukem	#	Change run_rc_commands()'s internal copy of $ntpd_flags
451.4Slukem	#
461.5Slukem	rc_flags="-u ntpd:ntpd -i ${ntpd_chrootdir} $rc_flags"
471.4Slukem}
481.1Ssimonb
491.2Slukemload_rc_config $name
501.1Ssimonbrun_rc_command "$1"
51