]>
Commit | Line | Data |
---|---|---|
9862853a MK |
1 | #!/bin/sh |
2 | # | |
0bcd3f32 | 3 | # ntp This shell script synchronizes time with ntpdate (NTP client) |
9862853a MK |
4 | # |
5 | # chkconfig: 2345 55 10 | |
6 | # description: ntp 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/ntp | |
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 | |
9862853a MK |
20 | msg_network_down ntp |
21 | exit 1 | |
22 | fi | |
23 | else | |
24 | exit 0 | |
25 | fi | |
26 | ||
2fc0ecc0 | 27 | start() { |
0bcd3f32 ER |
28 | show "Syncing time with ntpdate (backgrounding)" |
29 | daemon --fork /usr/sbin/ntpdate -s $NTPDATE_OPTIONS $NTPDATE_SERVERS | |
754ad555 | 30 | RETVAL=$? |
6dce25d6 | 31 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ntp |
2fc0ecc0 ER |
32 | } |
33 | ||
34 | stop() { | |
35 | rm -f /var/lock/subsys/ntp | |
36 | } | |
37 | ||
38 | RETVAL=0 | |
39 | # See how we were called. | |
40 | case "$1" in | |
41 | start) | |
42 | start | |
0bcd3f32 ER |
43 | ;; |
44 | stop) | |
2fc0ecc0 | 45 | stop |
9862853a | 46 | ;; |
0bcd3f32 | 47 | restart|force-reload) |
2fc0ecc0 ER |
48 | stop |
49 | start | |
50 | ;; | |
51 | cronsettime) | |
52 | is_yes "$NTPDATE_CRON" && /usr/sbin/ntpdate -s $NTPDATE_OPTIONS $NTPDATE_SERVERS > /dev/null 2>&1 | |
53 | RETVAL=$? | |
9862853a | 54 | ;; |
0bcd3f32 | 55 | *) |
9862853a MK |
56 | msg_usage "$0 {start|restart|force-reload}" |
57 | exit 3 | |
58 | esac | |
59 | ||
60 | exit $RETVAL |