]>
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 | ||
65155ef7 ER |
12 | upstart_controlled |
13 | ||
b9935303 | 14 | # Source networking configuration. |
15 | . /etc/sysconfig/network | |
16 | ||
5820dfda | 17 | # Source ntp configuration |
9862853a | 18 | . /etc/sysconfig/ntpd |
5820dfda | 19 | |
b9935303 | 20 | # Check that networking is up. |
f0279210 | 21 | if is_yes "${NETWORKING}"; then |
0284b494 | 22 | if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then |
d9ddddbb | 23 | msg_network_down "ntpd" |
f0279210 | 24 | exit 1 |
25 | fi | |
26 | else | |
27 | exit 0 | |
28 | fi | |
b9935303 | 29 | |
93c97cc8 | 30 | [ -f /etc/ntp/ntp.conf ] || exit 0 |
b9935303 | 31 | |
365ec4e7 | 32 | start() { |
b9935303 | 33 | # Check if the service is already running? |
9862853a | 34 | if [ ! -f /var/lock/subsys/ntpd ]; then |
d9ddddbb | 35 | msg_starting "ntpd" |
4aef70db | 36 | daemon /usr/sbin/ntpd -c /etc/ntp/ntp.conf -p /var/run/ntpd.pid -u ntp:ntp $NTPD_OPTIONS |
966bd92b | 37 | RETVAL=$? |
9862853a | 38 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ntpd |
966bd92b | 39 | else |
d9ddddbb | 40 | msg_already_running "ntpd" |
b9935303 | 41 | fi |
365ec4e7 ER |
42 | } |
43 | ||
44 | stop() { | |
9862853a | 45 | if [ -f /var/lock/subsys/ntpd ]; then |
d9ddddbb | 46 | msg_stopping "ntpd" |
68000f77 | 47 | killproc ntpd |
9862853a | 48 | rm -f /var/lock/subsys/ntpd |
966bd92b | 49 | else |
d9ddddbb | 50 | msg_not_running "ntpd" |
ee2f7289 | 51 | fi |
365ec4e7 ER |
52 | } |
53 | ||
3130aa68 ER |
54 | condrestart() { |
55 | if [ -f /var/lock/subsys/ntpd ]; then | |
56 | stop | |
57 | start | |
58 | else | |
d9ddddbb | 59 | msg_not_running "ntpd" |
3130aa68 ER |
60 | RETVAL=$1 |
61 | fi | |
62 | } | |
63 | ||
365ec4e7 ER |
64 | RETVAL=0 |
65 | # See how we were called. | |
66 | case "$1" in | |
67 | start) | |
68 | start | |
69 | ;; | |
70 | stop) | |
71 | stop | |
ee2f7289 | 72 | ;; |
3130aa68 ER |
73 | restart) |
74 | stop | |
75 | start | |
76 | ;; | |
77 | # NB! don't remove 'condrestart': dhcpcd calls this | |
78 | try-restart|condrestart) | |
79 | condrestart 0 | |
80 | ;; | |
81 | force-reload) | |
82 | condrestart 7 | |
83 | ;; | |
b9935303 | 84 | status) |
cea25d01 | 85 | status ntpd |
dfecda58 | 86 | exit $? |
b9935303 | 87 | ;; |
b9935303 | 88 | *) |
3130aa68 | 89 | msg_usage "$0 {start|stop|restart|try-restart|force-reload|condrestart|status}" |
dfecda58 | 90 | exit 3 |
b9935303 | 91 | esac |
92 | ||
f0279210 | 93 | exit $RETVAL |