# NTP is still recommended on these machines to get to real time sync
# once more of the system is up and running.
#
-# Copyright 2012 Steve McIntyre <93sam@debian.org>
+# Copyright 2012-2016 Steve McIntyre <93sam@debian.org>
#
# License: GPLv2, see COPYING
FILE=/etc/fake-hwclock.data
fi
+# Midnight on the day of this release, used as a sanity check when
+# saving
+HWCLOCK_EPOCH="2016-04-15 00:00:00"
+HWCLOCK_EPOCH_SEC="1460678400"
+
COMMAND=$1
if [ "$COMMAND"x = ""x ] ; then
COMMAND="save"
case $COMMAND in
save)
if [ -e $FILE ] ; then
- SAVED="$(cat $FILE)"
- SAVED_SEC=$(date -u -d "$SAVED" '+%s')
NOW_SEC=$(date -u '+%s')
- if $FORCE || [ $NOW_SEC -ge $SAVED_SEC ] ; then
+ if $FORCE || [ $NOW_SEC -ge $HWCLOCK_EPOCH_SEC ] ; then
date -u '+%Y-%m-%d %H:%M:%S' > $FILE
else
+ echo "Time travel detected!"
+ echo "fake-hwclock release date is in the future: $HWCLOCK_EPOCH"
echo "Current system time: $(date -u '+%Y-%m-%d %H:%M:%S')"
- echo "fake-hwclock saved clock information is in the future: $SAVED"
- echo "To force the saved system clock backwards anyway, use \"force\""
+ echo "To force the saved system clock backwards in time anyway, use \"force\""
fi
else
date -u '+%Y-%m-%d %H:%M:%S' > $FILE