OpenRC / openrc

The OpenRC init system
BSD 2-Clause "Simplified" License
1.48k stars 247 forks source link

openrc-init: provide last-minute shutdown hook #346

Open crabbedhaloablution opened 4 years ago

crabbedhaloablution commented 4 years ago

Provide a last-minute hook similar to /usr/lib/systemd/system-shutdown/, sitting after the shutdown runlevel, before physical poweroff.

Use-case: I have an (out of warranty) board that only turns off in a most peculiar way. First you have to write some special magic to a special device, then reboot. Upon reboot, firmware detects the magic, clears the special device and turns off the board. Having somewhere I can hook in and know whether it's a halt, poweroff or reboot that's happening would be very helpful.

udeved commented 4 years ago

@crabbedhaloablution

elogind provides this.

https://github.com/elogind/elogind

crabbedhaloablution commented 4 years ago

@udeved That's cool. I'll add the files for that. I'm puzzled how you can guarantee "Immediately before executing the actual system poweroff/reboot elogind will run all executables in /lib/elogind/system-shutdown" -- I thought elogind would be stopped at least after mount-ro. I still think it would be useful to have this functionality directly in openrc. Dbus and elogind is a bit much for the embedded world.

navi-desu commented 2 months ago

@crabbedhaloablution would adding a script/service to the shutdown runlevel with depend { after * } not suffice?