initscipts: Improve RTC handling so /etc/timestamp is used if its timestamp is 1...
authorRichard Purdie <rpurdie@rpsys.net>
Sun, 2 Sep 2007 14:18:47 +0000 (14:18 +0000)
committerRichard Purdie <rpurdie@rpsys.net>
Sun, 2 Sep 2007 14:18:47 +0000 (14:18 +0000)
packages/initscripts/initscripts-1.0/bootmisc.sh
packages/initscripts/initscripts-1.0/save-rtc.sh
packages/initscripts/initscripts_1.0.bb

index 799cdca..2a40e0c 100755 (executable)
@@ -61,16 +61,18 @@ fi
 #
 /sbin/ldconfig
 
-# 
-# Recover the time, if there is a time file (first boot only)
-# If not, set system clock from hardware clock
-#
+# Set the system clock from hardware clock
+# If the timestamp is 1 day or more recent than the current time,
+# use the timestamp instead.
+/etc/init.d/hwclock.sh start
 if test -e /etc/timestamp
 then
-       date -s `cat /etc/timestamp`
-       mv -f /etc/timestamp /etc/timestamp.done
-       /etc/init.d/hwclock.sh stop
-else
-       /etc/init.d/hwclock.sh start
+       SYSTEMDATE=`date "+%Y%m%d"`
+       TIMESTAMP=`cat /etc/timestamp | awk '{ print substr($0,9,4) substr($0,1,4);}'`
+        NEEDUPDATE=`expr \( $TIMESTAMP \> $SYSTEMDATE \)`                                                 
+        if [ $NEEDUPDATE -eq 1 ]; then 
+               date `cat /etc/timestamp`
+               /etc/init.d/hwclock.sh stop
+       fi
 fi
 : exit 0
index 4e0e270..e786073 100644 (file)
@@ -1,3 +1,5 @@
 #! /bin/sh
-#FIXME read timestamp handling for systems where RTC doesn't survive a reboot
 /etc/init.d/hwclock.sh stop
+
+# Update the timestamp
+date +%2m%2d%2H%2M%Y > /etc/timestamp
index 3d2f0f5..06a12c0 100644 (file)
@@ -4,7 +4,7 @@ PRIORITY = "required"
 DEPENDS = "makedevs"
 RDEPENDS = "makedevs"
 LICENSE = "GPL"
-PR = "r99"
+PR = "r100"
 
 SRC_URI = "file://functions \
            file://halt \