ntpd revision 153607
1#!/bin/sh
2#
3# $FreeBSD: head/etc/rc.d/ntpd 153607 2005-12-21 09:48:41Z dougb $
4#
5
6# PROVIDE: ntpd
7# REQUIRE: DAEMON ntpdate cleanvar devfs
8# BEFORE:  LOGIN
9# KEYWORD: nojail
10
11. /etc/rc.subr
12
13name=ntpd
14rcvar=`set_rcvar`
15command="/usr/sbin/${name}"
16pidfile="/var/run/${name}.pid"
17start_precmd="ntpd_precmd"
18required_files="/etc/ntp.conf"
19
20ntpd_precmd()
21{
22	if checkyesno ntpd_sync_on_start; then
23		rc_flags="-g ${ntpd_flags}"
24	fi
25
26	if [ -z "$ntpd_chrootdir" ]; then
27		return 0;
28	fi
29
30	# If running in a chroot cage, ensure that the appropriate files
31	# exist inside the cage, as well as helper symlinks into the cage
32	# from outside.
33	#
34	# As this is called after the is_running and required_dir checks
35	# are made in run_rc_command(), we can safely assume ${ntpd_chrootdir}
36	# exists and ntpd isn't running at this point (unless forcestart
37	# is used).
38	#
39	if [ ! -c "${ntpd_chrootdir}/dev/clockctl" ]; then
40		rm -f "${ntpd_chrootdir}/dev/clockctl"
41		( cd /dev ; /bin/pax -rw -pe clockctl "${ntpd_chrootdir}/dev" )
42	fi
43	ln -fs "${ntpd_chrootdir}/var/db/ntp.drift" /var/db/ntp.drift
44
45	#	Change run_rc_commands()'s internal copy of $ntpd_flags
46	#
47	rc_flags="-u ntpd:ntpd -i ${ntpd_chrootdir} $rc_flags"
48}
49
50load_rc_config $name
51run_rc_command "$1"
52