]>
Commit | Line | Data |
---|---|---|
9862853a MK |
1 | #!/bin/sh |
2 | # | |
3 | # ntp This shell script takes care of starting and stopping | |
4 | # ntp (NTP client). | |
5 | # | |
6 | # chkconfig: 2345 55 10 | |
7 | # description: ntp is the NTP client. | |
8 | ||
9 | # Source function library. | |
10 | . /etc/rc.d/init.d/functions | |
11 | ||
12 | # Source networking configuration. | |
13 | . /etc/sysconfig/network | |
14 | ||
15 | # Source ntp configuration | |
16 | . /etc/sysconfig/ntp | |
17 | ||
18 | # Check that networking is up. | |
19 | if is_yes "${NETWORKING}"; then | |
20 | if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then | |
21 | # nls "ERROR: Networking is down. %s can't be run." <service> | |
22 | msg_network_down ntp | |
23 | exit 1 | |
24 | fi | |
25 | else | |
26 | exit 0 | |
27 | fi | |
28 | ||
29 | [ -x /usr/sbin/ntpdate ] || exit 0 | |
30 | ||
31 | RETVAL=0 | |
32 | # See how we were called. | |
33 | case "$1" in | |
754ad555 AM |
34 | cronsettime) |
35 | is_yes "$NTPDATE_CRON" && /usr/sbin/ntpdate -s $NTPDATE_OPTIONS $NTPDATE_SERVERS > /dev/null 2>&1 | |
81adfe42 | 36 | RETVAL=$? |
9862853a | 37 | ;; |
754ad555 AM |
38 | start) |
39 | run_cmd "Syncing time for ntp" /usr/sbin/ntpdate $NTPDATE_OPTIONS $NTPDATE_SERVERS | |
40 | RETVAL=$? | |
41 | ;; | |
9862853a MK |
42 | stop) |
43 | exit $RETVAL | |
44 | ;; | |
45 | restart|force-reload) | |
46 | $0 start | |
47 | exit $? | |
48 | ;; | |
49 | *) | |
50 | msg_usage "$0 {start|restart|force-reload}" | |
51 | exit 3 | |
52 | esac | |
53 | ||
54 | exit $RETVAL |