22.\" First parameter, NAME, should be all caps
33.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
44.\" other parameters are allowed: see man(7), man(1)
5- .Dd July 11, 2023
5+ .Dd July 10, 2025
66.Dt FINIT.CONF 5 SMM
77.Os Linux
88.Sh NAME
@@ -178,7 +178,7 @@ Similar to
178178.Cm service
179179is the
180180.Cm sysv
181- stanza , which can be used to call SysV style start/stop scripts. The
181+ directive , which can be used to call SysV style start/stop scripts. The
182182primary intention for this command is to be able to re-use traditional
183183SysV init scripts in Linux distributions.
184184.Pp
194194.Cm initctl reload .
195195Similar to how
196196.Cm service
197- stanzas work.
197+ directives work.
198198.Pp
199199Forking services started with
200200.Cm sysv
@@ -416,7 +416,30 @@ The post:script is called with the same environment variables
416416for the
417417.Cm EXIT_CODE
418418variable which is set to
419- .Cm " crashed" .
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 .
420443.El
421444.Pp
422445When stopping a service (run/task/sysv/service), either manually or when
@@ -535,7 +558,7 @@ size limit is reached.
535558.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
536559This form of the
537560.Cm tty
538- stanza uses the built-in getty on the given TTY device
561+ directive uses the built-in getty on the given TTY device
539562.Ar DEV ,
540563in the given runlevels.
541564.Ar DEV may be the special keyword
@@ -545,8 +568,8 @@ useful on embedded systems.
545568.Pp
546569The default baud rate is 0, i.e., keep kernel default.
547570.Pp
548- The `tty` stanza inherits runlevel, condition (and other feature)
549- parsing from the `service` stanza . So TTYs can run in one or many
571+ The `tty` directive inherits runlevel, condition (and other feature)
572+ parsing from the `service` directive . So TTYs can run in one or many
550573runlevels and depend on any condition supported by Finit. This is
551574useful e.g. to depend on `<pid/elogind>` before starting a TTY.
552575.Bd -unfilled -offset indent
@@ -555,7 +578,7 @@ tty [12345] /dev/ttyAMA0 115200 noclear vt220
555578.It Cm tty Oo LVLS Oc Ao COND Ac Ar CMD DEV Oo noclear Oc Oo nowait Oc
556579This form of the
557580.Cm tty
558- stanza is for using an external getty, like agetty or the BusyBox getty.
581+ directive is for using an external getty, like agetty or the BusyBox getty.
559582.Pp
560583By default, these first two syntax variants
561584.Em clear
@@ -625,7 +648,7 @@ board bringup and system debugging it can come in handy.
625648.Pp
626649One can also use the
627650.Cm service
628- stanza to start a stand-alone shell:
651+ directive to start a stand-alone shell:
629652.Bd -unfilled -offset indent
630653service [12345] /bin/sh -l
631654.Ed
@@ -650,9 +673,9 @@ is started to present a bare-bones root login prompt. If the root
650673(uid:0, gid:0) user does not have a password set, no rescue is possible.
651674.El
652675.Sh COMMAND MODIFIERS
653- The run/task/tty/service/sysv stanzas take modifiers, or options, to
676+ The run/task/tty/service/sysv directives take modifiers, or options, to
654677control their behavior. This section lists them with their limitations.
655- All modifiers must be placed between the stanza and its command.
678+ All modifiers must be placed between the directive and its command.
656679.Bl -tag -width 1n
657680.It Cm @user:group
658681Every
946969service [...] <...> cgroup.maint /path/to/foo args -- description
947970.Ed
948971.Pp
949- The latter form also allows per-stanza limits on the form:
972+ The latter form also allows per-stanza limits on the form (notice the
973+ single quotes for arguments that contain spaces):
950974.Bd -unfilled -offset indent
951- service [...] <...> cgroup.maint:cpu.max:10000 ,mem.max:655360 /path/to/foo args -- description
975+ service [...] <...> cgroup.maint:cpu.max:'200000 100000' ,mem.max:655360 /path/to/foo args -- description
952976.Ed
953977.Pp
954978Notice the comma separation and the
@@ -968,6 +992,97 @@ available in your Linux kernel, or the name is misspelled.
968992Linux cgroups and details surrounding values are not explained in the
969993Finit documentation. The Linux admin-guide cover this well:
970994.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
9711086.Sh LIMITATIONS
9721087As of Finit v4 there are no limitations to where
9731088.Cm .conf
0 commit comments