]>
Commit | Line | Data |
---|---|---|
b9935303 | 1 | #!/bin/sh |
2 | # | |
9862853a | 3 | # ntpd This shell script takes care of starting and stopping |
f0279210 | 4 | # ntp (NTP daemon). |
b9935303 | 5 | # |
6fccad43 | 6 | # chkconfig: 2345 55 10 |
9862853a | 7 | # description: ntpd is the NTP daemon. |
b9935303 | 8 | |
9 | # Source function library. | |
10 | . /etc/rc.d/init.d/functions | |
11 | ||
12 | # Source networking configuration. | |
13 | . /etc/sysconfig/network | |
14 | ||
5820dfda | 15 | # Source ntp configuration |
9862853a | 16 | . /etc/sysconfig/ntpd |
5820dfda | 17 | |
b9935303 | 18 | # Check that networking is up. |
f0279210 | 19 | if is_yes "${NETWORKING}"; then |
0284b494 | 20 | if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then |
f0279210 | 21 | # nls "ERROR: Networking is down. %s can't be run." <service> |
9862853a | 22 | msg_network_down ntpd |
f0279210 | 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 | ||
dfecda58 | 31 | RETVAL=0 |
b9935303 | 32 | # See how we were called. |
33 | case "$1" in | |
34 | start) | |
35 | # Check if the service is already running? | |
9862853a MK |
36 | if [ ! -f /var/lock/subsys/ntpd ]; then |
37 | msg_starting ntpd | |
966bd92b | 38 | daemon ntpd -c /etc/ntp/ntp.conf |
39 | RETVAL=$? | |
9862853a | 40 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ntpd |
966bd92b | 41 | else |
42 | msg_already_running ntp | |
b9935303 | 43 | fi |
966bd92b | 44 | ;; |
b9935303 | 45 | stop) |
9862853a MK |
46 | if [ -f /var/lock/subsys/ntpd ]; then |
47 | msg_stopping ntpd | |
ee2f7289 | 48 | killproc ntpd |
9862853a | 49 | rm -f /var/lock/subsys/ntpd |
966bd92b | 50 | else |
9862853a | 51 | msg_not_running ntpd |
ee2f7289 SZ |
52 | fi |
53 | ;; | |
b9935303 | 54 | status) |
cea25d01 | 55 | status ntpd |
dfecda58 | 56 | exit $? |
b9935303 | 57 | ;; |
dfecda58 | 58 | restart|force-reload) |
b9935303 | 59 | $0 stop |
60 | $0 start | |
dfecda58 | 61 | exit $? |
b9935303 | 62 | ;; |
63 | *) | |
dfecda58 | 64 | msg_usage "$0 {start|stop|restart|force-reload|status}" |
65 | exit 3 | |
b9935303 | 66 | esac |
67 | ||
f0279210 | 68 | exit $RETVAL |