]> git.pld-linux.org Git - packages/ntp.git/blob - ntp.init
- LSB conformance
[packages/ntp.git] / ntp.init
1 #!/bin/sh
2 #
3 # ntp           This shell script takes care of starting and stopping
4 #               ntp (NTP daemon).
5 #
6 # chkconfig:    2345 55 10
7 # description:  ntp 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/ntp
17
18 # Check that networking is up.
19 if is_yes "${NETWORKING}"; then
20         if [ ! -f /var/lock/subsys/network ]; then
21                 # nls "ERROR: Networking is down. %s can't be run." <service>
22                 msg_network_down ntp
23                 exit 1
24         fi
25 else
26         exit 0
27 fi
28
29 [ -x /usr/sbin/ntpd -a -f /etc/ntp/ntp.conf ] || exit 0
30
31 RETVAL=0
32 # See how we were called.
33 case "$1" in
34   start)
35         # Check if the service is already running?
36         if [ ! -f /var/lock/subsys/ntp ]; then
37                 if is_yes "$SYNC_TIME"; then
38                         # Adjust time to make life easy for ntp
39                         run_cmd "Syncing time for ntp" "/usr/sbin/ntpdate $NTPDATE_OPTIONS $NTPDATE_SERVERS"
40                 fi
41                 msg_starting ntp
42                 daemon ntpd -c /etc/ntp/ntp.conf
43                 RETVAL=$?
44                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ntp
45         else
46                 msg_already_running ntp
47         fi
48         ;;
49   stop)
50         if [ -f /var/lock/subsys/ntp ]; then
51                 msg_stopping ntp
52                 killproc ntpd
53                 rm -f /var/lock/subsys/ntp
54         else
55                 msg_not_running ntp
56         fi
57         ;;
58   status)
59         status ntpd
60         exit $?
61         ;;
62   restart|force-reload)
63         $0 stop
64         $0 start
65         exit $?
66         ;;
67   *)
68         msg_usage "$0 {start|stop|restart|force-reload|status}"
69         exit 3
70 esac
71
72 exit $RETVAL
This page took 0.068396 seconds and 4 git commands to generate.