Add support for starting/stopping services on Netlink events

This commit adds support for event based services to Finit.  Along with
the previously added support for multiple instances of the same process,
the feature scope for Finit v2.0 has been reached!

As of now a service can be declared in /etc/finit.conf or /etc/finit.d/
like this:

    service :1 [2345] <!IFUP:eth0,GW> /sbin/dropbear -R -F -p 22 -- SSH daemon

Here the first instance `:1` of dropbear is declared to run in runlevels
2-5, but only if eth0 `IFUP:eth0` is up and a gateway `GW` is set.  When
the configuration changes, a new gateway is set, or somehow a new `IFUP`
event for eth0 is received, then dropbear is not SIGHUP'ed, but instead
stop-started `<!>`.  The latter trick applies to all services, even
those that do not define any events.

Currently inetd services are not supported for event based starting, but
it could easily be added.  Likely scenario is to deny incoming requests
on, e.g., eth0 if there is no gateway.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2015-09-15 09:13:33 +02:00
1 parent ffa32c6674
commit 6e07dd8dec
9 files changed
+367 -26

No files matched your search

+1 -8
View File
@@ -18,16 +18,10 @@ very low dependency on external packages.
General
-------
* Add compile-time support for running `/bin/sh` instead of `getty`
* Add `!` or `[wait <pidfile>]` to service directive to let finit pause
and wait for a pidfile before starting processes -- both at boot and
when starting processes in a runlevel.
* Add `<GW,ADDR:iface,IF:iface>` events to service stanza so services
can be reloaded/restarted/stopped -- e.g, new GW --> SIGHUP process,
or loss of `IF:eth1` --> stop service, start it when eth1 comes up
again.
* Add support for listening to netlink messages for GW, ADDR, IF UP/DOWN
* Add `<!,...>` to let Finit know that a service does not support reload
(`SIGHUP`), but must be restarted (stop+start)
* Allow custom reload for processes like libreSwan's pluto
service [2345] <!gw,if:eth0,reload:'starter reload'> /sbin/pluto
@@ -38,7 +32,6 @@ General
`.monitor=` in `svc_t` ... the script named as the basename of the
service it monitors + `.sh`.
* Add support for `/etc/sysctl.d`
* Add compile-time supoprt for running `/bin/sh` instead of `getty`
* Implement `initctl stop|start|restart|reload|status <SVC>` and
`service <SVC> stop|start|restart|reload|status` on top
* Add PRE and POST hooks for when switching between runlevels