aboutsummaryrefslogtreecommitdiff
path: root/services
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-07-22 20:55:34 +0200
committerDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-07-22 21:38:14 +0200
commitc3249ae0c9777e8d16c90ce1ca441e90ad4fcf7b (patch)
tree314681ced1099af8e0b6c1c85e33a56eb5efeb51 /services
parent056d3c8e6481088b8e5d9791d8c1762a3c8d1a83 (diff)
Add swclock service for systems without a hardware RTC
Some systems don't have a hardware real time clock and don't know the time after bootin. An obvious soulution for this is to use time from an ntp server. Unfortunately that requires domain name resolution, which resolvers like unbound won't do for us, if the DNSSEC certificates aren't valid, which they aren't if we start out with a time around 1970-1-1. The "software clock" service tries to provide a workaround by restoring a reasonably valid time from a backup file during boot, which we update when shuting down. If we wan't a more correct time, we have to update it from NTP in between. Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
Diffstat (limited to 'services')
-rw-r--r--services/Makemodule.am3
-rw-r--r--services/swclock.in6
-rw-r--r--services/swclocksave.in7
3 files changed, 15 insertions, 1 deletions
diff --git a/services/Makemodule.am b/services/Makemodule.am
index 8f22675..3625715 100644
--- a/services/Makemodule.am
+++ b/services/Makemodule.am
@@ -7,7 +7,8 @@ init_DATA += services/sysfs services/procfs services/tmpfs
init_DATA += services/vfs services/ifrename services/ifcfg
init_DATA += services/dhcpcd services/dhcpcdmaster services/unbound
init_DATA += services/dnsmasq services/ifdown services/modules
-init_DATA += services/network services/hostapd
+init_DATA += services/network services/hostapd services/swclock
+init_DATA += services/swclocksave
if USYSLOGD
init_DATA += services/usyslogd
diff --git a/services/swclock.in b/services/swclock.in
new file mode 100644
index 0000000..02c4c27
--- /dev/null
+++ b/services/swclock.in
@@ -0,0 +1,6 @@
+description restore saved time from last shutdown
+type wait
+target boot
+before sysinit
+after vfs modules
+exec xargs -a @STATEFILESPATH@/swclock date --utc
diff --git a/services/swclocksave.in b/services/swclocksave.in
new file mode 100644
index 0000000..683ded7
--- /dev/null
+++ b/services/swclocksave.in
@@ -0,0 +1,7 @@
+description write current time to backup file
+type wait
+target %0
+after sigkill
+before sync
+tty truncate @STATEFILESPATH@/swclock
+exec date --utc +%%m%%d%%H%%M%%Y.%%S