summaryrefslogtreecommitdiff
path: root/packages/initscripts/initscripts-1.0/bootmisc.sh
diff options
context:
space:
mode:
Diffstat (limited to 'packages/initscripts/initscripts-1.0/bootmisc.sh')
-rwxr-xr-xpackages/initscripts/initscripts-1.0/bootmisc.sh20
1 files changed, 11 insertions, 9 deletions
diff --git a/packages/initscripts/initscripts-1.0/bootmisc.sh b/packages/initscripts/initscripts-1.0/bootmisc.sh
index 799cdca12b..2a40e0c410 100755
--- a/packages/initscripts/initscripts-1.0/bootmisc.sh
+++ b/packages/initscripts/initscripts-1.0/bootmisc.sh
@@ -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