FS#10287 - [initscripts] Making more live-system friendly
Attached to Project:
Arch Linux
Opened by Michael Towers (gradgrind) - Saturday, 26 April 2008, 10:40 GMT
Last edited by Thomas Bächler (brain0) - Monday, 07 February 2011, 08:10 GMT
Opened by Michael Towers (gradgrind) - Saturday, 26 April 2008, 10:40 GMT
Last edited by Thomas Bächler (brain0) - Monday, 07 February 2011, 08:10 GMT
|
Details
What do you think of this?
It would be possible to separate out certain bits of rc.sysinit and rc.shutdown into separate function files in /etc/rc.d/functions.d so that these bits can be easily replaced, say in the case of a 'live' system (I am of course primarily thinking of larch, but this approach might have other uses), without the present need to replace rc.sysinit and rc.shutdown. I've attached an example of how this could be done, by adding /etc/rc.d/functions.d/functions0 for rc.sysinit and /etc/rc.d/functions.d/functions1 for rc.shutdown. If I need different behaviour I can just add my own files to /etc/rc.d/functions.d which will be sourced after these, for example functions0-myversion and functions1-myversion. I've run quick tests on this (both normal install and larch live system) and it seems to work. |
This task depends upon
Closed by Thomas Bächler (brain0)
Monday, 07 February 2011, 08:10 GMT
Reason for closing: Fixed
Additional comments about closing: Time to close this. See FS#10536
for a followup.
Monday, 07 February 2011, 08:10 GMT
Reason for closing: Fixed
Additional comments about closing: Time to close this. See
Any thoughts on this?
I can imagine various ways of implementing something along these lines, but it would be nice to know if it's the sort of thing you'd like to support.
For example, it seems somehow cleaner to separate out those functions which are used in rc.shutdown from those for rc.sysinit (unless they are shared). I haven't done that so far as I wanted to keep the code alterations to a minimum. Also there would be the question of how much code to repackage as (importable) functions - just for live systems, or all of the more sizable chunks in the original scripts (clock/raid/lvm/filesystems/keyboard/...). I don't know if there would be other advantages apart from those for live systems, I'm not even sure if it would count as a simplification or a 'complification'!
Let me turn this request on its side a bit: why precisely do you need this? It is my opinion that you should be able to do anything in a live system via an additional rc.d script. I'm trying to figure out what customizations would cause you to need a refactoring such as this.
larch-sysinit (1.2 KiB)
rc.shutdown.larch (3.9 KiB)
larch-shutdown (1.1 KiB)
There are still one or two things that would be nice, though
- the ability to disable setting the hardware clock at shutdown (while still being able to load it at startup)
- some sort of hook to be able to insert code just before the final shutdown in /etc/rc.shutdown, e.g.
[ -f /etc/rc.shutdown.hook ] && . /etc/rc.shutdown.hook
We have some code to skip the clock when there's no clear setting in rc.conf, that could easily be extended by an extra option in rc.conf which causes it to always skip it.
Including more customizable hooks should be done via functions.d, which should be extended anyway to provide a few useful hooks in sysinit and shutdown.
From Kurt.J.Bosch:
I noticed one problem: Fbsplash is unable now to show the SIGTERM message since the daemon restarter is forked before the stat_busy.
[code]
run_hook shutdown_prekillall
# Terminate all processes
stat_busy "Sending SIGTERM To Processes"
[/code]
To fix this please move the run_hook *behind* the stat_busy in rc.shutdown and rc.single:
[code]
# Terminate all processes
stat_busy "Sending SIGTERM To Processes"
run_hook shutdown_prekillall
[/code]
This would also improve consistency since in rc.sysinit there is already:
[code]
stat_busy "Mounting Local Filesystems"
...
run_hook sysinit_premount
[/code]
Can I have comments on that please? It seems inconsistent, will it break anything?
Currently I have to duplicate the CONSOLEFONTS code from rc.sysinit into initscripts-extras-fbsplash to run it after the splash daemon is stopped because setfont destroys the splash screen.
Ideas to fix this:
- Move this code into a separate daemon scriptlet.
- Move this code into a function. (Patch against git provided.)
I'll think on this one
Thomas: To me the moved 'run_hook shutdown_prekillall' looks inconsistent only in the same way as the 'run_hook sysinit_premount' already does: It comes between stat_busy and stat_done. The only problem I can see with this is: The stat_done screen positions are messed up if a hook function calls stat_busy too. (Maybe I could live without this change simply adding a copy of the sigterm busy message to the fbsplash hook function.)
In the sysinit_premount case, it has to be in that place to do some extra business in the middle of our mounting code.
If not, maybe you could push this too:
0002-Add-support-for-the-fsck... (0.8 KiB)
I just noticed, all hooks are documented in comments in /etc/rc.d/functions, the new ones aren't now.
BTW: initscripts-extras-fbsplash made it to 1.0 now :)