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