]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/sh | |
2 | # | |
3 | # ntpd This shell script takes care of starting and stopping | |
4 | # ntp (NTP daemon). | |
5 | # | |
6 | # chkconfig: 2345 55 10 | |
7 | # description: ntpd 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 | # Source ntp configuration | |
16 | . /etc/sysconfig/ntpd | |
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 ntpd | |
23 | exit 1 | |
24 | fi | |
25 | else | |
26 | exit 0 | |
27 | fi | |
28 | ||
29 | [ -x /usr/sbin/ntpd -a -f /etc/ntp/ntp.conf ] || exit 0 | |
30 | ||
31 | RETVAL=0 | |
32 | # See how we were called. | |
33 | case "$1" in | |
34 | start) | |
35 | # Check if the service is already running? | |
36 | if [ ! -f /var/lock/subsys/ntpd ]; then | |
37 | msg_starting ntpd | |
38 | daemon ntpd -c /etc/ntp/ntp.conf | |
39 | RETVAL=$? | |
40 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ntpd | |
41 | else | |
42 | msg_already_running ntp | |
43 | fi | |
44 | ;; | |
45 | stop) | |
46 | if [ -f /var/lock/subsys/ntpd ]; then | |
47 | msg_stopping ntpd | |
48 | killproc ntpd | |
49 | rm -f /var/lock/subsys/ntpd | |
50 | else | |
51 | msg_not_running ntpd | |
52 | fi | |
53 | ;; | |
54 | status) | |
55 | status ntpd | |
56 | exit $? | |
57 | ;; | |
58 | restart|force-reload) | |
59 | $0 stop | |
60 | $0 start | |
61 | exit $? | |
62 | ;; | |
63 | *) | |
64 | msg_usage "$0 {start|stop|restart|force-reload|status}" | |
65 | exit 3 | |
66 | esac | |
67 | ||
68 | exit $RETVAL |