SysV + RC
A BSD-style init based on SysVinit as PID 1. RC is a set of simple shell scripts, with no dependency handling, that start, stop, or restart the daemon: the boot order of services is entirely up to you. With SysVinit + RC there's no service supervision.
| File | Purpose |
|---|---|
/etc/rc |
Main boot script, executed by /sbin/init. |
/etc/rc.conf |
Clock, timezone, keymap, console font, and the list of daemons to start. |
/etc/rc.d/ |
Directory holding each service's script. |
/etc/rc.local |
Extra commands run at the end of multi-user boot. |
/etc/rc.shutdown |
Script executed on shutdown. |
/etc/rc.subr |
Shared functions used by the scripts in /etc/rc.d/. |
Managing services
Each service is controlled directly through its script in /etc/rc.d/:
# /etc/rc.d/networkmanager start
# /etc/rc.d/networkmanager restart
# /etc/rc.d/networkmanager stop
To have a service start with the system, add it to the DAEMONS variable in
/etc/rc.conf, in the order you want it to start.
Writing a service
A service script only needs to source /etc/rc.subr and use its
functions. Minimal example:
#!/bin/sh
. /etc/rc.subr
case $1 in
start)
msg "Starting daemon..."
start_daemon /usr/bin/myprogram
;;
stop)
msg "Stopping daemon..."
stop_daemon /usr/bin/myprogram
;;
restart)
$0 stop
sleep 1
$0 start
;;
status)
status_daemon /usr/bin/myprogram
;;
*)
echo "usage: $0 [start|stop|restart|status]"
;;
esac
Save the script in /etc/rc.d/ with execute permissions (chmod +x) and
it's ready to be controlled with start/stop/restart/status.
Runit
A minimalist process supervision suite. Each service runs in a clean process environment regardless of how it was started or restarted, and gets its own log for as long as the service stays up.
Service layout
Each service lives in a directory with a single required file, run, which execs
the process in the foreground. It may optionally include:
check— checks whether the service is available.finish— runs when the service stops.conf— environment variables used byrun.log/— subdirectory with its ownrunto receive the service's output.
Managing services
Active services are symlinks inside /var/service/:
# sv up <service>
# sv down <service>
# sv restart <service>
# sv status <service>
Enabling a service
# ln -s /etc/sv/<service> /var/service/
This starts the service immediately; runit will restart it if it dies and bring it back up on every boot.
Disabling a service
# rm /var/service/<service>
If you just want to stop a service from starting at boot without removing it from
supervision, create a down file inside its service directory:
# touch /etc/sv/<service>/down
s6
A process supervision suite that, together with s6-rc (service management) and
s6-linux-init (system startup), makes up the full init. s6-svscan
acts as PID 1 and supervises the entire process tree.
Bundles
Services are grouped into bundles: collections of daemons (longrun),
one-off tasks (oneshot), and even other bundles. The default bundle
is the one started on a normal system, and it in turn includes boot, with the
essential startup tasks.
Managing services
# s6 live start <service>
# s6 live stop <service>
# s6 process restart <service>
# s6 live status
Enabling or disabling at boot
# s6 set enable <service>
# s6 set disable <service>
# s6 set commit
# s6 live install
commit and install are required for the change to persist across
reboots. If you've added or modified service definitions, sync first with
s6 repo sync.
Each starkOS rootfs ships with a single init pre-installed; they aren't mixed together. To switch init systems, you'll need to reinstall with the corresponding rootfs (see Downloads).