]>
Commit | Line | Data |
---|---|---|
b9935303 | 1 | #!/bin/sh |
2 | # | |
3 | # ntp This shell script takes care of starting and stopping | |
4 | # ntp (NTP daemon). | |
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 | ||
15 | # Check that networking is up. | |
16 | [ "${NETWORKING}" = "no" ] && exit 0 | |
17 | ||
18 | [ -x /usr/sbin/ntpd -a -f /etc/ntp/ntp.conf ] || exit 0 | |
19 | ||
20 | # See how we were called. | |
21 | case "$1" in | |
22 | start) | |
23 | # Check if the service is already running? | |
24 | if [ ! -f /var/lock/subsys/ntp ]; then | |
d2dd7019 SZ |
25 | if is_yes "$SYNC_TIME"; then |
26 | # Adjust time to make life easy for ntp | |
27 | run_cmd "Syncing time for ntp" /usr/sbin/ntpdate $NTPDATE_OPTIONS $NTPDATE_SERVERS | |
28 | fi | |
b9935303 | 29 | msg_starting ntp |
7fc5e330 | 30 | daemon ntpd -c /etc/ntp/ntp.conf |
ee2f7289 SZ |
31 | RETVAL=$? |
32 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ntp | |
b9935303 | 33 | else |
34 | msg_Already_Running ntp | |
35 | exit 1 | |
36 | fi | |
b9935303 | 37 | ;; |
38 | stop) | |
ee2f7289 SZ |
39 | if [ -f /var/lock/subsys/ntp ]; then |
40 | msg_stopping ntp | |
41 | killproc ntpd | |
42 | rm -f /var/lock/subsys/ntp | |
43 | else | |
44 | msg_Not_Running ntp | |
45 | exit 1 | |
46 | fi | |
47 | ;; | |
b9935303 | 48 | status) |
cea25d01 | 49 | status ntpd |
b9935303 | 50 | ;; |
51 | restart|reload) | |
52 | $0 stop | |
53 | $0 start | |
54 | ;; | |
55 | *) | |
56 | echo "Usage: $0 {start|stop|restart|status}" | |
57 | exit 1 | |
58 | esac | |
59 | ||
60 | exit 0 |