]> git.pld-linux.org Git - packages/ntp.git/blobdiff - ntp-client.init
- missing BR: pciutils-devel
[packages/ntp.git] / ntp-client.init
index 75746e414209c151732868effc3853a6d030ba68..ff624c597a8adfe3deb15d45beef1705534beb72 100644 (file)
@@ -1,38 +1,51 @@
 #!/bin/sh
 #
-# ntp          This shell script synchronizes time with ntpdate (NTP client)
+# ntpdate              This shell script synchronizes time with ntpdate (NTP client)
 #
-# chkconfig:   2345 55 10
-# description: ntp is the NTP client.
+# chkconfig:   2345 16 89
+# description: ntpdate is the NTP client.
 
 # Source function library.
 . /etc/rc.d/init.d/functions
 
+upstart_controlled --except cronsettime
+
 # Source networking configuration.
 . /etc/sysconfig/network
 
+# if not specified in config
+NTPDATE_USER="ntp"
+
 # Source ntp configuration
-. /etc/sysconfig/ntp
+. /etc/sysconfig/ntpdate
 
 # Check that networking is up.
 if is_yes "${NETWORKING}"; then
        if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
-               msg_network_down ntp
+               msg_network_down "ntpdate"
                exit 1
        fi
 else
        exit 0
 fi
 
+ntpdate_background() {
+       /usr/sbin/ntpdate -s ${NTPDATE_USER:+-U $NTPDATE_USER} $NTPDATE_OPTIONS $NTPDATE_SERVERS || return $?
+
+       if is_yes "$SYNC_HWCLOCK"; then
+               /sbin/hwclock --systohc
+       fi
+}
+
 start() {
        show "Syncing time with ntpdate (backgrounding)"
-       daemon --fork /usr/sbin/ntpdate -s $NTPDATE_OPTIONS $NTPDATE_SERVERS
-       RETVAL=$?
-       [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ntp
+       ntpdate_background &
+       touch /var/lock/subsys/ntpdate
+       ok
 }
 
 stop() {
-       rm -f /var/lock/subsys/ntp
+       rm -f /var/lock/subsys/ntpdate
 }
 
 RETVAL=0
@@ -49,7 +62,7 @@ restart|force-reload)
        start
        ;;
 cronsettime)
-       is_yes "$NTPDATE_CRON" && /usr/sbin/ntpdate -s $NTPDATE_OPTIONS $NTPDATE_SERVERS > /dev/null 2>&1
+       is_yes "$NTPDATE_CRON" && /usr/sbin/ntpdate -s ${NTPDATE_USER:+-U $NTPDATE_USER} $NTPDATE_OPTIONS $NTPDATE_SERVERS
        RETVAL=$?
        ;;
 *)
This page took 0.0313 seconds and 4 git commands to generate.