PKGBUILDs/alarm/fake-hwclock/fake-hwclock.sh

38 lines
581 B
Bash
Raw Normal View History

2013-12-21 10:56:45 +00:00
#!/bin/bash
2014-01-13 15:02:37 +00:00
THISFILE=$0
STATEFILE=$0
2013-12-21 10:56:45 +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() {
echo "Saving current time."
touch "$STATEFILE"
2013-12-21 10:56:45 +00:00
}
case "$1" in
load)
loadclock
;;
2013-12-21 10:56:45 +00:00
set)
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
;;
*)
echo "Usage: $THISFILE {load|save}"
2013-12-21 10:56:45 +00:00
exit 1
;;
esac