man openrc
OpenRC
NAMENOM
openrc: the init system of Mwa Linux
openrc : le système d'init de Mwa Linux
DESCRIPTION
OpenRC starts the services at boot, in the order their dependencies require. It stops them at shutdown.
OpenRC démarre les services au boot, dans l'ordre imposé par leurs dépendances. Il les arrête à l'extinction.
On Mwa Linux, openrc-init is PID 1. There is no sysvinit. supervise-daemon can restart a service that dies.
Sur Mwa Linux, openrc-init est le PID 1. Il n'y a pas de sysvinit. supervise-daemon peut relancer un service qui s'arrête.
Commands that change the system run as root, through doas.
Les commandes qui modifient le système se lancent en root, avec doas.
FILESFICHIERS
- /etc/rc.conf
- global settings, with commentsréglages généraux, commentés
- /etc/conf.d/
- settings of each serviceréglages de chaque service
- /etc/init.d/
- service scriptsscripts des services
- /etc/runlevels/
- enabled services, one directory per runlevelservices activés, un dossier par runlevel
- /var/log/rc.log
- boot output, if rc_logger is onsortie du boot, si rc_logger est activé
SERVICES
Start, stop, restart, show the state:
Démarrer, arrêter, relancer, voir l'état :
$ doas rc-service dhcpcd start $ doas rc-service dhcpcd stop $ doas rc-service dhcpcd restart $ rc-service dhcpcd status
Start a service at every boot, or stop doing it:
Lancer un service à chaque démarrage, ou ne plus le faire :
$ doas rc-update add iwd default $ doas rc-update del iwd default
Listing needs no root:
Lister ne demande pas root :
$ rc-update show -v $ rc-status $ rc-status -s
RUNLEVELS
A runlevel is a set of services: a directory in /etc/runlevels. Mwa Linux starts three, in this order:
Un runlevel est un ensemble de services : un dossier dans /etc/runlevels. Mwa Linux en démarre trois, dans cet ordre :
- sysinit
- udevd, udev-trigger
- boot
- nftables, sysklogd
- default
- dhcpcd, agetty.tty1 … agetty.tty6, agetty.ttyS0
The firewall starts in boot, before the network. It blocks incoming connections. No service listens on the network after installation.
Le pare-feu démarre dans boot, avant le réseau. Il bloque les connexions entrantes. Aucun service n'écoute sur le réseau après l'installation.
iwd (Wi-Fi) and dbus are installed but not enabled. For Wi-Fi: doas rc-update add iwd default.
iwd (Wi-Fi) et dbus sont installés mais pas activés. Pour le Wi-Fi : doas rc-update add iwd default.
Create a runlevel, switch to it, then go back:
Créer un runlevel, y passer, puis revenir :
$ doas install -d /etc/runlevels/offline $ doas openrc offline $ doas openrc default
To boot straight into it, add softlevel=offline to the kernel command line.
Pour démarrer directement dessus, ajoute softlevel=offline à la ligne de commande du noyau.
DEPENDENCIESDÉPENDANCES
Each script says what it needs in its depend() function. To change that without editing the script, use /etc/conf.d/<service>:
Chaque script déclare ce dont il a besoin dans sa fonction depend(). Pour changer ça sans toucher au script, passe par /etc/conf.d/<service> :
rc_need="dbus"
rc_need: start dbus first, and stop this service if dbus stops. rc_use: start it first only if it is enabled. rc_after: order only.
rc_need : démarre dbus avant, et arrête ce service si dbus s'arrête. rc_use : le démarre avant seulement s'il est activé. rc_after : ordre seulement.
SUPERVISION
With supervise-daemon, OpenRC watches the process and restarts it if it dies. Turn it on in /etc/conf.d/<service>:
Avec supervise-daemon, OpenRC surveille le processus et le relance s'il meurt. À activer dans /etc/conf.d/<service> :
supervisor="supervise-daemon" respawn_delay=2 respawn_max=5
The program must stay in the foreground. Check its options: often -f or --foreground.
Le programme doit rester au premier plan. Regarde ses options : souvent -f ou --foreground.
LOGSJOURNAUX
OpenRC writes nothing to disk by default. To keep the boot output, in /etc/rc.conf:
Par défaut, OpenRC n'écrit rien sur le disque. Pour garder la sortie du boot, dans /etc/rc.conf :
rc_logger="YES"
It goes to /var/log/rc.log. The logs of the services go to sysklogd, in /var/log.
Elle va dans /var/log/rc.log. Les journaux des services passent par sysklogd, dans /var/log.
WRITING A SERVICEÉCRIRE UN SERVICE
A service is a shell script in /etc/init.d:
Un service est un script shell dans /etc/init.d :
#!/sbin/openrc-run
description="my daemon"
command="/usr/bin/mydaemon"
command_args="--foreground"
supervisor="supervise-daemon"
depend() {
need localmount
after firewall
}
$ doas chmod +x /etc/init.d/mydaemon $ doas rc-update add mydaemon default $ doas rc-service mydaemon start
TROUBLESHOOTINGDÉPANNAGE
A service shows crashed: the process died but OpenRC still thinks it runs. Reset its state, then start it:
Un service affiche crashed : le processus est mort mais OpenRC le croit encore lancé. Remets son état à zéro, puis démarre-le :
$ doas rc-service mydaemon zap $ doas rc-service mydaemon start
doas openrc brings the system back to its runlevel: it starts what is missing and stops what was started by hand. doas openrc -n does not stop anything.
doas openrc remet le système dans l'état de son runlevel : il démarre ce qui manque et arrête ce qui a été lancé à la main. doas openrc -n n'arrête rien.
SEE ALSOVOIR AUSSI
man pages:pages de manuel : openrc, openrc-run, openrc-init, rc-service, rc-update, rc-status, supervise-daemon