:: Re: [DNG] Migrating initscripts to …
Top Page
Delete this message
Reply to this message
Author: Nick
Date:  
To: dng
Subject: Re: [DNG] Migrating initscripts to pure runit
On 8/18/26 10:00 AM, aitor wrote:
> Hi,
>
> I recently migrated sysv-rc to pure OpenRC by building a new debhelper
> utility dh-openrc similar to the already existent dh-runit.
> You can test it in the latest genuen iso images. I'm doing the same
> with runit right now.
>
> One interesting discovery has been that, for one-shot services (the
> opposite of long-running instances) you can use the trick of
>
>    exec sv -v pause .
>
> at the end of the `run` script. For example:
>
> / ********  BEGIN ***********/
>
> #!/usr/bin/env /lib/runit/invoke-run
> set -eu
>
> i=0
> while [ $i -lt 200 ]; do
>   [ -S /run/udev/control ] && break
>   sleep 0.1
>   i=$((i+1))
> done
>
> [ -S /run/udev/control ] || exit 1
>
> sleep 0.3
>
> vdevadm trigger -s misc -a add || true
> vdevadm trigger -s platform -a add || true
>
> vdevadm settle
>
> # Oneshot: no re-run in loop
> exec sv -v pause .
>
> /******* END *********/
>
>
> Disclaimer: currently udevadm is a symlink to vdevadm in genuen, and
> supports several of its features (like vdevadm settle).
> The existance of the `/run/udev/control` socket is necessary for the
> proper functioning of gparted:
>
> https://dev1galaxy.org/viewtopic.php?id=8052&p=2
> <https://dev1galaxy.org/viewtopic.php?id=8052&p=2>
> It means that a long-running instance of vdev is already running.
> Otherwise `vdevadm trigger` wouldn't work.
>
> Cheers,
>
> Aitor.
>

Interesting. The way I create oneshot services now is by at the end of
the script by creating a file 'down' in the service directory next to
the 'run' file. That way it will not restart until you remove the 'down'
file.

For real one time only services you can of course use phase 1 of runit init.