Merge from vendor branch OPENSSL:
[dragonfly.git] / etc / rc.d / ntpd
1 #!/bin/sh
2 #
3 # $NetBSD: ntpd,v 1.6 2002/03/22 04:33:59 thorpej Exp $
4 # $FreeBSD: src/etc/rc.d/ntpd,v 1.5 2002/10/12 10:31:31 schweikh Exp $
5 # $DragonFly: src/etc/rc.d/Attic/ntpd,v 1.2 2004/01/27 00:42:45 rob Exp $
6 #
7
8 # PROVIDE: ntpd
9 # REQUIRE: DAEMON
10 # BEFORE:  LOGIN
11 # KEYWORD: DragonFly
12
13 . /etc/rc.subr
14
15 name=ntpd
16 rcvar=`set_rcvar`
17 command="/usr/sbin/${name}"
18 pidfile="/var/run/${name}.pid"
19 required_files="/etc/ntp.conf"
20 ntpd_precmd()
21 {
22         if [ -z "$ntpd_chrootdir" ]; then
23                 return 0;
24         fi
25
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.
29         #
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).
34         #
35         if [ ! -c "${ntpd_chrootdir}/dev/clockctl" ]; then
36                 rm -f "${ntpd_chrootdir}/dev/clockctl"
37                 ( cd /dev ; /bin/pax -rw -pe clockctl "${ntpd_chrootdir}/dev" )
38         fi
39         ln -fs "${ntpd_chrootdir}/var/db/ntp.drift" /var/db/ntp.drift
40
41         #       Change run_rc_commands()'s internal copy of $ntpd_flags
42         #
43         rc_flags="-u ntpd:ntpd -i ${ntpd_chrootdir} $rc_flags"
44 }
45
46 load_rc_config $name
47 run_rc_command "$1"