Skip to content

Check for save file's availability in init.d/swclock - #1094

Open
meoovv wants to merge 1 commit into
OpenRC:masterfrom
meoovv:service-swclock
Open

meoovv wants to merge 1 commit into
OpenRC:masterfrom
meoovv:service-swclock

Conversation

@meoovv

@meoovv meoovv commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

closes #989

rc-service swclock status
 * status: stopped
alpine:~# rc-service swclock start
 * Caching service dependencies ... [ ok ]
 * Setting the local clock based on last shutdown time ...
 * swclock: `/var/lib/misc/openrc-shutdowntime': No such file or directory [ ok ]
alpine:~# rc-service swclock stop
 * Saving the shutdown time ...
 * /var/lib/misc/openrc-shutdowntime: creating [ ok ]

service declares use bootmisc to ensure that /var/lib/misc exists. since bootmisc depends on localmount, the case described in the mentioned issue should no longer be possible.
if save file does not exist, checkpath is called to create it. if its parent directory is missing, service reports “no such file” error.

Comment thread init.d/swclock.in Outdated
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 "${swclock_file}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems wrong. it's a fallback for when the swclock file doesn't exist, thus comparing against a known-existent file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but whats the point? it makes script succeed everytime it starts

@navi-desu navi-desu Sep 28, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the point is to set a system time that is closer to now than january 1st, 1970

aka it's a fallback, for a reason

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be appropriate to mention this in einfo?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

swclock will print out an error for the first failed try already

we could additionally add ewarn "Falling back to @BINDIR@/openrc-run as clock reference" or something, i have no issue with that

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

swclock will print out an error for the first failed try already

seems like it wont? service just starts successfully for me when fallback file exists.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the service will start successfully, yes, and this is required so that first-boot on sw clock doesn't always trigger a failure

it will print out a message with eerrorx, that can be seen either on the console, or by setting rc_logger in /etc/rc.conf

@navi-desu

Copy link
Copy Markdown
Member

we could move this to /var/lib/rc which we're already using for the deptree cache

also please rebase your commits, this doesn't have to be more than one commit, much less have a revert commit on it

@meoovv
meoovv force-pushed the service-swclock branch 2 times, most recently from b1af9fe to 9fda18a Compare September 28, 2026 14:40
Comment thread init.d/swclock.in Outdated
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 "@SBINDIR/openrc-run"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduces a typo:

Suggested change
swclock --warn "@SBINDIR/openrc-run"
swclock --warn "@SBINDIR@/openrc-run"

@thesamesam

Copy link
Copy Markdown
Contributor

Please use a real email address as git author, not meow@localhost.

@meoovv
meoovv force-pushed the service-swclock branch 2 times, most recently from 78e5713 to ac9414a Compare September 28, 2026 15:03
@meoovv

meoovv commented Sep 28, 2026

Copy link
Copy Markdown
Contributor Author

service should not fail if the second swclock call fails, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

swclock does not show read/write errors

3 participants