]>
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 | ||
9862853a MK |
27 | RETVAL=0 |
28 | # See how we were called. | |
29 | case "$1" in | |
0bcd3f32 ER |
30 | cronsettime) |
31 | is_yes "$NTPDATE_CRON" && /usr/sbin/ntpdate -s $NTPDATE_OPTIONS $NTPDATE_SERVERS > /dev/null 2>&1 | |
81adfe42 | 32 | RETVAL=$? |
9862853a | 33 | ;; |
0bcd3f32 ER |
34 | start) |
35 | show "Syncing time with ntpdate (backgrounding)" | |
36 | daemon --fork /usr/sbin/ntpdate -s $NTPDATE_OPTIONS $NTPDATE_SERVERS | |
754ad555 | 37 | RETVAL=$? |
6dce25d6 | 38 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ntp |
0bcd3f32 ER |
39 | ;; |
40 | stop) | |
6dce25d6 | 41 | rm -f /var/lock/subsys/ntp |
9862853a MK |
42 | exit $RETVAL |
43 | ;; | |
0bcd3f32 | 44 | restart|force-reload) |
9862853a MK |
45 | $0 start |
46 | exit $? | |
47 | ;; | |
0bcd3f32 | 48 | *) |
9862853a MK |
49 | msg_usage "$0 {start|restart|force-reload}" |
50 | exit 3 | |
51 | esac | |
52 | ||
53 | exit $RETVAL |