Package: runit-init Version: 2.1.2-43 Severity: normal Tags: patch upstream
Hi, currently /sbin/runlevel always prints "2 N", which is fine most of the time. However, runit can invoke initscripts that change behaviour based on runlevel; for example, the kexec initscript from the kexec package has this: if [ -d /run/systemd/system ]; then systemctl list-jobs systemd-kexec.service | grep -q systemd-kexec.service if [ $? -ne 0 ]; then exit 0 fi else if [ -x /sbin/runlevel -a "$(runlevel | awk '{ print $2 }')" != "6" ]; then exit 0 fi fi This means that when /etc/runit/3 invokes /etc/rc6.d/K??kexec, the initscript will just exit instead of performing a kexec(8) and you end up with a plain reboot. If /sbin/runlevel looked like this instead: #!/bin/sh # This only does anything useful if /etc/runit/3 updates /run/runit.runlevel before starting stop scripts if [ -s /run/runit.runlevel ]; then CURLEVEL="$(head -c 1 /run/runit.runlevel)" else CURLEVEL=2 fi exec printf "N $CURLEVEL" And the following patch were applied to /etc/runit/3: --- a/3 2021-12-28 15:03:01.179691038 +0100 +++ b/3 2021-12-28 15:03:30.266943564 +0100 @@ -9,6 +9,7 @@ # executable bit set on 'noexec' filesystem as executable, and /run # often is mounted as 'noexec'. [ $(stat -c %a /run/runit.reboot) = 100 ] && LAST=6 +printf "$LAST" >/run/runit.runlevel echo 'Waiting for services to stop...' sv force-stop /etc/service/* Then the kexec package would work. If you're willing to accept this patch I can also update the runlevel(8) manpage. I'm also fine with /etc/runit/3 creating /run/runit.runlevel.$LAST and /sbin/runlevel checking for those in some order (this would avoid calling head(1) in /sbin/runlevel), if you prefer. AndrĂ¡s Ps. incidentally, happy new year! -- System Information: Architecture: amd64 (x86_64) Init: runit (via /run/runit.stopit) -- I'm sure if Vimes were to say 'Jump!', Detritus would say 'What colour?'