mirror of
https://github.com/troglobit/finit.git
synced 2026-10-28 12:30:44 +00:00
Add support for multiple if:!foo,!bar to skip loading of service
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
304a096877
commit
c886ecb5cc
2 files changed
+33
-25
No files matched your search
@@ -710,6 +710,7 @@ int svc_conflicts(svc_t *svc)
|
|||||||
*/
|
*/
|
||||||
int svc_ifthen(int is_conf, const char *ident, char *stmt)
|
int svc_ifthen(int is_conf, const char *ident, char *stmt)
|
||||||
{
|
{
|
||||||
|
char stmts[MAX_IDENT_LEN];
|
||||||
int not = 0;
|
int not = 0;
|
||||||
svc_t *svc;
|
svc_t *svc;
|
||||||
|
|
||||||
@@ -724,39 +725,46 @@ int svc_ifthen(int is_conf, const char *ident, char *stmt)
|
|||||||
if (is_conf)
|
if (is_conf)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (stmt[0] == '!') {
|
|
||||||
stmt++;
|
|
||||||
not++;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (ptr[i] != '>' && ptr[i] != 0)
|
while (ptr[i] != '>' && ptr[i] != 0)
|
||||||
i++;
|
i++;
|
||||||
ptr[i] = 0;
|
ptr[i] = 0;
|
||||||
|
|
||||||
cond = cond_get(stmt);
|
strlcpy(stmts, stmt, sizeof(stmts));
|
||||||
if (not && cond == COND_ON)
|
for (stmt = strtok(stmts, ","); stmt; stmt = strtok(NULL, ","), not = 0) {
|
||||||
return 0;
|
if (stmt[0] == '!') {
|
||||||
if (!not && cond == COND_OFF)
|
stmt++;
|
||||||
return 0;
|
not++;
|
||||||
|
}
|
||||||
|
|
||||||
|
cond = cond_get(stmt);
|
||||||
|
if (not && cond == COND_ON)
|
||||||
|
return 0;
|
||||||
|
if (!not && cond == COND_OFF)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_conf)
|
if (!is_conf)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (stmt[0] == '!') {
|
strlcpy(stmts, stmt, sizeof(stmts));
|
||||||
stmt++;
|
for (stmt = strtok(stmts, ","); stmt; stmt = strtok(NULL, ","), not = 0) {
|
||||||
not++;
|
if (stmt[0] == '!') {
|
||||||
}
|
stmt++;
|
||||||
|
not++;
|
||||||
|
}
|
||||||
|
|
||||||
svc = svc_find_by_str(stmt);
|
svc = svc_find_by_str(stmt);
|
||||||
if (not && svc) {
|
if (not && svc) {
|
||||||
logit(LOG_NOTICE, "skipping %s, %s already loaded.", ident, svc_ident(svc, NULL, 0));
|
logit(LOG_NOTICE, "skipping %s, %s already loaded.", ident, svc_ident(svc, NULL, 0));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!not && !svc) {
|
if (!not && !svc) {
|
||||||
logit(LOG_NOTICE, "skipping %s, %s not available.", ident, stmt);
|
logit(LOG_NOTICE, "skipping %s, %s not available.", ident, stmt);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ run nowarn if:udevd cgroup.init :5 [S] <pid/udevd> log udevadm settle -t 30
|
|||||||
# <run/coldplug/success> (same as for plain mdev below) can be relied on as a
|
# <run/coldplug/success> (same as for plain mdev below) can be relied on as a
|
||||||
# barrier for services that, e.g., need to probe for switchcore ports or PHYs
|
# barrier for services that, e.g., need to probe for switchcore ports or PHYs
|
||||||
# that require firmware loading before they show up.
|
# that require firmware loading before they show up.
|
||||||
service nowarn conflict:udevd,mdev cgroup.init \
|
service nowarn conflict:udevd,mdev cgroup.init if:!udevd \
|
||||||
[S12345789] notify:s6 mdevd -O 4 -D %n -- Device event daemon (mdevd)
|
[S12345789] notify:s6 mdevd -O 4 -D %n -- Device event daemon (mdevd)
|
||||||
run nowarn conflict:udevd,mdev cgroup.init name:coldplug <service/mdevd/ready> \
|
run nowarn conflict:udevd,mdev cgroup.init name:coldplug <service/mdevd/ready> \
|
||||||
[S] mdevd-coldplug -- Cold plugging system
|
[S] mdevd-coldplug -- Cold plugging system
|
||||||
@@ -42,12 +42,12 @@ run nowarn conflict:udevd,mdev cgroup.init name:coldplug <service/mdevd/read
|
|||||||
# If neither udevd or mdevd are available, fall back to mdev. The new daemon
|
# If neither udevd or mdevd are available, fall back to mdev. The new daemon
|
||||||
# mode calls `mdev -s` internally but does not create a PID file when that is
|
# mode calls `mdev -s` internally but does not create a PID file when that is
|
||||||
# done, so synchronization with coldplug is fragile.
|
# done, so synchronization with coldplug is fragile.
|
||||||
service nowarn conflict:udevd,mdevd cgroup.init if:!mdevd \
|
service nowarn conflict:udevd,mdevd cgroup.init if:!udevd,!mdevd \
|
||||||
[S12345789] mdev -df -S -- Device event daemon (mdev)
|
[S12345789] mdev -df -S -- Device event daemon (mdev)
|
||||||
|
|
||||||
# Trigger a replay of all uevents from boot, before userspace was up and the
|
# Trigger a replay of all uevents from boot, before userspace was up and the
|
||||||
# filesystem mounted. Compared to udevd, we don't know when 'mdev -df' has
|
# filesystem mounted. Compared to udevd, we don't know when 'mdev -df' has
|
||||||
# finished processing all events, i.e., depending on <run/coldplug/success> is
|
# finished processing all events, i.e., depending on <run/coldplug/success> is
|
||||||
# not an indicator of all devices having been (re)discovered and fully set up.
|
# not an indicator of all devices having been (re)discovered and fully set up.
|
||||||
run nowarn conflict:udevd,mdevd cgroup.init name:coldplug if:!mdevd <service/mdev/running> \
|
run nowarn conflict:udevd,mdevd cgroup.init name:coldplug if:mdev <service/mdev/running> \
|
||||||
[S] @pkglibexecdir@/coldplug -- Cold plugging system
|
[S] @pkglibexecdir@/coldplug -- Cold plugging system
|
||||||
Reference in new issue
Block a user