]> git.pld-linux.org Git - packages/ntp.git/blobdiff - ntp.init
- missing BR: pciutils-devel
[packages/ntp.git] / ntp.init
index a5150f399c8ce1c628c8d3d4833587bff9b11a31..afab09c50c71b0d8717534fb853e05977c266320 100644 (file)
--- a/ntp.init
+++ b/ntp.init
@@ -1,55 +1,96 @@
 #!/bin/sh
 #
-# ntp           This shell script takes care of starting and stopping
-#               ntp (NTP daemon).
+# ntpd         This shell script takes care of starting and stopping
+#              ntp (NTP daemon).
 #
-# chkconfig:   - 55 10
-# description: ntp is the NTP daemon.
+# chkconfig:   2345 55 10
+# description: ntpd is the NTP daemon.
 
 # Source function library.
 . /etc/rc.d/init.d/functions
 
+upstart_controlled
+
 # Source networking configuration.
 . /etc/sysconfig/network
 
+# default user if not overriden by config
+NTPD_USER="ntp"
+
+# Source ntp configuration
+. /etc/sysconfig/ntpd
+
 # Check that networking is up.
-[ "${NETWORKING}" = "no" ] && exit 0
+if is_yes "${NETWORKING}"; then
+       if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
+               msg_network_down "ntpd"
+               exit 1
+       fi
+else
+       exit 0
+fi
 
-[ -x /usr/sbin/ntpd -a -f /etc/ntp/ntp.conf ] || exit 0
+[ -f /etc/ntp/ntp.conf ] || exit 0
 
+start() {
+       # Check if the service is already running?
+       if [ ! -f /var/lock/subsys/ntpd ]; then
+               msg_starting "ntpd"
+               daemon /usr/sbin/ntpd -c /etc/ntp/ntp.conf -p /var/run/ntpd.pid ${NTPD_USER:+-u $NTPD_USER} $NTPD_OPTIONS
+               RETVAL=$?
+               [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ntpd
+       else
+               msg_already_running "ntpd"
+       fi
+}
+
+stop() {
+       if [ -f /var/lock/subsys/ntpd ]; then
+               msg_stopping "ntpd"
+               killproc ntpd
+               rm -f /var/lock/subsys/ntpd
+       else
+               msg_not_running "ntpd"
+       fi
+}
+
+condrestart() {
+       if [ -f /var/lock/subsys/ntpd ]; then
+               stop
+               start
+       else
+               msg_not_running "ntpd"
+               RETVAL=$1
+       fi
+}
+
+RETVAL=0
 # See how we were called.
 case "$1" in
   start)
-       # Check if the service is already running?
-        if [ ! -f /var/lock/subsys/ntp ]; then
-               # Adjust time to make life easy for ntp
-#              echo -n "Syncing time for ntp"
-#              /usr/sbin/ntpdate -o 1  clock.llnl.gov norad.arc.nasa.gov
-#              echo
-               msg_starting ntp
-               daemon ntpd -c /etc/ntp/ntp.conf
-        else
-               msg_Already_Running ntp
-               exit 1
-       fi
-        touch /var/lock/subsys/ntp
-        ;;
+       start
+       ;;
   stop)
-        # Stop daemons.
-        msg_stopping ntpd
-       killproc ntpd
-        rm -f /var/lock/subsys/ntp
-        ;;
-  status)
-       status ntp ntpd
+       stop
+       ;;
+  restart)
+       stop
+       start
+       ;;
+  # NB! don't remove 'condrestart': dhcpcd calls this
+  try-restart|condrestart)
+       condrestart 0
        ;;
-  restart|reload)
-       $0 stop
-       $0 start
+  force-reload)
+       condrestart 7
+       ;;
+  status)
+       status ntpd
+       exit $?
        ;;
   *)
-        echo "Usage: $0 {start|stop|restart|status}"
-        exit 1
+       msg_usage "$0 {start|stop|restart|try-restart|force-reload|condrestart|status}"
+       exit 3
 esac
 
-exit 0
+exit $RETVAL
This page took 0.040548 seconds and 4 git commands to generate.