]> git.pld-linux.org Git - packages/ntp.git/blob - ntp.init
- rel 2
[packages/ntp.git] / ntp.init
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 upstart_controlled
13
14 # Source networking configuration.
15 . /etc/sysconfig/network
16
17 # Source ntp configuration
18 . /etc/sysconfig/ntpd
19
20 # Check that networking is up.
21 if is_yes "${NETWORKING}"; then
22         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
23                 msg_network_down "ntpd"
24                 exit 1
25         fi
26 else
27         exit 0
28 fi
29
30 [ -f /etc/ntp/ntp.conf ] || exit 0
31
32 start() {
33         # Check if the service is already running?
34         if [ ! -f /var/lock/subsys/ntpd ]; then
35                 msg_starting "ntpd"
36                 daemon /usr/sbin/ntpd -c /etc/ntp/ntp.conf -p /var/run/ntpd.pid -u ntp:ntp $NTPD_OPTIONS
37                 RETVAL=$?
38                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ntpd
39         else
40                 msg_already_running "ntpd"
41         fi
42 }
43
44 stop() {
45         if [ -f /var/lock/subsys/ntpd ]; then
46                 msg_stopping "ntpd"
47                 killproc ntpd
48                 rm -f /var/lock/subsys/ntpd
49         else
50                 msg_not_running "ntpd"
51         fi
52 }
53
54 condrestart() {
55         if [ -f /var/lock/subsys/ntpd ]; then
56                 stop
57                 start
58         else
59                 msg_not_running "ntpd"
60                 RETVAL=$1
61         fi
62 }
63
64 RETVAL=0
65 # See how we were called.
66 case "$1" in
67   start)
68         start
69         ;;
70   stop)
71         stop
72         ;;
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         ;;
84   status)
85         status ntpd
86         exit $?
87         ;;
88   *)
89         msg_usage "$0 {start|stop|restart|try-restart|force-reload|condrestart|status}"
90         exit 3
91 esac
92
93 exit $RETVAL
This page took 0.065775 seconds and 3 git commands to generate.