8.85. OpenRC-0.63

The OpenRC package contains programs for controlling the startup, running, and shutdown of the system.

Approximate build time: 0.1 SBU
Required disk space: 13 MB

8.85.1. Installation of OpenRC

Fix a script to allow a normal installation:

sed -i '/set -u/d' tools/meson_final.sh

Prepare OpenRC for compilation:

mkdir build
cd    build

meson setup --prefix=/usr       \
            --buildtype=release \
            -D pam=false ..

The meaning of the configure options:

-D pam=false

This disables needing Linux-PAM for the build, since it is not installed yet.

Compile the package:

ninja

To run the tests, issue:

ninja test

Install the package:

DESTDIR=$PWD/DESTDIR ninja install

mv -v DESTDIR/{s,}bin/rc-update
mv -v DESTDIR/{s,}bin DESTDIR/usr
install -vDm755 DESTDIR/usr/bin/*  -t /usr/bin/
install -vDm755 DESTDIR/usr/sbin/* -t /usr/sbin/
rm -rf DESTDIR/usr/{s,}bin

for conf in DESTDIR/etc/conf.d/*; do
  if [ ! -e /etc/conf.d/$(basename $conf) ]; then
    install -vDm644 $conf -t /etc/conf.d/
  fi
  rm -f $conf
done

cp -vR DESTDIR/* /
rm -rf DESTDIR
[Note]

Note

OpenRC by default reinstalls the configuration files for the base services, meaning that if you have configured a service like agetty, a normal installation would have reset the configuration to the default. The above ensures that doesn't happen when applicable. The rc-update under some circumstances is meant to be ran as a normal user as well, so it should be in /usr/bin.

OpenRC provides init and other programs of its own. However, the shorthands for them aren't created. Create the symlinks:

for i in {init,shutdown}; do
  ln -sv openrc-$i /sbin/$i
done

cat > /sbin/poweroff << "EOF"
#!/bin/sh
/sbin/shutdown --poweroff now
EOF

cat > /sbin/reboot << "EOF"
#!/bin/sh
/sbin/shutdown --reboot now
EOF

chmod 755 /sbin/poweroff /sbin/reboot

8.85.2. Contents of OpenRC

Installed programs: rc-status, init (link to openrc-init), openrc, openrc-init, openrc-run, openrc-shutdown, poweroff, rc-service, rc-sstat, rc-update, reboot, shutdown (link to openrc-shutdown), start-stop-daemon, and supervise-daemon
Installed libraries: libeinfo.so and librc.so
Installed directories: /etc/conf.d, /etc/init.d, /etc/local.d, /etc/runlevels, /etc/sysctl.d, /usr/libexec/rc, and /usr/share/openrc

Short Descriptions

rc-status

Gives the status of a service

init

Is the first process to be started when the kernel has initialized the hardware; it takes over the boot process and starts all the services; symlink to openrc-init

openrc

starts and stops services on a given runlevel

openrc-init

Gets called from init and starts every service as needed

openrc-run

Allows using shell commands in a service file

openrc-shutdown

Brings the system down in a secure way, signaling all processes and notifying all logged-in users

poweroff

Calls openrc-shutdown with --poweroff, stopping all services and processes before shutting down the system

rc-service

Runs a given service after locating it

rc-sstat

Gives the status of the most crucial services, followed by normal services

rc-update

Adds and removes services on a runlevel

reboot

Calls openrc-shutdown with --reboot, stopping all services and processes before telling the system to reboot

shutdown

Is a symlink to openrc-shutdown

start-stop-daemon

Starts or stops a daemon in a service file

supervise-daemon

Supervises a daemon in a service file

libeinfo

Contains functions for outputting colored messages

librc

Provides the core OpenRC functions