Skip to content

Commit

Permalink
make the location of the swclock reference file configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
williamh committed Dec 7, 2022
1 parent dd56735 commit 7aaf647
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions conf.d/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ conf_common = [
'localmount',
'netmount',
'swap',
'swclock',
]

conf_net = [
Expand Down
6 changes: 6 additions & 0 deletions conf.d/swclock
Original file line number Diff line number Diff line change
@@ -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
5 changes: 3 additions & 2 deletions init.d/swclock.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# except according to the terms contained in the LICENSE file.

description="Sets the local clock to the mtime of a given file."
swclock_file="${swclock_file:-/var/lib/misc/openrc-shutdowntime}"

depend()
{
Expand All @@ -22,7 +23,7 @@ depend()
start()
{
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
fi
eend $?
Expand All @@ -31,6 +32,6 @@ start()
stop()
{
ebegin "Saving the shutdown time"
swclock --save
swclock --save ${swclock_file}
eend $?
}

0 comments on commit 7aaf647

Please sign in to comment.