Fix mdoc(7)/man(7) mix up.
[netbsd-mini2440.git] / etc / rc.d / ntpd
blobf67e72e1d6a3aa88ac291ad4a2d612dd117674e2
1 #!/bin/sh
3 # $NetBSD: ntpd,v 1.12 2004/03/31 18:01:07 fredb Exp $
6 # PROVIDE: ntpd
7 # REQUIRE: DAEMON
8 # BEFORE: LOGIN
9 # KEYWORD: chrootdir
11 $_rc_subr_loaded . /etc/rc.subr
13 name="ntpd"
14 rcvar=$name
15 command="/usr/sbin/${name}"
16 pidfile="/var/run/${name}.pid"
17 start_precmd="ntpd_precmd"
18 required_files="/etc/ntp.conf"
20 ntpd_precmd()
22 if [ -z "$ntpd_chrootdir" ]; then
23 return 0;
26 # If running in a chroot cage, ensure that the appropriate files
27 # exist inside the cage, as well as helper symlinks into the cage
28 # from outside.
30 # As this is called after the is_running and required_dir checks
31 # are made in run_rc_command(), we can safely assume ${ntpd_chrootdir}
32 # exists and ntpd isn't running at this point (unless forcestart
33 # is used).
35 # Before enabling ntpd_chrootdir, ensure that:
36 # - The kernel has "pseudo-device clockctl" compiled in
37 # - /dev/clockctl is present
39 if (: </dev/clockctl) 2>/dev/null; then
40 : exists and works
41 else
42 logger -s -p daemon.warning -t ntpd \
43 "WARNING: not chrooting -- no working /dev/clockctl device"
44 return 0
46 if [ ! -c "${ntpd_chrootdir}/dev/clockctl" ]; then
47 rm -f "${ntpd_chrootdir}/dev/clockctl"
48 ( cd /dev ; /bin/pax -rw -pe clockctl "${ntpd_chrootdir}/dev" )
50 ln -fs "${ntpd_chrootdir}/var/db/ntp.drift" /var/db/ntp.drift
52 # Change run_rc_commands()'s internal copy of $ntpd_flags
54 rc_flags="-u ntpd:ntpd -i ${ntpd_chrootdir} $rc_flags"
57 load_rc_config $name
58 run_rc_command "$1"