How OpenRC Works
Init needs a configuration file that specifies what actions need to be taken. This configuration file is /etc/inittab
init's first action is to mount all file systems. This is defined in the following line from /etc/inittab.
init's second action is to execute all scripts that had symbolic links in /etc/runlevels/boot/. This is defined in the following line from /etc/inittab.
init checks its configuration file to see what runlevel it should run. To decide this, it reads the following line from /etc/inittab.
In this casethe runlevel id is 3. Using this information, init checks what it must run to start runlevel 3.
l3:3:wait:/sbin/openrc default. The line that defines level 3, again, uses the openrc script to start the services (now with argument default)
init decides what virtual consoles it should activate and what commands need to be run at each console.
c1:12345:respawn:/sbin/agetty 38400 tty1 linux
c2:12345:respawn:/sbin/agetty 38400 tty2 linux
c3:12345:respawn:/sbin/agetty 38400 tty3 linux
c4:12345:respawn:/sbin/agetty 38400 tty4 linux
c5:12345:respawn:/sbin/agetty 38400 tty5 linux
c6:12345:respawn:/sbin/agetty 38400 tty6 linux
Working with initscripts
The scripts that the openrc process starts are called init scripts. Each script in /etc/init.d/ can be executed with the arguments start, stop, restart, zap, status, ineed, iuse, iwant, needsme, usesme, or wantsme.
Start a service
Stop a service, but not the services that depend on it
/etc/init.d/postfix --nodeps stop
See what status a service has
Ask what dependencies the service has
Ask what services require the service
Every init script that can be configured has a file in /etc/conf.d/. For instance, the apache2 initscript (called /etc/init.d/apache2) has a configuration file called /etc/conf.d/apache2, which can contain the options to give to the Apache 2 server when it is started. Such a configuration file contains only variables.
Replacing default runlevel
Add a new entry in the bootloader configuration for the desired runlevel. In that entry, add
softlevel=desired as a boot parameter.
Working with runlevel
Change to nonetwork runlevel
Change to default runlevel
Change to shutdown runlevel
Change to reboot runlevel
Show status info about runlevels
Locate and run an OpenRC service
rc-service service cmd [...]
rc-update add postfix default
rc-update del postfix default