Files
finit/doc/config/templating.md
T
Joachim Wiberg b9ad9bcb21 doc: convert the documentation to the block format
The syntax overview no longer describes a line-based format, since that
is not what the rest of the documentation shows.  It now covers the
grammar, the two naming conventions, the nine aliases, and the leading
'-' on a path, and it says plainly that both formats are still read and
told apart per file by content.  Without that, a reader with an
existing configuration is left wondering what happened to it.

service-opts.md was a list of modifiers to place between a directive
and its command, so it needed rewriting rather than translating: there
are no positions left to describe.  It is now grouped by what the
settings do.

conditions.md needed correcting.  It presented '!' as a condition
prefix alongside '~'.  It is neither a condition nor a negation, it is
a flag on the block that means one thing on a service and another on a
run or task, so it is spelled reload-signal and required here, and the
page maps the old form to both.

Two things the pages claimed are not true.  The kill delay range is
1-300, not 1-60, and stop and reload scripts are no longer run without
a timeout.

ChangeLog.md keeps its line-based examples.  Those sit in historical
release entries, and rewriting them in a syntax that did not exist at
the time would misdate the format.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2026-07-30 15:21:31 +02:00

1.4 KiB

Templating

Finit comes with rudimentary support for templating, similar to that of systemd. Best illustrated with an example:

$ initctl show avahi-autoipd@
service avahi-autoipd:%i {
    description = "ZeroConf for %i"
    command     = "avahi-autoipd --syslog %i"
}

To enable ZeroConf for, e.g., eth0, use

$ initctl enable avahi-autoipd@eth0.conf

The enabled symlink will be set up to avahi-autoipd@.conf and every instance of %i will be replaced with eth0 before the file is parsed, so it works in the block title, in any value, and in the command line alike. Inspect the resulting instantiated template with initctl show avahi-autoipd:eth0 and check the status of a running instance with:

$ initctl status avahi-autoipd:eth0
     Status : running
   Identity : avahi-autoipd:eth0
Description : ZeroConf for eth0
     Origin : /etc/finit.d/enabled/avahi-autoipd@eth0.conf
Environment : -/etc/default/avahi-autoipd-eth0
    Command : avahi-autoipd $AVAHI_AUTOIPD_ARGS eth0
   PID file : /run/avahi-autoipd.eth0.pid
        PID : 4190
       User : root
      Group : root
     Uptime : 24 sec
   Restarts : 0 (0/10)
  Runlevels : [---2345-789]
     Memory : 20.0k
     CGroup : /system/avahi-autoipd@eth0 cpu 0 [100, max] mem [0, max]
              └─ 4190 avahi-autoipd: [eth0] bound 169.254.1.9  

Jul  8 11:51:42 infix-c0-ff-ee finit[1]: Starting avahi-autoipd:eth0[4190]