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