Merge from vendor branch LIBSTDC++:
[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.1 2003/07/24 06:35:37 dillon Exp $
6 #
7
8 # PROVIDE: ntpd
9 # REQUIRE: DAEMON
10 # BEFORE:  LOGIN
11 # KEYWORD: DragonFly FreeBSD NetBSD
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
21 case ${OSTYPE} in
22 NetBSD)
23         start_precmd="ntpd_precmd"
24         ;;
25 esac
26
27 ntpd_precmd()
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 load_rc_config $name
54 run_rc_command "$1"