**What is OpenRC?** OpenRC is *a dependency-based init system for Unix-like operating systems.* > **What does OpenRC maintain?** > OpenRC maintains *compatibility with the system-provided init system.* > > **Where is the system-provided init system normally located?** > The system-provided init system is normally located *at `/sbin/init`.* > > **What is Gentoo's native init system?** > Gentoo's native init system is *OpenRC.* > > **Does Gentoo support other init systems besides OpenRC?** > > *Yes*, Gentoo supports other init systems besides OpenRC. **What three things does OpenRC do with necessary system services?** With necessary system services, OpenRC: 1. Starts them in the correct order at boot. 2. Manages them while the system is in use. 3. Stops them at shutdown. ... **What Linux distribution was OpenRC developed for?** The Linux distribution OpenRC was developed for was *Gentoo.* > **What can OpenRC be used on?** > OpenRC can be used on *other Linux distributions and BSD systems.* > > **What is OpenRC invoked by on Gentoo by default?** > By default, OpenRC is invoked by *sysvinit* on Gentoo. **What may need to be done for daemons installed from outside the Gentoo repository?** For daemons installed from outside the Gentoo repository, they may need to be *adapted to work with OpenRC.* # Implementation ... # Installation **Does OpenRC generally need to be installed manually and why?** *No*, OpenRC generally doesn't need to be installed manually *because it's provided as part of an OpenRC profile on installation.* ... # USE flags > [!todo] > This section includes all of the compatible USE flags for OpenRC. **What can you do if the USE flags for OpenRC are changed?** If the USE flags for OpenRC are changed, you can *rebuild the package to apply them.* > **How is OpenRC pulled in for OpenRC profiles?** > For OpenRC profiles, OpenRC is pulled in *as a dependency of `virtual/service-manager`.* > > **Should OpenRC ever be added to the selected-packages set (`/var/lib/portage/world` file)?** > *No*, OpenRC should never be added to the selected-packages set (`/var/lib/portage/world`). > > **How do you emerge OpenRC without adding it to the selected-packages set (`/var/lib/portage/world`)?** > > To emerge OpenRC without adding it to the selected-packages set (`/var/lib/portage/world`), *run:* > > ```bash > > $ emerge --ask --oneshot sys-apps/portage > > ``` # Files **What two places stores the configuration for OpenRC?** The two places which store the configuration for OpenRC are: 1. `/etc/rc.conf` - Global OpenRC configuration file. 2. `/etc/conf.d` - Contains configuration files for individual initscripts. # Logging **Does OpenRC log anything by default?** *No*, OpenRC doesn't log anything by default. > **How do enable logging for OpenRC?** > To enable logging for OpenRC, *uncomment and set the `rc_logger` option in `/etc/rc.conf` to `"YES"`.* > > **Where is the log for OpenRC saved to by default?** > By default, the log for OpenRC is saved to *`/var/log/rc.log`.* # Network management ... # Dependency behavior ... > [!example] Example of changing the `net` dependency of `sshd` to depend on `net.eth0` > ```bash > # /etc/conf.d/sshd > rc_need="!net net.eth0" > ``` > [!example] Example of changing the `net` dependency of `sshd` so that it depends on `net.eth0` in the "default" runlevel and `wlan0` in the "office" runlevel > ```bash > $ ln -s sshd /etc/init.d/sshd.eth0 > $ ln -s sshd /etc/init.d/sshd.wlan0 > $ cp /etc/conf.d/sshd /etc/conf.d/sshd.eth0 > $ cp /etc/conf.d/sshd /etc/conf.d/sshd.wlan0 > $ echo 'rc_need="!net net.eth0"' >> /etc/conf.d/sshd.eth0 > $ echo 'rc_need="!net net.wlan0"' >> /etc/conf.d/sshd.wlan0 > $ rc-update add sshd.eth0 default > $ rc-update add sshd.wlan0 office > $ rc-update add net.eth0 default office > $ rc-update add net.wlan0 default office > ``` **What's the best way to switch between runlevels with different network configurations without rebooting?** The best way to switch between runlevels with different network configurations without rebooting is *to change to the "nonetwork" runlevel before the desired runlevel.* > [!example] Examples of switching between the "default" runlevel and the "office" runlevel > ```bash > $ openrc nonetwork && openrc office > $ openrc nonetwork && openrc default > ``` # Selecting a specific runlevel at boot **What does OpenRC read at boot time to determine which runlevel to start?** To determine which runlevel to start, OpenRC reads *the kernel command-line* at boot time. > **What kernel parameter does OpenRC check to determine which runlevel to start?** > The kernel parameter that OpenRC checks to determine which runlevel to start is *the `softlevel` parameter.* > > **What runlevel does OpenRC start if no `softlevel` kernel parameter is provided?** > If no `softlevel` kernel parameter is provided, OpenRC starts *the "default" runlevel.* # Runlevels **What three commands are used to control and configure OpenRC?** The three commands used to control and configure OpenRC are: 1. `openrc`. 2. `rc-update`. 3. `rc-status`. > [!example] Example of deleting `sshd` from the "default" runlevel > ```bash > $ rc-update delete sshd default > ``` # Listing **Do you need root permissions to list runlevels and services assigned to them?** *No*, you don't need root permissions to list runlevels and services assigned to them. > **How do you display all available initscripts and their current runlevel including ones without a runlevel?** > To display all available initscripts and their current runlevel including ones without a runlevel, *run:* > ```bash > $ rc-update show -v > ``` > > **How do you display all available initscripts and their current runlevel?** > To display all available initscripts and their current runlevel, *run:* > ```bash > $ rc-update [show] > ``` > > **How do you view the state of all services?** > To view the state of all services, *run either:* > ```bash > $ rc-status -s > $ rc-status --servicelist > ``` # Named runlevels **How are OpenRC runlevels implemented?** OpenRC runlevels are implemented *as directories in `/etc/runlevels/`.* > [!example] Example of creating a new runlevel called "office" > ```bash > $ install -d /etc/runlevels/office > ``` **Why are additional runlevels helpful?** Additional runlevels are helpful *because they provide alternative system start-up profiles.* # Stacked runlevels **What are stacked or dependent runlevels?** Stacked or dependent runlevels are *runlevels which inherit the actions of one or more other runlevels.* > **What command is used to create a stacked runlevel?** > The command used to create a stacked runlevel is: > ```bash > $ rc-update -s > ``` > > **What happens when a target runlevel is started or stopped?** > When a target runlevel is started or stopped, *any stacked runlevels are also started or stopped.* > [!todo] Todo [(1)](https://wiki.gentoo.org/wiki/OpenRC/Stacked_runlevel) > This section has a link to an example of setting up a stacked runlevel to group networking services based on location on a laptop. # Prefix **What is Gentoo Prefix?** [(1)](https://wiki.gentoo.org/wiki/Project:Prefix) Gentoo Prefix is *a project which develops and maintains a way to install Gentoo in a non-standard location designated by a prefix.* ... # Hotplug **Can OpenRC be triggered by external events?** *Yes*, OpenRC can be triggered by external events. > **What configuration setting controls what services are allowed to be hotplugged?** > The configuration setting which controls what services are allowed to be hotplugged is *`rc_hotplug`.* > > **What is a hotplugged service?** > A hotplugged service is *a service started by a dynamic dev manager.* > > **When does a hotplugged service start?** > > A hotplugged service starts *when a matching hardware device is found.* > > > > **What runlevel do hotplugged services appear in?** > > The runlevel hotplugged services appear in is *the "hotplugged" runlevel.* > > > > > [!example] Example of allowing `net.wlan` and any service not matching `net.*` to be hotplugged > > > ```bash > > > # /etc/rc.conf > > > rc_hotplug="net.wlan !net.*" > > > ``` # CGroups support **Does OpenRC support control groups (cgroups)?** *Yes*, OpenRC supports cgroups. # Chroot support ... # logind **What's a suitable replacement for systemd-logind for OpenRC?** A suitable replacement for systemd-logind for OpenRC is *elogind.* # tmpfiles.d ... # udev and mdev **What are udev and mdev?** Udev and mdev are *systems to manage `/dev/`.* > **What package provides udev for OpenRC?** > The package which provides udev for OpenRC is *`sys-apps/systemd-utils[udev]`.* ... # BusyBox integration > [!todo] > This section provides some information about using OpenRC with BusyBox. # Respawning crashed services ... # Manually recovering crashed services ...