ntpd revision 1.8
1#!/bin/sh
2#
3# $NetBSD: ntpd,v 1.8 2002/06/17 06:47:59 lukem Exp $
4#
5
6# PROVIDE: ntpd
7# REQUIRE: DAEMON
8# BEFORE:  LOGIN
9
10. /etc/rc.subr
11
12name="ntpd"
13rcvar=$name
14command="/usr/sbin/${name}"
15pidfile="/var/run/${name}.pid"
16start_precmd="ntpd_precmd"
17required_files="/etc/ntp.conf"
18
19ntpd_precmd()
20{
21	if [ -z "$ntpd_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 ${ntpd_chrootdir}
31	# exists and ntpd isn't running at this point (unless forcestart
32	# is used).
33	#
34	# Before enabling ntpd_chrootdir, ensure that:
35	#	- The kernel has "pseudo-device clockctl" compiled in
36	#	- /dev/clockctl is present
37	#
38	if [ ! -c "${ntpd_chrootdir}/dev/clockctl" ]; then
39		rm -f "${ntpd_chrootdir}/dev/clockctl"
40		( cd /dev ; /bin/pax -rw -pe clockctl "${ntpd_chrootdir}/dev" )
41	fi
42	ln -fs "${ntpd_chrootdir}/var/db/ntp.drift" /var/db/ntp.drift
43
44	#	Change run_rc_commands()'s internal copy of $ntpd_flags
45	#
46	rc_flags="-u ntpd:ntpd -i ${ntpd_chrootdir} $rc_flags"
47}
48
49load_rc_config $name
50run_rc_command "$1"
51