| 1 |
.\" Hey, EMACS: -*- nroff -*- |
| 2 |
.\" First parameter, NAME, should be all caps |
| 3 |
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection |
| 4 |
.\" other parameters are allowed: see man(7), man(1) |
| 5 |
.Dd July 10, 2025 |
| 6 |
.Dt FINIT.CONF 5 SMM |
| 7 |
.Os Linux |
| 8 |
.Sh NAME |
| 9 |
.Nm finit.conf |
| 10 |
.Nd Finit configuration file format |
| 11 |
.Sh SYNOPSIS |
| 12 |
.Nm /etc/finit.conf |
| 13 |
.Nm /etc/finit.d/*.conf |
| 14 |
.Nm /etc/finit.d/available/*.conf |
| 15 |
.Nm /etc/finit.d/enabled/*.conf |
| 16 |
.Sh DESCRIPTION |
| 17 |
.Nm Finit |
| 18 |
based systems can be set up with a single file: |
| 19 |
.Pa /etc/finit.conf . |
| 20 |
This is the traditional way of doing it which can be ideal for some |
| 21 |
setups since it gives a great overview of the system configuration. |
| 22 |
.Pp |
| 23 |
More comprehensive setups, however, require more careful planning. |
| 24 |
The recommendation is per-package |
| 25 |
.Cm *.conf |
| 26 |
files in |
| 27 |
.Pa /etc/finit.d/available/ . |
| 28 |
This allows end users to enable and disable parts of the system |
| 29 |
configuration at runtime. Finit tracks which tasks and services belong |
| 30 |
to a given file, so that when the user calls |
| 31 |
.Cm initctl reload |
| 32 |
to activate the changes they have made, only the affected tasks and |
| 33 |
services are stopped, started, or restarted. Hence, this approach is |
| 34 |
useful for modern package-based Linux distributions. |
| 35 |
.Pp |
| 36 |
The following sections describe the more of this in detail, starting |
| 37 |
with files, the file format, and available directives. Remember to |
| 38 |
also visit the other manual pages (references at the bottom). |
| 39 |
.Sh FILES |
| 40 |
.Bl -tag -width /etc/finit.d/available/*.conf -compact |
| 41 |
.It Pa /etc/finit.conf |
| 42 |
Main configuration file, optional |
| 43 |
.It Pa /etc/finit.d/*.conf |
| 44 |
Static (system) service definitions |
| 45 |
.It Pa /etc/finit.d/available/*.conf |
| 46 |
Available (installed) services |
| 47 |
.It Pa /etc/finit.d/enabled/*.conf |
| 48 |
Enabled services (symlink back) |
| 49 |
.El |
| 50 |
.Pp |
| 51 |
Static services, |
| 52 |
.Cm .conf |
| 53 |
files in |
| 54 |
.Pa /etc/finit.d/ , |
| 55 |
cannot be enabled or disabled using |
| 56 |
.Cm initctl [enable | disable] service[.conf] . |
| 57 |
An enabled service is a symlink back to the corresponding |
| 58 |
.Cm ../available/ |
| 59 |
service |
| 60 |
.Cm .conf |
| 61 |
file. Please use the |
| 62 |
.Cm initctl |
| 63 |
tool to manage these symlinks to ensure proper operation. |
| 64 |
.Pp |
| 65 |
.Sy NOTE: |
| 66 |
Previous versions of |
| 67 |
.Nm Finit |
| 68 |
created symlinks in |
| 69 |
.Pa /etc/finit.d/ |
| 70 |
if |
| 71 |
.Pa /etc/finit.d/enabled/ |
| 72 |
was missing, this is as of v4.4 not supported. |
| 73 |
.Sh FILE FORMAT |
| 74 |
The file format is line based, empty lines and comments, lines starting |
| 75 |
with `#', are ignored. A configuration directive starts with a keyword |
| 76 |
followed by a space and the rest of the line is treated as the value. |
| 77 |
.Pp |
| 78 |
As of Finit v4.4, configuration directives can be broken up in multiple |
| 79 |
lines using the continuation character `\\', and trailing comments are |
| 80 |
also allowed. Example: |
| 81 |
.Bd -unfilled -offset indent |
| 82 |
# Escape \\# chars if you want them literal in, e.g., descriptions |
| 83 |
service name:sysklogd [S123456789] \\ |
| 84 |
env:-/etc/default/sysklogd \\ |
| 85 |
syslogd -F $SYSLOGD_ARGS \\ |
| 86 |
-- System log daemon \\# 1 # Comments allowed now |
| 87 |
.Ed |
| 88 |
.Sh DIRECTIVES |
| 89 |
This section lists all supported configuration directives. There also exist |
| 90 |
deprecated directives, see the Markdown documentation for details on these. |
| 91 |
.Pp |
| 92 |
.Bl -tag -width 1n |
| 93 |
.It Cm rlimit Oo hard|soft Oc Ar RESOURCE Aq LIMIT | unlimited |
| 94 |
.Pp |
| 95 |
Set the hard or soft limit for a resource, or both if that argument is |
| 96 |
omitted. |
| 97 |
.Ar RESOURCE |
| 98 |
is the lower-case |
| 99 |
.Cm RLIMIT_ |
| 100 |
string constants from |
| 101 |
.Xr setrlimit 2 , |
| 102 |
without prefix. E.g. to set |
| 103 |
.Cm RLIMIT_CPU , |
| 104 |
use |
| 105 |
.Cm cpu . |
| 106 |
.Pp |
| 107 |
.Ar LIMIT |
| 108 |
is an integer that depends on the resource being modified, see |
| 109 |
the man page, or the kernel |
| 110 |
.Pa /proc/PID/limits |
| 111 |
file, for details. |
| 112 |
Finit versions before v3.1 used |
| 113 |
.Cm infinity |
| 114 |
for |
| 115 |
.Cm unlimited , |
| 116 |
which is still supported, albeit deprecated. |
| 117 |
.Bd -unfilled -offset indent |
| 118 |
# No process is allowed more than 8MB of address space |
| 119 |
rlimit hard as 8388608 |
| 120 |
|
| 121 |
# Core dumps may be arbitrarily large |
| 122 |
rlimit soft core infinity |
| 123 |
|
| 124 |
# CPU limit for all services, soft & hard = 10 sec |
| 125 |
rlimit cpu 10 |
| 126 |
.Ed |
| 127 |
.Pp |
| 128 |
.Cm rlimit |
| 129 |
can be set globally, in |
| 130 |
.Pa /etc/finit.conf , |
| 131 |
or locally per each |
| 132 |
.Pa /etc/finit.d/*.conf |
| 133 |
read. I.e., a set of task/run/service stanzas can share the same |
| 134 |
rlimits if they are in the same .conf. |
| 135 |
.It Cm runlevel Aq N |
| 136 |
The system runlevel to go to after bootstrap (S) has completed. |
| 137 |
.Cm N |
| 138 |
is the runlevel number 0-9, where 6 is reserved for reboot and 0 for |
| 139 |
halt. All other can be used by operating system administrators. |
| 140 |
Default: 2 |
| 141 |
.Pp |
| 142 |
It s recommended to keep runlevel 1 as single-user mode, because |
| 143 |
.Nm |
| 144 |
disables networking in this mode. |
| 145 |
.Pp |
| 146 |
.Sy Note: |
| 147 |
only read and executed in runlevel S (bootstrap). |
| 148 |
.It Cm run Oo LVLS Oc Ao COND Ac Ar /path/to/cmd ARGS Op -- Optional description |
| 149 |
One-shot command to run in sequence when entering a runlevel, with |
| 150 |
optional arguments and description. |
| 151 |
.Pp |
| 152 |
.Cm run |
| 153 |
commands are guaranteed to be completed before running the next |
| 154 |
command. Highly useful if true serialization is needed. Usually |
| 155 |
only used in the bootstrap (S) runlevel. |
| 156 |
.Pp |
| 157 |
.Cm Aq COND |
| 158 |
conditions are described in |
| 159 |
.Xr finit 8 , |
| 160 |
see also the |
| 161 |
.Sx Examples |
| 162 |
section below. |
| 163 |
.It Cm task Oo LVLS Oc Ao COND Ac Ar /path/to/cmd ARGS Op -- Optional description |
| 164 |
One-shot like |
| 165 |
.Cm run , |
| 166 |
but starts in parallel with the next command. |
| 167 |
.Pp |
| 168 |
Both |
| 169 |
.Cm run |
| 170 |
and |
| 171 |
.Cm task |
| 172 |
commands are run in a shell, so pipes and redirects can be freely used: |
| 173 |
.Bd -unfilled -offset indent |
| 174 |
task [s] echo "foo" | cat >/tmp/bar |
| 175 |
.Ed |
| 176 |
.It Cm sysv Oo LVLS Oc Ao COND Ac Ar /path/to/script ARGS Op -- Optional description |
| 177 |
Similar to |
| 178 |
.Cm service |
| 179 |
is the |
| 180 |
.Cm sysv |
| 181 |
directive, which can be used to call SysV style start/stop scripts. The |
| 182 |
primary intention for this command is to be able to re-use traditional |
| 183 |
SysV init scripts in Linux distributions. |
| 184 |
.Pp |
| 185 |
When entering an allowed runlevel, Finit calls |
| 186 |
.Cm init-script start , |
| 187 |
when entering a disallowed runlevel, Finit calls |
| 188 |
.Cm init-script stop , |
| 189 |
and if the Finit .conf, where the |
| 190 |
.Cm sysv |
| 191 |
stanza is declared, is modified, Finit calls |
| 192 |
.Cm init-script restart |
| 193 |
on |
| 194 |
.Cm initctl reload . |
| 195 |
Similar to how |
| 196 |
.Cm service |
| 197 |
directives work. |
| 198 |
.Pp |
| 199 |
Forking services started with |
| 200 |
.Cm sysv |
| 201 |
scripts can be monitored by Finit by declaring the PID file to look for: |
| 202 |
.Bd -unfilled -offset indent |
| 203 |
sysv pid:!/path/to/pidfile.pid /path/to/script ... |
| 204 |
.Ed |
| 205 |
.Pp |
| 206 |
The leading '!' is to prevent Finit from managing the PID file, which is |
| 207 |
the default behavior for the |
| 208 |
.Cm pid: |
| 209 |
command modifier. |
| 210 |
.It Cm service Oo LVLS Oc Ao COND Ac Ar /path/to/daemon ARGS Op -- Optional description |
| 211 |
Service, or daemon, to be monitored and automatically restarted if it |
| 212 |
exits prematurely. Finit tries to restart services that die, by |
| 213 |
default 10 times, before giving up and marking them as |
| 214 |
.Em crashed . |
| 215 |
After which they have to be restarted manually using |
| 216 |
.Cm initctl restart NAME . |
| 217 |
The number of restarts, the delay between each restart, and more is |
| 218 |
configurable, see the options below. |
| 219 |
.Pp |
| 220 |
.Bd -filled -offset indent |
| 221 |
.Sy Tip: |
| 222 |
to allow endless restarts, see below option |
| 223 |
.Cm respawn |
| 224 |
.Ed |
| 225 |
.Pp |
| 226 |
For daemons that support it, we recommend appending |
| 227 |
.Cm --foreground , --no-background , -n , -F , |
| 228 |
or similar command line argument to prevent them from forking off a |
| 229 |
sub-process in the background. This is the most reliable way to monitor |
| 230 |
a service. |
| 231 |
.Pp |
| 232 |
However, not all daemons support running in the foreground, or they may |
| 233 |
start logging to the foreground as well, these are called forking |
| 234 |
services and are supported using the same syntax as forking |
| 235 |
.Cm sysv |
| 236 |
services, using the |
| 237 |
.Cm pid:!/path/to/pidfile.pid |
| 238 |
command modifier syntax. There is an alternative syntax that may be |
| 239 |
more intuitive, where Finit can also guess the PID file based on the |
| 240 |
daemon's command name: |
| 241 |
.Bd -unfilled -offset indent |
| 242 |
service type:forking ntpd -- NTP daemon |
| 243 |
.Ed |
| 244 |
.Pp |
| 245 |
Here we let BusyBox |
| 246 |
.Nm ntpd |
| 247 |
daemonize itself. Finit uses the basename of the binary to guess the |
| 248 |
PID file to watch for the PID: |
| 249 |
.Pa /var/run/ntpd.pid . |
| 250 |
If Finit guesses wrong, you have to submit the full |
| 251 |
.Cm pid:!/path/to/file.pid |
| 252 |
option to your service stanza. |
| 253 |
.Pp |
| 254 |
.Sy Example: in the case of |
| 255 |
.Cm ospfd |
| 256 |
(below), we omit the |
| 257 |
.Cm -d |
| 258 |
flag (daemonize) to prevent it from forking to the background: |
| 259 |
.Bd -unfilled -offset indent |
| 260 |
service [2345] <pid/zebra> /sbin/ospfd -- OSPF daemon |
| 261 |
.Ed |
| 262 |
.Pp |
| 263 |
.Cm [2345] |
| 264 |
denote the runlevels |
| 265 |
.Cm ospfd |
| 266 |
is allowed to run in, they are optional and default to runlevel 2-5 if |
| 267 |
omitted. |
| 268 |
.Pp |
| 269 |
.Cm <pid/zebra> |
| 270 |
is the condition for starting |
| 271 |
.Cm ospfd . |
| 272 |
In this example Finit waits for another service, |
| 273 |
.Cm zebra , |
| 274 |
to have created its PID file in |
| 275 |
.Pa /var/run/quagga/zebra.pid |
| 276 |
before starting |
| 277 |
.Cm ospfd . |
| 278 |
Finit watches *all* files in |
| 279 |
.Pa /var/run , |
| 280 |
for each file named |
| 281 |
.Cm *.pid , |
| 282 |
.Cm */pid , |
| 283 |
Finit opens it and find the matching |
| 284 |
.Cm NAME:ID |
| 285 |
using the PID. |
| 286 |
.Pp |
| 287 |
Some services do not maintain a PID file and rather than patching each |
| 288 |
application Finit provides a workaround. A |
| 289 |
.Cm pid |
| 290 |
modifier keyword can be set to have Finit automatically create (when |
| 291 |
starting) and later remove (when stopping) the PID file. The file is |
| 292 |
created in the |
| 293 |
.Pa /var/run |
| 294 |
directory using the |
| 295 |
.Xr basename 3 |
| 296 |
of the service. The full syntax of the |
| 297 |
.Cm pid |
| 298 |
modifier is: |
| 299 |
.Bd -unfilled -offset indent |
| 300 |
pid[:[!][/path/to/]filename[.pid]] |
| 301 |
.Ed |
| 302 |
.Pp |
| 303 |
For example, by adding |
| 304 |
.Cm pid:/run/foo.pid |
| 305 |
to the service |
| 306 |
.Cm /sbin/bar , |
| 307 |
that PID file will, not only be created and removed automatically, but |
| 308 |
also be used by the Finit condition subsystem. So a service/run/task |
| 309 |
can depend on the |
| 310 |
.Cm <pid/bar> |
| 311 |
condition. |
| 312 |
.Pp |
| 313 |
As an alternative "readiness" notification, Finit supports both systemd |
| 314 |
and s6 style notification. This can be enabled by using the `notify` |
| 315 |
option: |
| 316 |
.Bl -tag -width 1n |
| 317 |
.It Cm notify:systemd |
| 318 |
tells Finit the service uses the |
| 319 |
.Cm sd_notify() |
| 320 |
API to signal PID 1 when it has completed its startup and is ready |
| 321 |
to service events. This API expects |
| 322 |
the environment variable |
| 323 |
.Cm NOTIFY_SOCKET |
| 324 |
to be set to the socket where the application can send |
| 325 |
.Cm "READY=1\n" |
| 326 |
when it is starting up or has processed a |
| 327 |
.Cm SIGHUP . |
| 328 |
For details, see: |
| 329 |
.Pp |
| 330 |
.Lk https://www.freedesktop.org/software/systemd/man/sd_notify.html |
| 331 |
.It Cm notify:s6 |
| 332 |
puts Finit in s6 compatibility mode. Compared to the systemd |
| 333 |
notification, s6 expect compliant daemons to send |
| 334 |
.Cm "\\n" |
| 335 |
and then close their socket. For details, see: |
| 336 |
.Pp |
| 337 |
.Lk https://skarnet.org/software/s6/notifywhenup.html |
| 338 |
.Pp |
| 339 |
Finit takes care of "hard-wiring" the READY state as long as the |
| 340 |
application is running, events across any `SIGHUP`. Since s6 can give |
| 341 |
its applications the descriptor number (must be >3) on then command |
| 342 |
line, Finit provides the following syntax ( |
| 343 |
.Cm %n |
| 344 |
is replaced by Finit with then descriptor number): |
| 345 |
.Bd -unfilled -offset indent |
| 346 |
service notify:s6 mdevd -C -O 4 -D %n |
| 347 |
.Ed |
| 348 |
.Pp |
| 349 |
When a service is ready, either by Finit detecting its PID file, or |
| 350 |
their respective readiness mechanism has been triggered, Finit creates |
| 351 |
then service's ready condition which other services can depend on: |
| 352 |
.Bd -unfilled -offset indent |
| 353 |
$ initctl -v cond get service/mdevd/ready |
| 354 |
on |
| 355 |
.Ed |
| 356 |
.El |
| 357 |
.Pp |
| 358 |
If a service should not be automatically started, it can be configured |
| 359 |
as manual with the |
| 360 |
.Cm manual:yes |
| 361 |
command modifier. The service can then be started at any time by |
| 362 |
running |
| 363 |
.Cm initctl start NAME |
| 364 |
.Pp |
| 365 |
The name of a service, shown by the |
| 366 |
.Cm initctl |
| 367 |
tool, defaults to the basename of the service executable. It can be |
| 368 |
changed with the |
| 369 |
.Cm name:foo |
| 370 |
command modifier. |
| 371 |
.Pp |
| 372 |
As mentioned previously, services are automatically restarted should |
| 373 |
they crash, this is configurable with the following options: |
| 374 |
.Bl -tag -width 1n |
| 375 |
.It Cm restart:NUM |
| 376 |
number of times Finit tries to restart a crashing |
| 377 |
service, default: 10. When this limit is reached the service is |
| 378 |
marked |
| 379 |
.Em crashed |
| 380 |
and must be restarted manually with |
| 381 |
.Xr initctl 8 . |
| 382 |
.It Cm restart_sec:SEC |
| 383 |
number of seconds before Finit tries to restart |
| 384 |
a crashing service, default: 2 seconds for the first five retries, |
| 385 |
then back-off to 5 seconds. The maximum of this configured value |
| 386 |
and the above (2 and 5) will be used |
| 387 |
.It Cm restart:always |
| 388 |
no upper limit on the number of times Finit tries to restart a crashing |
| 389 |
service. Same as |
| 390 |
.Cm restart:-1 |
| 391 |
.It Cm norestart |
| 392 |
dont restart on failures, same as |
| 393 |
.Cm restart:0 |
| 394 |
.It Cm respawn |
| 395 |
bypasses the |
| 396 |
.Cm restart |
| 397 |
mechanism completely, allows endless restarts. Useful in many |
| 398 |
use-cases, but not what |
| 399 |
.Cm service |
| 400 |
was originally designed for so not the default behavior. |
| 401 |
.It Cm oncrash:reboot |
| 402 |
when all retries have failed, and the service |
| 403 |
has |
| 404 |
.Em crashed , |
| 405 |
if this option is set the system is rebooted. |
| 406 |
.It Cm oncrash:script |
| 407 |
Similar to |
| 408 |
.Cm oncrash:reboot , |
| 409 |
but instead of rebooting this action calls the |
| 410 |
.Cm post:script |
| 411 |
(see below) to let the operator decide the best course of action. If |
| 412 |
the post:script option is not set, this is a no-op. |
| 413 |
.Pp |
| 414 |
The post:script is called with the same environment variables |
| 415 |
.Sy except |
| 416 |
for the |
| 417 |
.Cm EXIT_CODE |
| 418 |
variable which is set to |
| 419 |
.Cm "crashed" |
| 420 |
.It Cm reload:'script [args]' |
| 421 |
some services do not support SIGHUP but may have other ways to update |
| 422 |
the configuration of a running daemon. When |
| 423 |
.Cm reload:script |
| 424 |
is defined it is preferred over SIGHUP. Like systemd, |
| 425 |
.Nm finit |
| 426 |
sets |
| 427 |
.Cm $MAINPID |
| 428 |
as a convenience to scripts, which in effect also allow |
| 429 |
.Cm reload:'kill -HUP $MAINPID' |
| 430 |
.It Cm stop:'script [args]' |
| 431 |
Some services may require alternate methods to be stopped. When |
| 432 |
.Cm stop:script |
| 433 |
is defined it is preferred over SIGTERM and stop, for |
| 434 |
.Cm service |
| 435 |
and |
| 436 |
.Cm sysv |
| 437 |
directives, respectively. |
| 438 |
Similar to |
| 439 |
.Cm reload:script , |
| 440 |
.Nm finit |
| 441 |
sets |
| 442 |
.Cm $MAINPID . |
| 443 |
.El |
| 444 |
.Pp |
| 445 |
When stopping a service (run/task/sysv/service), either manually or when |
| 446 |
moving to another runlevel, Finit starts by sending SIGTERM, to allow |
| 447 |
the process to shut down gracefully. If the process has not been |
| 448 |
collected within 3 seconds, Finit sends SIGKILL. To halt the process |
| 449 |
using a different signal, use the command modifier |
| 450 |
.Cm halt:SIGNAL , |
| 451 |
e.g., |
| 452 |
.Cm halt:SIGPWR . |
| 453 |
To change the delay between your halt signal and KILL, use the command |
| 454 |
modifier |
| 455 |
.Cm kill:SEC , |
| 456 |
e.g., |
| 457 |
.Cm kill:10 |
| 458 |
to wait 10 seconds before sending SIGKILL. |
| 459 |
.Pp |
| 460 |
Services, including the |
| 461 |
.Cm sysv |
| 462 |
variant, support pre/post/ready and cleanup scripts: |
| 463 |
.Bl -tag -width 1n |
| 464 |
.It Cm pre:[0-3600,]script |
| 465 |
called before the sysv/service is stated |
| 466 |
.It Cm post:[0-3600,]script |
| 467 |
called after the sysv/service has stopped |
| 468 |
.It Cm ready:[0-3600,]script |
| 469 |
called when the sysv/service is ready |
| 470 |
.It Cm cleanup:[0-3600,]script |
| 471 |
called when run/task/sysv/service is removed |
| 472 |
.El |
| 473 |
.Pp |
| 474 |
The optional number (0-3600) is the timeout before Finit kills the |
| 475 |
script, it defaults to the kill delay value and can be disabled by |
| 476 |
setting it to zero. These scripts run as the same |
| 477 |
.Cm @USER:GROUP |
| 478 |
as the service itself, with any |
| 479 |
.Cm env:file |
| 480 |
sourced. The scripts must use an absolute path, but are executed from |
| 481 |
the |
| 482 |
.Cm $HOME |
| 483 |
of the given user. The scripts are not called with any argument, but |
| 484 |
both get a set of environment variables: |
| 485 |
.Pp |
| 486 |
.Bl -tag -width 1n -compact |
| 487 |
.It Cm SERVICE_IDENT=foo:1 |
| 488 |
.It Cm SERVICE_NAME=foo |
| 489 |
.It Cm SERVICE_ID=1 |
| 490 |
.El |
| 491 |
.Pp |
| 492 |
The |
| 493 |
.Cm post:script |
| 494 |
is called with an additional set of environment variables, and yes the |
| 495 |
naming looks like it should be swapped: |
| 496 |
.Bl -tag -offset indent -width 1n |
| 497 |
.It Cm EXIT_CODE=[exited,signal,crashed] |
| 498 |
set to one of |
| 499 |
.Cm exited , |
| 500 |
.Cm signal , |
| 501 |
or |
| 502 |
.Cm crashed |
| 503 |
(see above). |
| 504 |
.It Cm EXIT_STATUS=[num,SIGNAME] |
| 505 |
set to one of exit status code from the program, if it exited normally, |
| 506 |
or the signal name (HUP, TERM, etc.) if it exited due to signal |
| 507 |
.El |
| 508 |
.Pp |
| 509 |
When a run/task/sys/service is removed (disable + reload) it is first |
| 510 |
stopped and then removed from the runlevel. The |
| 511 |
.Cm post:script |
| 512 |
always runs when the process has stopped, and the |
| 513 |
.Cm cleanup:script |
| 514 |
runs when the the stanza has been removed from the runlevel. |
| 515 |
.It Cm runparts Aq DIR |
| 516 |
Call |
| 517 |
.Xr run-parts 8 |
| 518 |
on |
| 519 |
.Cm DIR |
| 520 |
to run start scripts. All executable files, or scripts, in the |
| 521 |
directory are called, in alphabetic order. The scripts in this |
| 522 |
directory are executed at the very end of bootstrap, runlevel S. |
| 523 |
.Pp |
| 524 |
It can be beneficial to use |
| 525 |
.Cm S01name , |
| 526 |
.Cm S02othername , |
| 527 |
etc. if there is a dependency order between the scripts. Symlinks to |
| 528 |
existing daemons can talso be used, but make sure they daemonize by |
| 529 |
default. |
| 530 |
.Pp |
| 531 |
Similar to the |
| 532 |
.Pa /etc/rc.local |
| 533 |
shell script, make sure that all your services and programs either |
| 534 |
terminate or start in the background or you will block Finit. |
| 535 |
.Sy Note: |
| 536 |
only read and executed in runlevel S (bootstrap). |
| 537 |
.It Cm include Aq CONF |
| 538 |
Include another configuration file. Absolute path required. |
| 539 |
.It Cm log size:BYTES count:NUM |
| 540 |
Log rotation for run/task/services using the |
| 541 |
.Cm log |
| 542 |
command modifier with redirection to a log file. Global setting, |
| 543 |
applies to all services. |
| 544 |
.Pp |
| 545 |
The size can be given as bytes, without a specifier, or in `k`, `M`, |
| 546 |
or `G`, e.g. |
| 547 |
.Cm size:10M , |
| 548 |
or |
| 549 |
.Cm size:3G . |
| 550 |
A value of |
| 551 |
.Cm size:0 |
| 552 |
disables log rotation. The default is |
| 553 |
.Cm size:200k . |
| 554 |
.Pp |
| 555 |
The count value is recommended to be between 1-5, with a default 5. |
| 556 |
Setting count to 0 means the logfile will be truncated when the MAX |
| 557 |
size limit is reached. |
| 558 |
.It Cm tty Oo LVLS Oc Ao COND Ac Ar DEV Oo BAUD Oc Oo noclear Oc Oo nowait Oc Oo nologin Oc Oo TERM Oc |
| 559 |
This form of the |
| 560 |
.Cm tty |
| 561 |
directive uses the built-in getty on the given TTY device |
| 562 |
.Ar DEV , |
| 563 |
in the given runlevels. |
| 564 |
.Ar DEV may be the special keyword |
| 565 |
.Cm @console , |
| 566 |
or `console`, which is expanded from `/sys/class/tty/console/active`, |
| 567 |
useful on embedded systems. |
| 568 |
.Pp |
| 569 |
The default baud rate is 0, i.e., keep kernel default. |
| 570 |
.Pp |
| 571 |
The `tty` directive inherits runlevel, condition (and other feature) |
| 572 |
parsing from the `service` directive. So TTYs can run in one or many |
| 573 |
runlevels and depend on any condition supported by Finit. This is |
| 574 |
useful e.g. to depend on `<pid/elogind>` before starting a TTY. |
| 575 |
.Bd -unfilled -offset indent |
| 576 |
tty [12345] /dev/ttyAMA0 115200 noclear vt220 |
| 577 |
.Ed |
| 578 |
.It Cm tty Oo LVLS Oc Ao COND Ac Ar CMD DEV Oo noclear Oc Oo nowait Oc |
| 579 |
This form of the |
| 580 |
.Cm tty |
| 581 |
directive is for using an external getty, like agetty or the BusyBox getty. |
| 582 |
.Pp |
| 583 |
By default, these first two syntax variants |
| 584 |
.Em clear |
| 585 |
the TTY and |
| 586 |
.Em wait |
| 587 |
for the user to press enter before starting getty. |
| 588 |
.Bd -unfilled -offset indent |
| 589 |
tty [12345] /sbin/getty -L 115200 /dev/ttyAMA0 vt100 |
| 590 |
tty [12345] /sbin/agetty -L ttyAMA0 115200 vt100 nowait |
| 591 |
.Ed |
| 592 |
.Pp |
| 593 |
The |
| 594 |
.Cm noclear |
| 595 |
option disables clearing the TTY after each session. Clearing the TTY |
| 596 |
when a user logs out is usually preferable. |
| 597 |
.Pp |
| 598 |
The |
| 599 |
.Cm nowait |
| 600 |
option disables the |
| 601 |
.Cm Please press Enter to activate console |
| 602 |
message before actually starting the getty program. On small and |
| 603 |
embedded systems running multiple unused getty wastes both memory and |
| 604 |
CPU cycles, so `wait` is the preferred default. |
| 605 |
.Pp |
| 606 |
The |
| 607 |
.Cm nologin |
| 608 |
option disables getty and |
| 609 |
.Pa /bin/login , |
| 610 |
and gives the user a root (login) shell on the given TTY |
| 611 |
.Cm DEV |
| 612 |
immediately. Needless to say, this is a rather insecure option, but can |
| 613 |
be very useful for developer builds, during board bringup, or similar. |
| 614 |
.Pp |
| 615 |
Notice the ordering, the |
| 616 |
.Cm TERM |
| 617 |
option to the built-in getty must be the last argument. |
| 618 |
.Pp |
| 619 |
Embedded systems may want to enable automatic `DEV` by supplying the |
| 620 |
special |
| 621 |
.Cm @console |
| 622 |
device. This works regardless weather the system uses |
| 623 |
.Cm ttyS0 , ttyAMA0 , ttyMXC0 , |
| 624 |
or anything else. Finit figures it out by querying sysfs: |
| 625 |
.Pa /sys/class/tty/console/active . |
| 626 |
The speed can be omitted to keep the kernel default. |
| 627 |
.Pp |
| 628 |
Most systems get by fine by just using `console`, which will evaluate |
| 629 |
to |
| 630 |
.Pa /dev/console . |
| 631 |
If you have to use |
| 632 |
.Cm @console |
| 633 |
to get any output, you may have some issue with your kernel config. |
| 634 |
.Bd -unfilled -offset indent |
| 635 |
tty [12345] @console noclear vt220 |
| 636 |
.Ed |
| 637 |
.Pp |
| 638 |
On really bare bones systems, or for board bringup, Finit can give you a |
| 639 |
shell prompt as soon as bootstrap is done, without opening any device |
| 640 |
node: |
| 641 |
.Bd -unfilled -offset indent |
| 642 |
tty [12345789] notty |
| 643 |
.Ed |
| 644 |
.Pp |
| 645 |
This should of course not be enabled on production systems. Because it |
| 646 |
may give a user root access without having to log in. However, for |
| 647 |
board bringup and system debugging it can come in handy. |
| 648 |
.Pp |
| 649 |
One can also use the |
| 650 |
.Cm service |
| 651 |
directive to start a stand-alone shell: |
| 652 |
.Bd -unfilled -offset indent |
| 653 |
service [12345] /bin/sh -l |
| 654 |
.Ed |
| 655 |
.Pp |
| 656 |
.It Cm tty Oo LVLS Oc Ao COND Ac Oo notty Oc Oo rescue Oc |
| 657 |
The third |
| 658 |
.Cm tty |
| 659 |
form is for board bringup and the |
| 660 |
.Cm rescue |
| 661 |
boot mode. No device node is required in this variant, the same output |
| 662 |
that the kernel uses is reused for stdio. If the |
| 663 |
.Cm rescue |
| 664 |
option is omitted, a shell is started. The flags |
| 665 |
.Cm nologin , noclear , |
| 666 |
and |
| 667 |
.Cm nowait |
| 668 |
are implied. If the |
| 669 |
.Cm rescue |
| 670 |
option is set the bundled |
| 671 |
.Pa /libexec/finit/sulogin |
| 672 |
is started to present a bare-bones root login prompt. If the root |
| 673 |
(uid:0, gid:0) user does not have a password set, no rescue is possible. |
| 674 |
.El |
| 675 |
.Sh COMMAND MODIFIERS |
| 676 |
The run/task/tty/service/sysv directives take modifiers, or options, to |
| 677 |
control their behavior. This section lists them with their limitations. |
| 678 |
All modifiers must be placed between the directive and its command. |
| 679 |
.Bl -tag -width 1n |
| 680 |
.It Cm @user:group |
| 681 |
Every |
| 682 |
.Cm run , task , |
| 683 |
or |
| 684 |
.Cm service |
| 685 |
can also list the privileges the |
| 686 |
.Cm /path/to/cmd |
| 687 |
should be executed with. Prefix the command with |
| 688 |
.Cm @USR[:GRP] , |
| 689 |
group is optional, like this: |
| 690 |
.Bd -unfilled -offset indent |
| 691 |
run [2345] @joe:users logger "Hello world" |
| 692 |
.Ed |
| 693 |
.Pp |
| 694 |
For multiple instances of the same command, e.g. a DHCP client or |
| 695 |
multiple web servers, add |
| 696 |
.Cm :ID |
| 697 |
somewhere between the |
| 698 |
.Cm run , task , service |
| 699 |
keyword and the command, like this: |
| 700 |
.Bd -unfilled -offset indent |
| 701 |
service :80 [2345] httpd -f -h /http -p 80 -- Web server |
| 702 |
service :8080[2345] httpd -f -h /http -p 8080 -- Old web server |
| 703 |
.Ed |
| 704 |
.Pp |
| 705 |
Without the |
| 706 |
.Cm :ID |
| 707 |
to the service the latter will overwrite the former and only the old web |
| 708 |
server would be started and supervised. |
| 709 |
.It Cm log:/path/to/file |
| 710 |
Redirect stdout/stderr of a command to the given log file. See the |
| 711 |
global log directive, above, for details on log rotation. |
| 712 |
.It Cm log:console |
| 713 |
Redirect stdout/stderr of a command to |
| 714 |
.Pa /dev/console , |
| 715 |
only use this for debugging or bringup. |
| 716 |
.It Cm log:null |
| 717 |
Redirect stdout/stderr of a command to |
| 718 |
.Pa /dev/null . |
| 719 |
.It Cm log:prio:facility.level,tag:ident |
| 720 |
Redirect stdout/stderr of a command to syslog using the given priority |
| 721 |
and tag identity. |
| 722 |
.Bd -unfilled -offset indent |
| 723 |
service log:prio:user.warn,tag:ntpd /sbin/ntpd pool.ntp.org -- NTP daemon |
| 724 |
.Ed |
| 725 |
.It Cm log |
| 726 |
Default |
| 727 |
.Cm prio |
| 728 |
is |
| 729 |
.Cm daemon.info |
| 730 |
and the default |
| 731 |
.Cm tag |
| 732 |
identity is the basename of the service or run/task command. |
| 733 |
.El |
| 734 |
.Sh RESCUE MODE |
| 735 |
Finit supports a rescue mode which is activated by the |
| 736 |
.Cm rescue |
| 737 |
option on the kernel command line. The rescue mode comes in two |
| 738 |
flavors: |
| 739 |
.Em traditional |
| 740 |
and |
| 741 |
.Em fallback . |
| 742 |
.Ss Traditional |
| 743 |
This is what most users expect. A very early maintenance login prompt, |
| 744 |
served by the bundled |
| 745 |
.Pa /libexec/finit/sulogin |
| 746 |
program, or the standard |
| 747 |
.Cm sulogin |
| 748 |
from util-linux or BusyBox is searched for in the UNIX default |
| 749 |
.Cm $PATH . |
| 750 |
If a successful login is made, or the user exits (Ctrl-D), the rescue |
| 751 |
mode is ended and the system boots up normally. |
| 752 |
.Pp |
| 753 |
.Sy Note: |
| 754 |
if the user (UID 0 and GID 0) does not have a password, or |
| 755 |
.Em the account is locked , |
| 756 |
the user is presented with a password-less prompt: |
| 757 |
.Cm "Press enter to enter maintenance mode." , |
| 758 |
which opens up a root shell. |
| 759 |
.Ss Fallback |
| 760 |
If no |
| 761 |
.Cm sulogin |
| 762 |
program is found, Finit tries to bring up as much of its own |
| 763 |
functionality as possible, yet limiting many aspects, meaning; no |
| 764 |
network, no`fsck` of file systems in |
| 765 |
.Pa /etc/fstab , |
| 766 |
no |
| 767 |
.Pa /etc/rc.local , |
| 768 |
no |
| 769 |
.Cm runparts , |
| 770 |
and most plugins are skipped (except those that provide functionality |
| 771 |
for the condition subsystem). |
| 772 |
.Pp |
| 773 |
Instead of reading |
| 774 |
.Pa /etc/finit.conf |
| 775 |
et al, system configuration is read from |
| 776 |
.Pa /lib/finit/rescue.conf , |
| 777 |
which can be freely modified by the system administrator. |
| 778 |
.Pp |
| 779 |
The bundled default `rescue.conf` contains nothing more than: |
| 780 |
.Bd -unfilled -offset indent |
| 781 |
runlevel 1 |
| 782 |
tty [12345] rescue |
| 783 |
.Ed |
| 784 |
.Pp |
| 785 |
The |
| 786 |
.Cm tty |
| 787 |
has the |
| 788 |
.Cm rescue |
| 789 |
option set, which works similar to the board bring-up tty option |
| 790 |
.Cm notty . |
| 791 |
The major difference being that `sulogin` is started to query for |
| 792 |
root/admin password. If |
| 793 |
.Cm sulogin |
| 794 |
is not found, |
| 795 |
.Cm rescue |
| 796 |
behaves like |
| 797 |
.Cm notty |
| 798 |
and gives a plain root shell prompt. |
| 799 |
.Pp |
| 800 |
If Finit cannot find |
| 801 |
.Pa /lib/finit/rescue.conf |
| 802 |
it defaults to: |
| 803 |
.Bd -unfilled -offset indent |
| 804 |
tty [12345] rescue |
| 805 |
.Ed |
| 806 |
.Pp |
| 807 |
There is no way to exit the |
| 808 |
.Em fallback |
| 809 |
rescue mode. |
| 810 |
.Sh SERVICE ENVIRONMENT |
| 811 |
Finit supports sourcing environment variables from |
| 812 |
.Pa /etc/default/* , |
| 813 |
or similar. This is a common pattern from SysV init scripts, where the |
| 814 |
start/stop script is a generic script for the given service, |
| 815 |
.Cm foo , |
| 816 |
and the options for the service are sourced from the file |
| 817 |
.Pa /etc/default/foo . |
| 818 |
Like this: |
| 819 |
.Bd -unfilled -offset indent |
| 820 |
/etc/default/foo: |
| 821 |
|
| 822 |
FOO_OPTIONS=--extra-arg="bar" -s -x |
| 823 |
|
| 824 |
/etc/finit.conf: |
| 825 |
|
| 826 |
service [2345] env:-/etc/default/foo foo -n $FOO_OPTIONS -- Example foo daemon |
| 827 |
.Ed |
| 828 |
.Pp |
| 829 |
Here the service |
| 830 |
.Cm foo |
| 831 |
is started with |
| 832 |
.Op Fl -n , |
| 833 |
to make sure it runs in the foreground, and the with the options found |
| 834 |
in the environment file. With the |
| 835 |
.Cm ps |
| 836 |
command we can see that the process is started with: |
| 837 |
.Bd -unfilled -offset indent |
| 838 |
foo -n --extra-arg=bar -s -x |
| 839 |
.Ed |
| 840 |
.Pp |
| 841 |
.Sy Note: |
| 842 |
the leading `-` determines if Finit should treat a missing environment |
| 843 |
file as blocking the start of the service or not. When `-` is used, a |
| 844 |
missing environment file does |
| 845 |
.Em not |
| 846 |
block the start. |
| 847 |
.Sh SERVICE WRAPPER SCRIPTS |
| 848 |
If your service requires to run additional commands, executed before the |
| 849 |
service is actually started, like the systemd `ExecStartPre`, you can |
| 850 |
use a wrapper shell script to start your service. |
| 851 |
.Pp |
| 852 |
The Finit service |
| 853 |
.Cm .conf |
| 854 |
file can be put into |
| 855 |
.Pa /etc/finit.d/available , |
| 856 |
so you can control the service using |
| 857 |
.Cm initctl . |
| 858 |
Then use the path to the wrapper script in the Finit |
| 859 |
.Cm .conf |
| 860 |
service stanza. The following example employs a wrapper script in |
| 861 |
.Pa /etc/start.d . |
| 862 |
.Bd -unfilled |
| 863 |
/etc/finit.d/available/program.conf: |
| 864 |
|
| 865 |
service [235] <!> /etc/start.d/program -- Example Program |
| 866 |
|
| 867 |
/etc/start.d/program: |
| 868 |
|
| 869 |
#!/bin/sh |
| 870 |
# Prepare the command line options |
| 871 |
OPTIONS="-u $(cat /etc/username)" |
| 872 |
|
| 873 |
# Execute the program |
| 874 |
exec /usr/bin/program $OPTIONS |
| 875 |
.Ed |
| 876 |
.Pp |
| 877 |
.Sy Note: |
| 878 |
the example sets |
| 879 |
.Cm <!> |
| 880 |
to denote that it doesn't support SIGHUP. That way Finit will |
| 881 |
stop/start the service instead of sending SIGHUP at restart/reload |
| 882 |
events. |
| 883 |
.Sh TEMPLATING |
| 884 |
Finit comes with rudimentary support for templating, similar to that of |
| 885 |
systemd. Best illustrated with an example: |
| 886 |
.Bd -unfilled -offset indent |
| 887 |
$ initctl show avahi-autoipd@ |
| 888 |
service :%i avahi-autoipd --syslog %i -- ZeroConf for %i |
| 889 |
.Ed |
| 890 |
.Pp |
| 891 |
To enable ZeroConf for, e.g., |
| 892 |
.Cm eth0 , |
| 893 |
use |
| 894 |
.Bd -unfilled -offset indent |
| 895 |
$ initctl enable [email protected] |
| 896 |
.Ed |
| 897 |
.Pp |
| 898 |
The enabled symlink will be set up to |
| 899 |
.Cm [email protected] |
| 900 |
and every instance of |
| 901 |
.Cm %i |
| 902 |
will in the instantiated directive be replaced with |
| 903 |
.Cm eth0 . |
| 904 |
Inspect the result with: |
| 905 |
.Bd -unfilled -offset indent |
| 906 |
$ initctl status avahi-autoipd:eth0 |
| 907 |
.Ed |
| 908 |
.Sh CGROUPS |
| 909 |
There are three major cgroup configuration directives: |
| 910 |
.Pp |
| 911 |
.Bl -enum -offset indent -compact |
| 912 |
.It |
| 913 |
Global top-level group: init, system, user, or a custom group |
| 914 |
.It |
| 915 |
Selecting a top-level group for a set of run/task/services |
| 916 |
.It |
| 917 |
Per run/task/service limits |
| 918 |
.El |
| 919 |
.Pp |
| 920 |
Top-level group configuration. |
| 921 |
.Bd -unfilled -offset indent |
| 922 |
# Top-level cgroups and their default settings. All groups mandatory |
| 923 |
# but more can be added, max 8 groups in total currently. The cgroup |
| 924 |
# 'root' is also available, reserved for RT processes. Settings are |
| 925 |
# as-is, only one shorthand 'mem.' exists, other than that it's the |
| 926 |
# cgroup v2 controller default names. |
| 927 |
cgroup init cpu.weight:100 |
| 928 |
cgroup user cpu.weight:100 |
| 929 |
cgroup system cpu.weight:9800 |
| 930 |
.Ed |
| 931 |
.Pp |
| 932 |
Adding an extra cgroup |
| 933 |
.Cm maint/ |
| 934 |
will require you to adjust the weight of the above three. We leave |
| 935 |
.Cm init/ |
| 936 |
and |
| 937 |
.Cm user/ |
| 938 |
as-is reducing weight of |
| 939 |
.Cm system/ |
| 940 |
to 9700. |
| 941 |
.Bd -unfilled -offset indent |
| 942 |
cgroup system cpu.weight:9700 |
| 943 |
|
| 944 |
# Example extra cgroup 'maint' |
| 945 |
cgroup maint cpu.weight:100 |
| 946 |
.Ed |
| 947 |
.Pp |
| 948 |
By default, the |
| 949 |
.Cm system/ |
| 950 |
cgroup is selected for almost everything. The |
| 951 |
.Cm init/ |
| 952 |
cgroup is reserved for PID 1 itself and its closest relatives. The |
| 953 |
.Cm user/ |
| 954 |
cgroup is for local TTY logins spawned by getty. |
| 955 |
.Pp |
| 956 |
To select a different top-level cgroup, e.g. |
| 957 |
.Cm maint/ , |
| 958 |
one can either define it for a group of run/task/service directives in a |
| 959 |
.Cm .conf |
| 960 |
or per each stanza: |
| 961 |
.Bd -unfilled -offset indent |
| 962 |
cgroup.maint |
| 963 |
service [...] <...> /path/to/foo args -- description |
| 964 |
service [...] <...> /path/to/bar args -- description |
| 965 |
.Ed |
| 966 |
.Pp |
| 967 |
or |
| 968 |
.Bd -unfilled -offset indent |
| 969 |
service [...] <...> cgroup.maint /path/to/foo args -- description |
| 970 |
.Ed |
| 971 |
.Pp |
| 972 |
The latter form also allows per-stanza limits on the form (notice the |
| 973 |
single quotes for arguments that contain spaces): |
| 974 |
.Bd -unfilled -offset indent |
| 975 |
service [...] <...> cgroup.maint:cpu.max:'200000 100000',mem.max:655360 /path/to/foo args -- description |
| 976 |
.Ed |
| 977 |
.Pp |
| 978 |
Notice the comma separation and the |
| 979 |
.Cm mem. |
| 980 |
exception to the rule: every cgroup setting maps directly to cgroup v2 |
| 981 |
syntax. I.e., |
| 982 |
.Cm cpu.max |
| 983 |
maps to the file |
| 984 |
.Pm /sys/fs/cgroup/maint/foo/cpu.max . |
| 985 |
There is no filtering, except for expanding the shorthand |
| 986 |
.Cm mem. |
| 987 |
to |
| 988 |
.Cm memory. , |
| 989 |
if the file is not available, either the cgroup controller is not |
| 990 |
available in your Linux kernel, or the name is misspelled. |
| 991 |
.Pp |
| 992 |
Linux cgroups and details surrounding values are not explained in the |
| 993 |
Finit documentation. The Linux admin-guide cover this well: |
| 994 |
.Lk https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v2.html |
| 995 |
.Sh CONDITIONAL LOADING |
| 996 |
Finit support conditional loading of stanzas. The following example is |
| 997 |
take from the |
| 998 |
.Pa system/hotplug.conf |
| 999 |
file in the Finit distribution. Here we only show a simplified subset. |
| 1000 |
.Pp |
| 1001 |
Starting with the |
| 1002 |
.Cm nowarn |
| 1003 |
option. |
| 1004 |
.Bd -unfilled -offset indent |
| 1005 |
service nowarn name:udevd pid:udevd /lib/systemd/systemd-udevd |
| 1006 |
service nowarn name:udevd pid:udevd udevd |
| 1007 |
.Ed |
| 1008 |
.Pp |
| 1009 |
When loading the .conf file Finit looks for |
| 1010 |
.Pa /lib/systemd/systemd-udevd |
| 1011 |
if that is not found Finit automatically logs a warning. The |
| 1012 |
.Cm nowarn |
| 1013 |
option disables this warning so that the second line can be evaluated, |
| 1014 |
which also provides a service named |
| 1015 |
.Cm udevd . |
| 1016 |
.Bd -unfilled -offset indent |
| 1017 |
run nowarn if:udevd <pid/udevd> :1 udevadm settle -t 0 |
| 1018 |
.Ed |
| 1019 |
.Pp |
| 1020 |
This line is only loaded if we know of a service named |
| 1021 |
.Cm udevd . |
| 1022 |
Again, we do not warn if |
| 1023 |
.Cm udevadm |
| 1024 |
is not found, execution will also stop here until the PID condition is |
| 1025 |
asserted, i.e., Finit detecting udevd has started. |
| 1026 |
.Bd -unfilled -offset indent |
| 1027 |
run nowarn conflict:udevd [S] mdev -s -- Populating device tree |
| 1028 |
.Ed |
| 1029 |
.Pp |
| 1030 |
If |
| 1031 |
.Cm udevd |
| 1032 |
is not available, we try to run |
| 1033 |
.Cm mdev , |
| 1034 |
but if that is not found, again we do not warn. |
| 1035 |
.Pp |
| 1036 |
Conditional loading statements can also be negated, so the previous stanza |
| 1037 |
can also be written as: |
| 1038 |
.Bd -unfilled -offset indent |
| 1039 |
run nowarn if:!udevd [S] mdev -s -- Populating device tree |
| 1040 |
.Ed |
| 1041 |
.Pp |
| 1042 |
The reason for using |
| 1043 |
.Cm conflict |
| 1044 |
in this example is that a conflict can be resolved. Stanzas marked with |
| 1045 |
.C, conflict:foo |
| 1046 |
are rechecked at runtime. |
| 1047 |
.Sh CONDITIONAL EXECUTION |
| 1048 |
Similar to conditional loading of stanzas there is conditional runtime |
| 1049 |
execution. This can be confusing at first, since Finit already has a |
| 1050 |
condition subsystem, but this is more akin to the qualification to a |
| 1051 |
runlevel. E.g., a |
| 1052 |
.Cm task [123] |
| 1053 |
is qualified to run only in runlevel 1, 2, and 3. It is not considered |
| 1054 |
for other runlevels. |
| 1055 |
.Pp |
| 1056 |
Conditional execution qualify a run/task/service based on a condition. |
| 1057 |
Consider this (simplified) example from the Infix operating system: |
| 1058 |
.Bd -unfilled -offset indent |
| 1059 |
run [S] name:startup <pid/sysrepo> confd -b --load startup-config |
| 1060 |
run [S] if:<usr/fail-startup> name:failure <pid/sysrepo> confd --load failure-config |
| 1061 |
.Ed |
| 1062 |
.Pp |
| 1063 |
The two run statements reside in the same .conf file so Finit runs them |
| 1064 |
in true sequence. If loading the file |
| 1065 |
.Cm startup-config |
| 1066 |
fails |
| 1067 |
.Cm confd |
| 1068 |
sets the condition |
| 1069 |
.Cm usr/fail-startup , |
| 1070 |
thus allowing the next run statement to load |
| 1071 |
.Cm failure-config . |
| 1072 |
.Pp |
| 1073 |
Notice the critical difference between the |
| 1074 |
.Cm <pid/sysrepo> |
| 1075 |
condition and |
| 1076 |
.Cm if:<usr/fail-startup> . |
| 1077 |
The former is a condition for starting and the latter is a condition to |
| 1078 |
check if a run/task/service is qualified to even be considered. |
| 1079 |
.Pp |
| 1080 |
Conditional execution statements can also be negated, so provided the |
| 1081 |
file loaded did the opposite, i.e., set a condition on success, the |
| 1082 |
previous stanza can also be written as: |
| 1083 |
.Bd -unfilled -offset indent |
| 1084 |
run [S] if:<!usr/startup-ok> name:failure <pid/sysrepo> confd ... |
| 1085 |
.Ed |
| 1086 |
.Sh LIMITATIONS |
| 1087 |
As of Finit v4 there are no limitations to where |
| 1088 |
.Cm .conf |
| 1089 |
settings can be placed. Except for the system/global |
| 1090 |
.Cm rlimit |
| 1091 |
and |
| 1092 |
.Cm cgroup |
| 1093 |
top-level group declarations, which can only be set from |
| 1094 |
.Pa /etc/finit.conf , |
| 1095 |
since it is the first |
| 1096 |
.Cm .conf |
| 1097 |
file Finit reads. |
| 1098 |
.Pp |
| 1099 |
Originally, |
| 1100 |
.Pp /etc/finit.conf |
| 1101 |
was the only way to set up a Finit system. Today it is mainly used for |
| 1102 |
bootstrap settings like system hostname, early module loading for |
| 1103 |
watchdogd, network bringup and system shutdown. These can now also be |
| 1104 |
set in any |
| 1105 |
.Cm .conf |
| 1106 |
file in |
| 1107 |
.Pa /etc/finit.d . |
| 1108 |
.Pp |
| 1109 |
There is, however, nothing preventing you from having all configuration |
| 1110 |
settings in |
| 1111 |
.Pa /etc/finit.conf . |
| 1112 |
.Sh SEE ALSO |
| 1113 |
.Xr finit 8 , |
| 1114 |
.Xr initctl 8 |
| 1115 |
.Sh AUTHORS |
| 1116 |
.Nm Finit |
| 1117 |
was conceived and reverse engineered by Claudio Matsuoka. Since v1.0, |
| 1118 |
maintained by Joachim Wiberg, with contributions by many others. |