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
Task Type Feature Request
Category Packages: Core
Status Closed
Assigned To Aaron Griffin (phrakture)
Thomas Bächler (brain0)
Architecture All
Severity Low
Priority Normal
Reported Version 2007.08-2
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

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.
Comment by Michael Towers (gradgrind) - Friday, 02 May 2008, 08:54 GMT
Hi Aaron,

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'!

Comment by Gavin Bisesi (Daenyth) - Thursday, 11 December 2008, 18:28 GMT
Status?
Comment by Aaron Griffin (phrakture) - Thursday, 11 December 2008, 18:36 GMT
Sorry, forgot about this one.

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.
Comment by Michael Towers (gradgrind) - Friday, 12 December 2008, 11:50 GMT
Probably it's best if you have a look at the customizations I'm using at the moment. It may be possible to move some of them out of rc.sysinit/rc.shutdown, but that seems to me, given the present structure, the place where most of them should be. Maybe you have better suggestions. The main things at startup seem to be the handling of the remounting of the root file system and /etc/mtab, then the automatic generation of /etc/fstab. At shutdown the system time is not set, and various extra bits of code connected with 'session saving' (rewriting the aufs overlays) are introduced - which should be run as late as possible, i.e. after all activity has basically stopped. A CD will also be ejected.
Comment by Michael Towers (gradgrind) - Wednesday, 19 August 2009, 13:12 GMT
Things move on and I think there are now no insuperable problems for live systems with the initscripts.

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
Comment by Thomas Bächler (brain0) - Wednesday, 19 August 2009, 13:37 GMT
Please, send patches against our current git (I can't put too much time in this right now, but will apply a patch if I consider it clean and working).

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.
Comment by Aaron Griffin (phrakture) - Friday, 04 September 2009, 20:27 GMT
Can this be closed now that we have the hook system in git?
Comment by Thomas Bächler (brain0) - Friday, 04 September 2009, 20:47 GMT
Although Michael seems to be happy with the system, changes have been requested to the system from the fbsplash-side, I'll add the email here:

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?
Comment by kujub (kujub) - Sunday, 06 September 2009, 08:52 GMT
... and may I add this also outstanding one:
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.)
Comment by Aaron Griffin (phrakture) - Thursday, 24 September 2009, 21:54 GMT
Hrm, I don't know how to handle this one. It's a little tricky to Do It Right(TM), but I don't like this patch.

I'll think on this one
Comment by kujub (kujub) - Sunday, 08 November 2009, 22:57 GMT
Aaron: Did you find a better way to get rid of the setfont code duplication ?

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.)

Comment by Thomas Bächler (brain0) - Tuesday, 10 November 2009, 12:37 GMT
Kurt, you are correct here. However, I think larch wants to call stat_busy here (not sure though, Michael?). Maybe we should make this two hooks? As Arch won't use these hooks internally, I am happy to put whatever you want there.

In the sysinit_premount case, it has to be in that place to do some extra business in the middle of our mounting code.
Comment by Michael Towers (gradgrind) - Tuesday, 10 November 2009, 13:42 GMT
larch doesn't use 'shutdown_prekillall' at the moment, so it won't bother me where you put it!
Comment by kujub (kujub) - Tuesday, 26 January 2010, 12:46 GMT
I'm currently preparing initscripts-extras-fbsplash to work with single-user mode, so here comes another patch ;-)
Comment by Thomas Bächler (brain0) - Tuesday, 26 January 2010, 12:59 GMT
Pushed, thanks.
Comment by kujub (kujub) - Thursday, 28 January 2010, 09:51 GMT
Is there any reason why rc.single does not Always shutdown daemons, regardless of runlevel like rc.shutdown, but only if prevlevel [35] ?
If not, maybe you could push this too:
Comment by Thomas Bächler (brain0) - Thursday, 28 January 2010, 09:59 GMT
I guess this last one makes sense. Aaron?
Comment by kujub (kujub) - Sunday, 14 February 2010, 19:45 GMT
Here comes another one: Add support for the fsck progress file descriptor to rc.sysinit. This allows to update the status line of a splash screen during fsck like so: "Checking Filesystem 'MyPartition': Phase 1 33%"
Comment by Thomas Bächler (brain0) - Sunday, 14 February 2010, 21:18 GMT
Kurt, thank you, this looks good. Would you mind re-sending the last two patches as git formatted patches with good commit messages? This way, we can retain authorship of the patch more easily and transparently.
Comment by kujub (kujub) - Monday, 15 February 2010, 14:43 GMT
First time trying to do so...
Comment by Thomas Bächler (brain0) - Monday, 15 February 2010, 15:09 GMT
Perfect. Applied here: http://projects.archlinux.org/initscripts.git/

I just noticed, all hooks are documented in comments in /etc/rc.d/functions, the new ones aren't now.
Comment by kujub (kujub) - Tuesday, 16 February 2010, 21:19 GMT
Hmm, this one would fix a small glitch... :)
Comment by Thomas Bächler (brain0) - Tuesday, 16 February 2010, 21:30 GMT
Applied.
Comment by kujub (kujub) - Tuesday, 16 February 2010, 21:45 GMT
Thanks. Do you think we should do something about the CONSOLEFONT part? I still have this duplicated in initscripts-extras-fbsplash because it isn't callable in initscripts and it destroys the splash screen if not deferred. So maybe this should be moved into /etc/rc.d/consolefont?
Comment by Thomas Bächler (brain0) - Tuesday, 16 February 2010, 22:04 GMT
Looks good I guess, just the function name sort of bothers me.
Comment by kujub (kujub) - Tuesday, 16 February 2010, 22:07 GMT
If you talk about setfont_function.patch: this one won't work - we would need to move the function into /etc/rc.d/functions.
Comment by Thomas Bächler (brain0) - Tuesday, 16 February 2010, 22:10 GMT
Looking at the patch, it IS in rc.d/functions.
Comment by kujub (kujub) - Tuesday, 16 February 2010, 22:13 GMT
Wow, may fault was thinking I made a fault. LOL What function name would you prefer then?
Comment by Thomas Bächler (brain0) - Tuesday, 16 February 2010, 22:20 GMT
"maybe_setfont" is a weird name, something like "set_consolefont" would be more straightforward.
Comment by kujub (kujub) - Tuesday, 16 February 2010, 22:21 GMT
OK...
Comment by kujub (kujub) - Tuesday, 16 February 2010, 22:48 GMT
Updated patch reflecting git changes too:
Comment by kujub (kujub) - Thursday, 18 February 2010, 10:31 GMT
I think some additional hooks in the stat- and daemon-functions would make sense. This way we could eliminate any need to override those functions and avoid conflicts if two or more custom/extra script sets are used. Also this eliminates the remaining need of duplicated code. (This time I even added the explanation lines. :) Any comments?
Comment by kujub (kujub) - Wednesday, 24 February 2010, 21:28 GMT
[PATCH] Provide daemon script exit codes for post_daemon hooks
Comment by kujub (kujub) - Wednesday, 03 March 2010, 16:57 GMT
Currently we have to use some ugly backgrounded sub-shell hack to be able to restart a splash daemon after SIGTERM. This tiny patch would solve this.
BTW: initscripts-extras-fbsplash made it to 1.0 now :)
Comment by Glenn Matthys (RedShift) - Monday, 15 November 2010, 11:03 GMT
Please close this issue, the install CD is a liveCD.

Loading...