]> git.saurik.com Git - apple/launchd.git/blame - launchd/src/StartupItems/NetworkTime
launchd-106.10.tar.gz
[apple/launchd.git] / launchd / src / StartupItems / NetworkTime
CommitLineData
e91b9f68
A
1#!/bin/sh
2
3##
4# Network Time
5##
6
7. /etc/rc.common
8
9StartService ()
10{
11 if [ "${TIMESYNC:=-YES-}" = "-YES-" ] &&
12 ! GetPID ntpd > /dev/null; then
13
14 CheckForNetwork
15
16 if [ -f /var/run/NetworkTime.StartupItem -o "${NETWORKUP}" = "-NO-" ]; then exit; fi
17 touch /var/run/NetworkTime.StartupItem
18
19
20 echo "Starting network time synchronization"
21
22 # Synchronize our clock to the network's time,
23 # then fire off ntpd to keep the clock in sync.
24 ntpdate -bvs
25 ntpd -f /var/run/ntp.drift -p /var/run/ntpd.pid
26 fi
27}
28
29StopService ()
30{
31 if pid=$(GetPID ntpd); then
32 echo "Stopping network time synchronization"
33 kill -TERM "${pid}"
34 else
35 echo "ntpd is not running."
36 fi
37 rm -f /var/run/NetworkTime.StartupItem
38}
39
40RestartService () { StopService; StartService; }
41
42RunService "$1"