aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChloé Vulquin <code@toast.bunkerlabs.net>2026-02-07 22:19:38 +0100
committerChloé Vulquin <code@toast.bunkerlabs.net>2026-02-07 22:19:38 +0100
commit194aad96ca773469c3bcece845024f1388a58b67 (patch)
treeade883b3a75c46e3fccdfe5e28507907cc9adf6f
parentagetty@: add (diff)
runsvdir@: add
-rw-r--r--runsvdir@/README.md41
-rwxr-xr-xrunsvdir@/run11
2 files changed, 52 insertions, 0 deletions
diff --git a/runsvdir@/README.md b/runsvdir@/README.md
new file mode 100644
index 0000000..409f339
--- /dev/null
+++ b/runsvdir@/README.md
@@ -0,0 +1,41 @@
+# runsvdir@ : runit compatibility
+This is a transitional service so you can migrate to nitro one piece
+at a time. Under normal runit-init usage, /etc/runit/2 will exec into
+a runsvdir against your selected runlevel. This essentially does the
+same work, except the runlevel is selected by the @ target (you can
+select `current` to emulate typical runit setups).
+
+For example, here's what `pstree` looks like on an runit system:
+```
+runit───runsvdir─┬─runsv─┬─service1
+ │ └─logger
+ ├─runsv─┬─service2
+ │ └─logger
+ └─runsv─┬─service3
+ └─logger
+```
+
+A first step towards moving towards nitro can look like so: you swap
+out /sbin/init and /sbin/halt to nitroctl, setup the special SYS
+service, and then use this service as `runsvdir@default` (or
+`@current`). At this point, your `pstree` should look like this:
+
+```
+nitro───runsvdir─┬─runsv─┬─service1
+ │ └─logger
+ ├─runsv─┬─service2
+ │ └─logger
+ └─runsv─┬─service3
+ └─logger
+```
+
+At this point, you can freely control the system using both
+supervisors, picking which service to move over and when.
+
+This service pre-supposes that you are running Void Linux. If this is
+not the case, your runlevels may not be under
+`/etc/runit/runsvdir`. In that case, you will want to set `RUNSVDIR`
+to where your runlevels reside in `./conf`. If your runit setup does
+not use runlevels and only uses (for example) `/service` directly, you
+can set `RUNSVDIR` to the parent directory of your "runlevel". `/`
+should work.
diff --git a/runsvdir@/run b/runsvdir@/run
new file mode 100755
index 0000000..d92cf41
--- /dev/null
+++ b/runsvdir@/run
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+runlevel="$1"
+[ -f ./conf ] && . ./conf
+[ -f ./conf."$1" ] && . ./conf."$1"
+
+# set this in ./conf if your system keeps runlevels elsewhere
+: ${RUNSVDIR:=/etc/runit/runsvdir}
+[ -d "$RUNSVDIR/$runlevel" ] || runlevel=current
+
+exec runsvdir -P "$RUNSVDIR/$runlevel"