Hi,

On Wed, 26 Oct 2022 14:05:48 +0200
Andras Korn <korn-debb...@elan.rulez.org> wrote:

> Package: runit
> Version: 2.1.2-50
> Severity: minor
> Tags: patch
> 
> Hi,
> 
> I'm not satisfied with this bit from /etc/runit/1:
> 
> --- 8< ---
> if [ -f /etc/runit/native.boot.run ] || [ -n "$bootrun" ]; then
>       bootrun=1
> fi
> 
> if [ -d /etc/runit/boot-run ] && [ ! -z $bootrun ]; then
>       for f in /etc/runit/boot-run/*.sh; do
>               [ -r "$f" ] && . "$f"
>       done
> else
>       /lib/runit/run_sysv_scripts '/etc/rcS.d'
> fi
> 
> --- >8 ---
> 
> On the one hand, '-z $bootrun' looks like an accident waiting to
> happen due to the missing quotes around "$bootrun". On the other, '[
> ! -z "$bootrun" ]' and '[ -n "$bootrun ]' mean the same thing, so why
> do it two different ways within five lines?

I guess late night experimenting has drawbacks, and I'm taking too
seriously the advice to not use test -a or -o from the test man page...

> 
> Furthermore, the two ifs seem redundant; I think the code would be
> more succinct and more readable the following way:
> 
> --- 8< ---
> 
> if [ -f /etc/runit/native.boot.run -o -n "$bootrun" ] && [ -d
> /etc/runit/boot-run ]; then bootrun=1 # set this because
> sourced scripts might use it, I guess (although they wouldn't get run
> if bootrun weren't set, so setting bootrun=1 looks completely
> superfluous) for f in /etc/runit/boot-run/*.sh; do [ -r "$f" ] && .
> "$f" done else
>       /lib/runit/run_sysv_scripts '/etc/rcS.d'
> fi
> 
> --- >8 ---
> 
> I think this is equivalent with the exception that it only sets
> bootrun=1 if the /etc/runit/boot-run directory exists; but since
> nothing in the original script uses $bootrun, this doesn't seem to
> matter (and, as noted above, setting bootrun=1 seems completely
> redundant).

The only thing that I want to achieve here is:

1) have a way to boot with an alternative set of boot scripts by
setting 'bootrun' with GRUB, so that if something goes wrong it's
possible to reboot with initscripts

2) a permanent way (the flag file) to use an alternative set of
bootscripts, when one is satisfied with 1)

Your patch looks fine to me, I'm applying in the next upload.
Thank you

Lorenzo

> 
> AndrĂ¡s
> 

Reply via email to