mirror of
https://github.com/troglobit/finit.git
synced 2026-10-01 13:33:09 +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>
150 lines
4.1 KiB
Plaintext
150 lines
4.1 KiB
Plaintext
# Sample finit.conf to demonstrate the syntax
|
|
#
|
|
hostname = "testbed"
|
|
|
|
# Linux kernel modules to load
|
|
modules = { "button", "evdev", "loop", "psmouse" }
|
|
|
|
# Top-level cgroups and their default settings. All groups mandatory
|
|
# but more can be added, max 8 groups in total currently. The cgroup
|
|
# 'root' is also available, reserved for RT processes. Settings are
|
|
# as-is, only one shorthand 'mem.' exists, other than that it's the
|
|
# cgroup v2 controller default names.
|
|
cgroup init { cpu.weight = 100 }
|
|
cgroup user { cpu.weight = 100 }
|
|
cgroup system { cpu.weight = 9700 cpu.max = 50000 }
|
|
|
|
# Example extra cgroup
|
|
cgroup maint { cpu.weight = 100 }
|
|
|
|
# Runlevel to start after bootstrap, runlevel 'S'
|
|
runlevel = 2
|
|
|
|
# Network bringup script
|
|
network = "service networking start"
|
|
|
|
# Max file size for each log file: 100 kiB, rotate max 4 copies:
|
|
# log => log.1 => log.2.gz => log.3.gz => log.4.gz
|
|
log {
|
|
size = 100k
|
|
count = 4
|
|
}
|
|
|
|
# Virtual consoles to start getty on
|
|
tty tty1 { device = "/dev/tty1" }
|
|
tty tty2 { device = "/dev/tty2" }
|
|
tty tty3 { device = "/dev/tty3" }
|
|
|
|
# Task to run if ctrl-alt-del is pressed. This condition is asserted by
|
|
# Finit upon receiving SIGINT (from the kernel).
|
|
task reboot {
|
|
description = "Rebooting system"
|
|
runlevel = "12345789"
|
|
conditions = { "sys/key/ctrlaltdel" }
|
|
command = "initctl reboot"
|
|
}
|
|
|
|
# Task to run if the kernel gets a power fail condition is pressed.
|
|
# Asserted by Finit upon receiving SIGPWR (from the kernel).
|
|
task poweroff {
|
|
description = "Shutting down system"
|
|
runlevel = "12345789"
|
|
conditions = { "sys/pwr/fail" }
|
|
command = "initctl poweroff"
|
|
}
|
|
|
|
# Alternative method instead of runparts
|
|
#task keyboard-setup {
|
|
# description = "Setting up preliminary keymap"
|
|
# runlevel = "S"
|
|
# command = "/etc/init.d/keyboard-setup start"
|
|
#}
|
|
#task acpid {
|
|
# description = "Starting ACPI Daemon"
|
|
# runlevel = "S"
|
|
# command = "/etc/init.d/acpid start"
|
|
#}
|
|
#task kbd {
|
|
# description = "Preparing console"
|
|
# runlevel = "S"
|
|
# command = "/etc/init.d/kbd start"
|
|
#}
|
|
#run networking {
|
|
# description = "Start networking"
|
|
# runlevel = "2"
|
|
# command = "/etc/init.d/networking start"
|
|
#}
|
|
|
|
# Services to be monitored and respawned as needed
|
|
|
|
# klogd and syslogd are placed in the maint cgroup. There is no
|
|
# "current cgroup" to switch in this format, every block names its own.
|
|
service klogd {
|
|
description = "Kernel logging server"
|
|
runlevel = "2345"
|
|
conditions = { "pid/syslogd" }
|
|
cgroup maint {}
|
|
command = "klogd -n"
|
|
}
|
|
service syslogd {
|
|
description = "Syslog server"
|
|
runlevel = "2345"
|
|
cgroup maint {}
|
|
command = "syslogd -n"
|
|
}
|
|
|
|
# gdm gets its own limits inside the system group, which is where
|
|
# services end up when no cgroup block is given.
|
|
service gdm {
|
|
description = "GNOME Display Manager"
|
|
runlevel = "3"
|
|
cgroup system {
|
|
cpu.weight = 250
|
|
memory.max = 10M
|
|
}
|
|
command = "gdm"
|
|
}
|
|
|
|
# Start SSH daemon with opts from /etc/default/ssh (if available), move
|
|
# to user cgroup with cpu.weight 250. Default weight in the user group
|
|
# is 100 (above).
|
|
service sshd {
|
|
description = "OpenSSH daemon"
|
|
runlevel = "2345"
|
|
envfile = "-/etc/default/ssh"
|
|
cgroup user {
|
|
cpu.weight = 250
|
|
memory.max = 10M
|
|
}
|
|
command = "/usr/sbin/sshd -D $SSHD_OPTS"
|
|
}
|
|
|
|
# The BusyBox ntpd does not use syslog when running in the foreground
|
|
# So we use this trick to redirect stdout/stderr to a log file. The
|
|
# log file is rotated with the above settings. The condition declares
|
|
# a dependency on a system default route (gateway) to be set. ntpd
|
|
# does not respect SIGHUP, so Finit restarts it on reload instead.
|
|
service ntpd {
|
|
description = "NTP daemon"
|
|
runlevel = "2345"
|
|
conditions = { "net/route/default" }
|
|
reload-signal = "none"
|
|
log { file = "/var/log/ntpd.log" }
|
|
command = "ntpd -n -l -I eth0"
|
|
}
|
|
|
|
# Run start scripts from this directory
|
|
#runparts = "/etc/start.d"
|
|
|
|
# For multiple instances of the same service, add :ID to the block title.
|
|
service httpd:80 {
|
|
description = "Web server"
|
|
runlevel = "2345"
|
|
command = "/sbin/httpd -f -h /http -p 80"
|
|
}
|
|
service httpd:8080 {
|
|
description = "Old web server"
|
|
runlevel = "2345"
|
|
command = "/sbin/httpd -f -h /http -p 8080"
|
|
}
|