ntpd revision 187879
138032Speter#!/bin/sh
238032Speter#
3261363Sgshapiro# $FreeBSD: head/etc/rc.d/ntpd 187879 2009-01-29 06:43:29Z keramida $
464562Sgshapiro#
538032Speter
638032Speter# PROVIDE: ntpd
738032Speter# REQUIRE: DAEMON ntpdate cleanvar devfs
838032Speter# BEFORE:  LOGIN
938032Speter# KEYWORD: nojail shutdown
1038032Speter
1138032Speter. /etc/rc.subr
1238032Speter
1338032Spetername=ntpd
1438032Speterrcvar=`set_rcvar`
1538032Spetercommand="/usr/sbin/${name}"
1638032Speterpidfile="/var/run/${name}.pid"
1738032Speterstart_precmd="ntpd_precmd"
1838032Speter
1938032Speterload_rc_config $name
2038032Speter
2138032Speterntpd_precmd()
2238032Speter{
23261363Sgshapiro	rc_flags="-c ${ntpd_config} ${ntpd_flags}"
2438032Speter
2564562Sgshapiro	if checkyesno ntpd_sync_on_start; then
2664562Sgshapiro		rc_flags="-g $rc_flags"
2764562Sgshapiro	fi
2864562Sgshapiro
29	if [ -z "$ntpd_chrootdir" ]; then
30		return 0;
31	fi
32
33	# If running in a chroot cage, ensure that the appropriate files
34	# exist inside the cage, as well as helper symlinks into the cage
35	# from outside.
36	#
37	# As this is called after the is_running and required_dir checks
38	# are made in run_rc_command(), we can safely assume ${ntpd_chrootdir}
39	# exists and ntpd isn't running at this point (unless forcestart
40	# is used).
41	#
42	if [ ! -c "${ntpd_chrootdir}/dev/clockctl" ]; then
43		rm -f "${ntpd_chrootdir}/dev/clockctl"
44		( cd /dev ; /bin/pax -rw -pe clockctl "${ntpd_chrootdir}/dev" )
45	fi
46	ln -fs "${ntpd_chrootdir}/var/db/ntp.drift" /var/db/ntp.drift
47
48	#	Change run_rc_commands()'s internal copy of $ntpd_flags
49	#
50	rc_flags="-u ntpd:ntpd -i ${ntpd_chrootdir} $rc_flags"
51}
52
53run_rc_command "$1"
54