blob: 9961d25562f00d2e8db5a6fc6fc5080b6977f0c4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#! /usr/bin/env 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
|