make the location of the swclock reference file configurable

This fixes #565.
This commit is contained in:
William Hubbs 2022-12-08 09:56:40 -06:00
parent 1364e6631c
commit 839083bb52
3 changed files with 10 additions and 2 deletions

View File

@ -7,6 +7,7 @@ conf_common = [
'localmount', 'localmount',
'netmount', 'netmount',
'swap', 'swap',
'swclock',
] ]
conf_net = [ conf_net = [

6
conf.d/swclock Normal file
View File

@ -0,0 +1,6 @@
# This is the location of the reference file swclock uses to set the
# system date and time.
# This is the default path. If you are using it, you do not need to
# uncomment it. If you are using the default and have /var on its own
# file system, you need to add the appropriate rc_after setting.
# swclock_file=/var/lib/misc/openrc-shutdowntime

View File

@ -10,6 +10,7 @@
# except according to the terms contained in the LICENSE file. # except according to the terms contained in the LICENSE file.
description="Sets the local clock to the mtime of a given file." description="Sets the local clock to the mtime of a given file."
swclock_file="${swclock_file:-/var/lib/misc/openrc-shutdowntime}"
depend() depend()
{ {
@ -22,7 +23,7 @@ depend()
start() start()
{ {
ebegin "Setting the local clock based on last shutdown time" ebegin "Setting the local clock based on last shutdown time"
if ! swclock 2> /dev/null; then if ! swclock "${swclock_file}" 2> /dev/null; then
swclock --warn @SBINDIR@/openrc-run swclock --warn @SBINDIR@/openrc-run
fi fi
eend $? eend $?
@ -31,6 +32,6 @@ start()
stop() stop()
{ {
ebegin "Saving the shutdown time" ebegin "Saving the shutdown time"
swclock --save swclock --save "${swclock_file}"
eend $? eend $?
} }