mirror of
https://github.com/troglobit/finit.git
synced 2026-10-01 05:22:48 +07:00
The examples people copy from were still written in the line-based
format, so the block format was documented but nowhere demonstrated.
Two names in contrib were accidents of the old format, where the
service name falls out of the command basename: the Alpine and Void
keymap task was called zcat, and Debian's console/keyboard setup tasks
carried a .sh suffix. They now carry the name their file implies.
Nothing referenced the old names.
The mdevd coldplug path keeps the name it has always had. Its legacy
line spelled the name inside the cgroup argument, where it names the
cgroup leaf and not the service, so the barrier condition really is
<run/mdevd-coldplug/success> and not the <run/coldplug/success> the
comment above it promises. Converted as-is so boot ordering does not
change; the discrepancy is now written down where it happens.
A list may not contain comments, the lexer sees the entries after the
'#' regardless:
modules = {
# "fbcon",
"softdog"
}
so the commented-out module candidates sit above the list instead.
setup-sysroot.sh removes 10-hotplug.conf from the test sysroot, so that
file is covered by parsing only, not by make check.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
156 lines
5.3 KiB
Plaintext
156 lines
5.3 KiB
Plaintext
# System hotplug handled by udev, mdevd, or mdev (preferred order)
|
|
#
|
|
# Your system usually has either udevd, mdev, or mdevd. They probe the system
|
|
# for devices, loading modules and any firmware needed. Since the bootstrap
|
|
# often needs to be synchronized carefully, we suggest using your system log
|
|
# daemon as the barrier for all other services. E.g.:
|
|
#
|
|
# service syslogd {
|
|
# description = "System log daemon"
|
|
# runlevel = "S0123456789"
|
|
# if = "udevd"
|
|
# conditions = { "run/udevadm:5/success" }
|
|
# command = "syslogd -F"
|
|
# }
|
|
#
|
|
# with `if = "mdev"` or `if = "mdevd"` and the matching coldplug condition
|
|
# for those variants.
|
|
#
|
|
# This provdes a <pid/syslogd> condition that can act as a barrier for all
|
|
# other services. Notice the `if` setting: the condition for starting
|
|
# syslogd is only considered if either udevd or mdev (service) is loaded and
|
|
# is guaranteed to run after each respective run stanza have completed.
|
|
#
|
|
# Override this file by copying it to /etc/finit.d/, using the same name, then
|
|
# change the contents any way you like, it can even be empty.
|
|
#
|
|
# The leading '-' on every command says a missing binary is expected here, so
|
|
# the block is skipped quietly and the next candidate gets its turn.
|
|
|
|
# Check for systemd-udevd and eudev, if we find both, we opt for the latter.
|
|
service udevd {
|
|
description = "Device event daemon (udev)"
|
|
runlevel = "S12345789"
|
|
notify = "none"
|
|
envfile = "-/etc/default/udevd"
|
|
pidfile = "udevd"
|
|
pidfile-create = true
|
|
log { }
|
|
cgroup system { name = "udevd" }
|
|
command = "-/lib/systemd/systemd-udevd $UDEVD_ARGS"
|
|
}
|
|
service udevd {
|
|
description = "Device event daemon (udev)"
|
|
runlevel = "S12345789"
|
|
notify = "none"
|
|
envfile = "-/etc/default/udevd"
|
|
pidfile = "udevd"
|
|
pidfile-create = true
|
|
log { }
|
|
cgroup system { name = "udevd" }
|
|
command = "-udevd $UDEVD_ARGS"
|
|
}
|
|
|
|
# Wait for udevd to start, then trigger coldplug events and module loading.
|
|
# The last 'settle' call waits for it to finalize processing all uevents.
|
|
run udevadm:1 {
|
|
runlevel = "S"
|
|
if = "udevd"
|
|
conditions = { "service/udevd/ready" }
|
|
log { }
|
|
cgroup init { name = "udevadm" }
|
|
command = "-udevadm settle -t 0"
|
|
}
|
|
run udevadm:2 {
|
|
runlevel = "S"
|
|
if = "udevd"
|
|
conditions = { "service/udevd/ready" }
|
|
log { }
|
|
cgroup init { name = "udevadm" }
|
|
command = "-udevadm control --reload"
|
|
}
|
|
run udevadm:3 {
|
|
description = "Requesting device events"
|
|
runlevel = "S"
|
|
if = "udevd"
|
|
conditions = { "service/udevd/ready" }
|
|
log { }
|
|
cgroup init { name = "udevadm" }
|
|
command = "-udevadm trigger -c add -t devices"
|
|
}
|
|
run udevadm:4 {
|
|
description = "Requesting subsystem events"
|
|
runlevel = "S"
|
|
if = "udevd"
|
|
conditions = { "service/udevd/ready" }
|
|
log { }
|
|
cgroup init { name = "udevadm" }
|
|
command = "-udevadm trigger -c add -t subsystems"
|
|
}
|
|
run udevadm:5 {
|
|
description = "Waiting for udev to finish"
|
|
runlevel = "S"
|
|
if = "udevd"
|
|
conditions = { "service/udevd/ready" }
|
|
log { }
|
|
cgroup init { name = "udevadm" }
|
|
command = "-udevadm settle -t 30"
|
|
}
|
|
|
|
# If udevd is not available, check for mdevd. Unlike plain 'mdev -df', the
|
|
# mdevd-coldplug process exits when mdevd has completed. So the condition
|
|
# <run/mdevd-coldplug/success> can be relied on as a barrier for services
|
|
# that, e.g., need to probe for switchcore ports or PHYs that require
|
|
# firmware loading before they show up.
|
|
service mdevd {
|
|
description = "Device event daemon (mdevd)"
|
|
runlevel = "S12345789"
|
|
if = "!udevd"
|
|
conflicts = { "udevd", "mdev" }
|
|
notify = "s6"
|
|
cgroup init { name = "mdevd" }
|
|
command = "-mdevd -O 4 -D %n"
|
|
}
|
|
|
|
# NOTE: this block is named for its command, so its barrier condition is
|
|
# <run/mdevd-coldplug/success>, not the <run/coldplug/success> the
|
|
# plain mdev stanza below provides. The legacy line spelled the
|
|
# name inside the cgroup argument, where it names the cgroup leaf
|
|
# rather than the service, and the two paths have differed ever
|
|
# since. Left as it was so boot ordering does not change.
|
|
run mdevd-coldplug {
|
|
description = "Cold plugging system"
|
|
runlevel = "S"
|
|
conflicts = { "udevd", "mdev" }
|
|
conditions = { "service/mdevd/ready" }
|
|
cgroup init { name = "coldplug" }
|
|
command = "-mdevd-coldplug"
|
|
}
|
|
|
|
# If neither udevd or mdevd are available, fall back to mdev. The new daemon
|
|
# mode calls `mdev -s` internally but does not create a PID file when that is
|
|
# done, so synchronization with coldplug is fragile.
|
|
service mdev {
|
|
description = "Device event daemon (mdev)"
|
|
runlevel = "S12345789"
|
|
if = "!udevd,!mdevd"
|
|
conflicts = { "udevd", "mdevd" }
|
|
notify = "none"
|
|
cgroup init { name = "mdev" }
|
|
command = "-mdev -df -S"
|
|
}
|
|
|
|
# Trigger a replay of all uevents from boot, before userspace was up and the
|
|
# filesystem mounted. Compared to udevd, we don't know when 'mdev -df' has
|
|
# finished processing all events, i.e., depending on <run/coldplug/success> is
|
|
# not an indicator of all devices having been (re)discovered and fully set up.
|
|
run coldplug {
|
|
description = "Cold plugging system"
|
|
runlevel = "S"
|
|
if = "mdev"
|
|
conflicts = { "udevd", "mdevd" }
|
|
conditions = { "service/mdev/running" }
|
|
cgroup init {}
|
|
command = "-@pkglibexecdir@/coldplug"
|
|
}
|