From ac9414ab023bd31a004bf64fb99419c72ac8d743 Mon Sep 17 00:00:00 2001 From: meow Date: Mon, 15 Jun 2026 05:34:35 +1200 Subject: [PATCH] Check for save file's availability in init.d/swclock --- init.d/swclock.in | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/init.d/swclock.in b/init.d/swclock.in index 2d7187ba2..08b1d2c7c 100644 --- a/init.d/swclock.in +++ b/init.d/swclock.in @@ -15,6 +15,7 @@ swclock_file="${swclock_file:-/var/lib/misc/openrc-shutdowntime}" depend() { provide clock + use bootmisc keyword -docker -podman -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu -wsl } @@ -22,9 +23,12 @@ depend() start() { + local fallback_file="@SBINDIR@/openrc-run" + ebegin "Setting the local clock based on last shutdown time" if ! swclock "${swclock_file}" 2> /dev/null; then - swclock --warn @SBINDIR@/openrc-run + swclock --warn "${fallback_file}" + ewarn "Falling back to ${fallback_file} as clock reference" fi eend $? } @@ -32,6 +36,7 @@ start() stop() { ebegin "Saving the shutdown time" + checkpath -f -W -o root:root -m 0644 "${swclock_file}" swclock --save "${swclock_file}" eend $? }