]> git.pld-linux.org Git - packages/rdate.git/commitdiff
- added background clock syncing
authordeejay1 <deejay1@pld-linux.org>
Thu, 8 Jan 2004 20:00:39 +0000 (20:00 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
  by jerzy szczudłowski <jerzy {at} jedwab.net.pl>

Changed files:
    rdate.init -> 1.13

rdate.init

index 87e4ddc921a9f3bfed0212ceb2e75b735e6c93d9..e8c0db9f13048709dc6f37ecd0e361156242f24c 100644 (file)
@@ -29,53 +29,76 @@ if [ -f /etc/sysconfig/rdate ]; then
        . /etc/sysconfig/rdate
 fi
 
+# internal functions
+set_time ()
+{
+       if [ $? -eq 0 -a -x /sbin/hwclock ] && is_yes "${SYNC_HWCLOCK}"; then
+               # Set the system clock.
+               ARC=0
+               SRM=0
+               UTC=0
 
-# See how we were called.
-case "$1" in
-  start|restart|reload|force-reload)
-       # Check if we have to do anything:
-       if is_yes "${SET_TIME}" && [ -n "${RDATE_SERVERS}" ]; then
-               run_cmd "$(nls "Setting time from remote server: %s" "${RDATE_SERVERS}")" rdate -s -l "${RDATE_SERVERS}"
-               if [ $? -eq 0 -a -x /sbin/hwclock ] && is_yes "${SYNC_HWCLOCK}"; then
-                       # Set the system clock.
-                       ARC=0
-                       SRM=0
-                       UTC=0
-
-                       if [ -f /etc/sysconfig/clock ]; then
-                               . /etc/sysconfig/clock
+               if [ -f /etc/sysconfig/clock ]; then
+                       . /etc/sysconfig/clock
 
-                               # convert old style clock config to new values
-                               if [ "${CLOCKMODE}" = "GMT" ]; then
-                                       UTC=true
-                               elif [ "${CLOCKMODE}" = "ARC" ]; then
-                                       ARC=true
-                               fi
-                       fi
-
-                       if grep "system serial" /proc/cpuinfo | grep -q MILO ; then
+                       # convert old style clock config to new values
+                       if [ "${CLOCKMODE}" = "GMT" ]; then
+                               UTC=true
+                       elif [ "${CLOCKMODE}" = "ARC" ]; then
                                ARC=true
                        fi
+               fi
 
-                       CLOCKFLAGS="--systohc"
-                               
-                       if is_yes "$UTC" ; then
-                               CLOCKFLAGS="$CLOCKFLAGS --utc"
-                       else
-                               CLOCKFLAGS="$CLOCKFLAGS --localtime"
-                       fi
+               if grep "system serial" /proc/cpuinfo | grep -q MILO ; then
+                       ARC=true
+               fi
 
-                       if is_yes "$ARC" ; then
-                               CLOCKFLAGS="$CLOCKFLAGS -A"
-                       fi
+               CLOCKFLAGS="--systohc"
+                       
+               if is_yes "$UTC" ; then
+                       CLOCKFLAGS="$CLOCKFLAGS --utc"
+               else
+                       CLOCKFLAGS="$CLOCKFLAGS --localtime"
+               fi
 
-                       if is_yes "$SRM" ; then
-                               CLOCKFLAGS="$CLOCKFLAGS -S"
-                       fi
+               if is_yes "$ARC" ; then
+                       CLOCKFLAGS="$CLOCKFLAGS -A"
+               fi
+
+               if is_yes "$SRM" ; then
+                       CLOCKFLAGS="$CLOCKFLAGS -S"
+               fi
 
+               if is_yes "${BACKGROUND}"; then
+                       # be quiet when in background
+                       /sbin/hwclock $CLOCKFLAGS
+               else
                        run_cmd "Syncing hardware clock" /sbin/hwclock $CLOCKFLAGS
                fi
        fi
+}
+
+
+# See how we were called.
+case "$1" in
+  start|restart|reload|force-reload)
+       # Check if we have to do anything:
+       if is_yes "${SET_TIME}" && [ -n "${RDATE_SERVERS}" ]; then
+               if is_yes "${BACKGROUND}"; then
+                       # synchronize in background for faster startups
+                       run_cmd "$(nls "Setting time from remote server (bg): %s" "${RDATE_SERVERS}")" /bin/true
+                       run_cmd "Syncing hardware clock (bg)" /bin/true
+                       {
+                               rdate -s -l "${RDATE_SERVERS}"
+                               set_time
+                       }&
+               else
+                       # or else synchronize in foreground for precise timestamps
+                       run_cmd "$(nls "Setting time from remote server: %s" "${RDATE_SERVERS}")" rdate -s -l "${RDATE_SERVERS}"
+                       set_time
+               fi
+               
+       fi
        ;;
   stop)
        # nothing to do
This page took 0.063273 seconds and 4 git commands to generate.