]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - etc/rc.d/ntpd
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / etc / rc.d / ntpd
1 #!/bin/sh
2 #
3 # $FreeBSD$
4 #
5
6 # PROVIDE: ntpd
7 # REQUIRE: DAEMON ntpdate FILESYSTEMS devfs
8 # BEFORE:  LOGIN
9 # KEYWORD: nojail shutdown
10
11 . /etc/rc.subr
12
13 name="ntpd"
14 rcvar="ntpd_enable"
15 command="/usr/sbin/${name}"
16 pidfile="/var/run/${name}.pid"
17 start_precmd="ntpd_precmd"
18
19 load_rc_config $name
20
21 ntpd_precmd()
22 {
23         rc_flags="-c ${ntpd_config} ${ntpd_flags}"
24
25         if checkyesno ntpd_sync_on_start; then
26                 rc_flags="-g $rc_flags"
27         fi
28
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
53 run_rc_command "$1"