Create the following directories and symlinks:
# mkdir -p /etc/runit/runsvdir/default # mkdir -p /etc/runit/runsvdir/single # ln -s /etc/runit/getty-5 /etc/runit/runsvdir/single/getty-5 # ln -s default /etc/runit/runsvdir/currentCopy the content of /service/ to /etc/runit/runsvdir/current and replace /service with a symlink:
# cp -pR /service/* /etc/runit/runsvdir/current/ # mv -f /service /service.old && ln -s /etc/runit/runsvdir/current /serviceYou have now created two runlevels: default and single. The current runlevel is default. It is safe to remove /service.old if you don't need it anymore.
Finally edit /etc/runit/2 to set the default runlevel when stage 2 starts:
$ cat /etc/runit/2 #!/bin/sh PATH=/command:/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin runsvchdir default >/dev/null exec env - PATH=$PATH \ runsvdir /service 'log: ...........................................................................................................................................................................................................................................................................................................................................................................................................'
# runsvchdir singleTo switch back to the default runlevel, do:
# runsvchdir defaultSee the runsvdir program for a description of what happens when runsvdir sees the directory changed. Note that there is no guarantee that all services from the previous runlevel will stop, the runsv processes have sent the services a SIGTERM and wait for them to terminate. You can check the status of the previous runlevel in /etc/runit/runsvdir/previous/.
# mkdir /etc/runit/runsvdir/maintenanceAdd the services you want to run in the runlevel maintenance to the newly created directory, e.g.:
# ln -s /etc/runit/getty-5 /etc/runit/runsvdir/maintenance/ # ln -s /etc/runit/runsv/ssh /etc/runit/runsvdir/maintenance/ # ln -s /etc/runit/runsv/dnscache /etc/runit/runsvdir/maintenance/If you want to switch to the runlevel maintenance, do:
# runsvchdir maintenance