mirror of
https://github.com/troglobit/finit.git
synced 2026-10-01 21:42:40 +07:00
In 7447192 we dropped support for 'cond set' and 'cond clear' commands
with the motivation they were unsafe and sent the wrong message to the
user. That was true, but mostly because it was too generic and required
the user to call `initctl reload` to apply the changes.
This patch restores the behavior, albeit in a very reduced and simple
format. All conditions set with this command are constrained to the
'usr/...' namespace. No subdirectories are allowed. The argument to
the 'cond set|clear' command is disallowed if it contains '/' or '.'
but anything else is supported, for example:
initctl cond set foo:2
creates a static/oneshot condition in /run/finit/cond/usr/foo:2
These conditions are static and are fully handled by the user. The
initctl command is the recommended, and only supported, way of setting
and clearing usr conditions.
This patch also includes a new plugin, usr.so, which is a very simple
inotify plugin for the /run/finit/cond/usr/ directory. When files are
created or removed here the plugin tells the Finit condition engine to
update and trigger service changes.
For instance, the following service is not started by default at boot:
service <usr/foo> myservice -- MyService
However, as soon as `initctl cond set foo` is called, myservice starts.
Consequently, it is stopped when `initctl cond clr foo` is called.
Another major difference from the original is that this implementation
doesn't send IPC commands to create/delete the conditions. This makes
calling these new commands non-blocking so they can be used very early
in the bootstrap, by plugins, if needed.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
74 lines
1.7 KiB
Makefile
74 lines
1.7 KiB
Makefile
pkglibdir = $(plugin_path)
|
|
AM_LDFLAGS = -module -avoid-version -shared
|
|
AM_CFLAGS = -W -Wall -Wextra -Wno-unused-parameter -std=gnu99
|
|
AM_CPPFLAGS = -I$(top_srcdir)/src -U_FORTIFY_SOURCE
|
|
AM_CPPFLAGS += -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_GNU_SOURCE -D_DEFAULT_SOURCE
|
|
AM_CPPFLAGS += $(lite_CFLAGS)
|
|
|
|
if STATIC
|
|
noinst_LTLIBRARIES = libplug.la
|
|
libplug_la_SOURCES = bootmisc.c modprobe.c rtc.c pidfile.c procps.c tty.c urandom.c usr.c
|
|
|
|
if BUILD_ALSA_UTILS_PLUGIN
|
|
libplug_la_SOURCES += alsa-utils.c
|
|
endif
|
|
|
|
if BUILD_DBUS_PLUGIN
|
|
libplug_la_SOURCES += dbus.c
|
|
endif
|
|
|
|
if BUILD_HOTPLUG_PLUGIN
|
|
libplug_la_SOURCES += hotplug.c
|
|
endif
|
|
|
|
if BUILD_MODULES_LOAD_PLUGIN
|
|
libplug_la_SOURCES += modules-load.c
|
|
endif
|
|
|
|
if BUILD_NETLINK_PLUGIN
|
|
libplug_la_SOURCES += netlink.c
|
|
endif
|
|
|
|
if BUILD_RESOLVCONF_PLUGIN
|
|
libplug_la_SOURCES += resolvconf.c
|
|
endif
|
|
|
|
else
|
|
pkglib_LTLIBRARIES = bootmisc.la modprobe.la rtc.la pidfile.la procps.la tty.la urandom.la usr.la
|
|
|
|
if BUILD_ALSA_UTILS_PLUGIN
|
|
pkglib_LTLIBRARIES += alsa-utils.la
|
|
endif
|
|
|
|
if BUILD_DBUS_PLUGIN
|
|
pkglib_LTLIBRARIES += dbus.la
|
|
endif
|
|
|
|
if BUILD_HOTPLUG_PLUGIN
|
|
pkglib_LTLIBRARIES += hotplug.la
|
|
endif
|
|
|
|
if BUILD_MODULES_LOAD_PLUGIN
|
|
pkglib_LTLIBRARIES += modules-load.la
|
|
endif
|
|
|
|
if BUILD_NETLINK_PLUGIN
|
|
pkglib_LTLIBRARIES += netlink.la
|
|
endif
|
|
|
|
if BUILD_RESOLVCONF_PLUGIN
|
|
pkglib_LTLIBRARIES += resolvconf.la
|
|
endif
|
|
|
|
if BUILD_X11_COMMON_PLUGIN
|
|
pkglib_LTLIBRARIES += x11-common.la
|
|
endif
|
|
|
|
# Clean up .la files installed by libtool despite being in -module mode
|
|
install-exec-hook:
|
|
@(cd $(DESTDIR)$(pkglibdir) && $(RM) $(pkglib_LTLIBRARIES))
|
|
|
|
uninstall-hook:
|
|
@(cd $(DESTDIR)$(pkglibdir) && for file in $(pkglib_LTLIBRARIES); do $(RM) `basename $$file .la`.so; done)
|
|
endif
|