]>
Commit | Line | Data |
---|---|---|
b9935303 | 1 | #!/bin/sh |
2 | # | |
f0279210 | 3 | # ntp This shell script takes care of starting and stopping |
4 | # ntp (NTP daemon). | |
b9935303 | 5 | # |
6fccad43 | 6 | # chkconfig: 2345 55 10 |
b9935303 | 7 | # description: ntp is the NTP daemon. |
8 | ||
9 | # Source function library. | |
10 | . /etc/rc.d/init.d/functions | |
11 | ||
12 | # Source networking configuration. | |
13 | . /etc/sysconfig/network | |
14 | ||
5820dfda SZ |
15 | # Source ntp configuration |
16 | . /etc/sysconfig/ntp | |
17 | ||
b9935303 | 18 | # Check that networking is up. |
f0279210 | 19 | if is_yes "${NETWORKING}"; then |
20 | if [ ! -f /var/lock/subsys/network ]; 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 | |
b9935303 | 28 | |
29 | [ -x /usr/sbin/ntpd -a -f /etc/ntp/ntp.conf ] || exit 0 | |
30 | ||
31 | # See how we were called. | |
32 | case "$1" in | |
33 | start) | |
34 | # Check if the service is already running? | |
35 | if [ ! -f /var/lock/subsys/ntp ]; then | |
d2dd7019 SZ |
36 | if is_yes "$SYNC_TIME"; then |
37 | # Adjust time to make life easy for ntp | |
f0279210 | 38 | run_cmd "Syncing time for ntp" "/usr/sbin/ntpdate $NTPDATE_OPTIONS $NTPDATE_SERVERS" |
d2dd7019 | 39 | fi |
b9935303 | 40 | msg_starting ntp |
7fc5e330 | 41 | daemon ntpd -c /etc/ntp/ntp.conf |
ee2f7289 SZ |
42 | RETVAL=$? |
43 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ntp | |
b9935303 | 44 | else |
2e8d1fb2 | 45 | msg_already_running ntp |
b9935303 | 46 | exit 1 |
47 | fi | |
b9935303 | 48 | ;; |
49 | stop) | |
ee2f7289 SZ |
50 | if [ -f /var/lock/subsys/ntp ]; then |
51 | msg_stopping ntp | |
52 | killproc ntpd | |
53 | rm -f /var/lock/subsys/ntp | |
54 | else | |
2e8d1fb2 | 55 | msg_not_running ntp |
ee2f7289 SZ |
56 | exit 1 |
57 | fi | |
58 | ;; | |
b9935303 | 59 | status) |
cea25d01 | 60 | status ntpd |
b9935303 | 61 | ;; |
62 | restart|reload) | |
63 | $0 stop | |
64 | $0 start | |
65 | ;; | |
66 | *) | |
f0279210 | 67 | msg_usage "$0 {start|stop|restart|reload|status}" |
b9935303 | 68 | exit 1 |
69 | esac | |
70 | ||
f0279210 | 71 | exit $RETVAL |