On Sun, Jan 02, 2022 at 11:45:27PM +0100, Lorenzo wrote: Hi,
> > I'd argue that introducing stricter requirements on the existence and > > correct mode of /run/runit.reboot that apply over the whole uptime of > > the system is a more dangerous and invasive change than introducing a > > new control file with semantics that are obvious and well defined > > from the beginning. > > > >[ ...] > > The problem with this is that runit hasn't so far cared about the > > mode of runit.reboot before stage 3, and people may set runit.reboot > > to mode 100 early, for example out of a desire to make sure a box > > will reboot instead of shut down if pid 1 were to receive a CONT > > signal for any reason. > > Didn't thought about that: I'm not sure is a good idea but I'll > let the local admin have that call. > So I'm going with flag files, runit.runlevel.$LAST as you suggested > in your first message. Thanks, but that's not quite what I suggested. :) You now have two flag files and unconditinally use /lib/runit.runlevel.6 first if it exists, even if /lib/runit.runlevel.0 also exists and is newer. If you want one flag file per runlevel, I'd suggest something like #!/bin/sh ls -t /lib/runit.runlevel.[0-9] 2>/dev/null \ | sed 's@.*/@@g;s/^runit\.runlevel\.//;/^[0-9S]$/!d' \ | while read level; do exec printf "N $level" done exec printf 'N 2' (The ugly sed command makes sure we only print numbers even if some joker creates a file called literally '/lib/runit.runlevel.[0-9]'. The while loop makes sure we only execute the first printf if there was actually something to read.) I'm not sure this is better than using the first character of the contents of /lib/runit.runlevel, or making it a symlink instead of a file and using the first character of its target (we can also implement the former without depending on head(1)). (FWIW, I think the technically correct solution would be to have a "runit runlevel daemon": a simple process that provides a fifo to read the current runlevel from, and another fifo to write into when the runlevel changes; but this is overkill as the concept of a 'runlevel' is very rarely needed.) Best regards, AndrĂ¡s -- Aunt Em. Hate Kansas. Hate you. Took dog. Dorothy.