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