PKGBUILDs/alarm/fake-hwclock/fake-hwclock.sh
Peter Wu edaec43cea alarm/fake-hwclock: use systemd timer unit, to 0.3
* PKGBUILD: modified to install directories with correct permissions (in
  case of a restrictive umask).
* PKGBUILD: change arch to any as this is arch-indep.
* fake-hwclock.sh: add 'load' command that sets the system time only if
  the current time is older; make 'set' an deprecated alias of it.
* Add fake-hwclock-save timer and service that saves the time every 15
  minutes.
* install: suggest to enable timer unit instead of cron.
2014-05-25 13:21:30 +02:00

37 lines
581 B
Bash
Executable file

#!/bin/bash
THISFILE=$0
STATEFILE=$0
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
}
saveclock() {
echo "Saving current time."
touch "$STATEFILE"
}
case "$1" in
load)
loadclock
;;
set)
echo "'set' is deprecated, use 'load' instead."
echo "Consider using the systemd timer unit fake-hwclock-save.timer"
loadclock
;;
save)
saveclock
;;
*)
echo "Usage: $THISFILE {load|save}"
exit 1
;;
esac