]> git.pld-linux.org Git - packages/ntp.git/blob - ntp-client.init
- run ntpdate under ntp uid, ntpdate service also can sync hwclock after service...
[packages/ntp.git] / ntp-client.init
1 #!/bin/sh
2 #
3 # ntpdate               This shell script synchronizes time with ntpdate (NTP client)
4 #
5 # chkconfig:    2345 55 10
6 # description:  ntpdate is the NTP client.
7
8 # Source function library.
9 . /etc/rc.d/init.d/functions
10
11 # Source networking configuration.
12 . /etc/sysconfig/network
13
14 # Source ntp configuration
15 . /etc/sysconfig/ntpdate
16
17 # Check that networking is up.
18 if is_yes "${NETWORKING}"; then
19         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
20                 msg_network_down "ntpdate"
21                 exit 1
22         fi
23 else
24         exit 0
25 fi
26
27 start() {
28         show "Syncing time with ntpdate"
29         daemon /usr/sbin/ntpdate -s $NTPDATE_OPTIONS $NTPDATE_SERVERS
30         RETVAL=$?
31         if [ $RETVAL -eq 0 ]; then
32                 touch /var/lock/subsys/ntpdate
33                 if is_yes "$SYNC_HWCLOCK"; then
34                         show "Syncing hardware clock to system time"
35                     /sbin/hwclock --systohc && ok || fail
36                 fi
37         fi
38 }
39
40 stop() {
41         rm -f /var/lock/subsys/ntpdate
42 }
43
44 RETVAL=0
45 # See how we were called.
46 case "$1" in
47 start)
48         start
49         ;;
50 stop)
51         stop
52         ;;
53 restart|force-reload)
54         stop
55         start
56         ;;
57 cronsettime)
58         is_yes "$NTPDATE_CRON" && /usr/sbin/ntpdate -s $NTPDATE_OPTIONS $NTPDATE_SERVERS > /dev/null 2>&1
59         RETVAL=$?
60         ;;
61 *)
62         msg_usage "$0 {start|restart|force-reload}"
63         exit 3
64 esac
65
66 exit $RETVAL
This page took 0.037243 seconds and 4 git commands to generate.