xref: /netbsd/etc/rc.d/ntpd (revision bf9ec67e)
1#!/bin/sh
2#
3# $NetBSD: ntpd,v 1.6 2002/03/22 04:33:59 thorpej 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	if [ ! -c "${ntpd_chrootdir}/dev/clockctl" ]; then
35		rm -f "${ntpd_chrootdir}/dev/clockctl"
36		( cd /dev ; /bin/pax -rw -pe clockctl "${ntpd_chrootdir}/dev" )
37	fi
38	ln -fs "${ntpd_chrootdir}/var/db/ntp.drift" /var/db/ntp.drift
39
40	#	Change run_rc_commands()'s internal copy of $ntpd_flags
41	#
42	rc_flags="-u ntpd:ntpd -i ${ntpd_chrootdir} $rc_flags"
43}
44
45load_rc_config $name
46run_rc_command "$1"
47