2013-12-21 10:56:45 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2014-01-13 15:02:37 +00:00
|
|
|
THISFILE=$0
|
2014-05-25 11:21:30 +00:00
|
|
|
STATEFILE=$0
|
2013-12-21 10:56:45 +00:00
|
|
|
|
2014-05-25 11:21:30 +00:00
|
|
|
loadclock() {
|
|
|
|
local savedtime=$(stat -c %Y "$STATEFILE")
|
|
|
|
if [ $(date +%s) -lt $savedtime ]; then
|
|
|
|
echo "Restoring saved system time"
|
|
|
|
date -s @$savedtime
|
|
|
|
else
|
|
|
|
echo "Not restoring old system time"
|
|
|
|
fi
|
2013-12-21 10:56:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
saveclock() {
|
2013-12-22 22:22:00 +00:00
|
|
|
echo "Saving current time."
|
2014-05-25 11:21:30 +00:00
|
|
|
touch "$STATEFILE"
|
2013-12-21 10:56:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
2014-05-25 11:21:30 +00:00
|
|
|
load)
|
|
|
|
loadclock
|
|
|
|
;;
|
2013-12-21 10:56:45 +00:00
|
|
|
set)
|
2014-05-25 11:21:30 +00:00
|
|
|
echo "'set' is deprecated, use 'load' instead."
|
|
|
|
echo "Consider using the systemd timer unit fake-hwclock-save.timer"
|
|
|
|
loadclock
|
2013-12-21 10:56:45 +00:00
|
|
|
;;
|
|
|
|
save)
|
|
|
|
saveclock
|
|
|
|
;;
|
|
|
|
*)
|
2014-05-25 11:21:30 +00:00
|
|
|
echo "Usage: $THISFILE {load|save}"
|
2013-12-21 10:56:45 +00:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|