[systemd-devel] several Conditions (AND or OR)

Lennart Poettering lennart at poettering.net
Tue Feb 8 01:21:22 PST 2011


On Mon, 07.02.11 14:24, Alexey Shabalin (a.shabalin at gmail.com) wrote:

> Hello!
> I need define several conditions in [Unit].
> ConditionPathExists=/sbin/startevms
> ConditionKernelCommandLine=!noevms
> Service must run only if both conditions is true.
> Now service run if at least one condition is true.
> How chenge (Condition1 || Condition2)  to (Condition1 && Condition2)

Hmm, my recommendation in this case would be to drop the /sbin/startevms
check and instead just ship the service in the same package that
installs /sbin/startevms, so that the service file is available excatly
when the binary is around. (or to turn this around: how can it even
happen that the service file is around and enabled but the binary is not
installed?)

Note that my intention in adding the condition stuff was not so much
altering control flow but more to make available a way of optimizing the
boot where suppressing starting particular services makes things faster
but does not take away functionality. A typical example of this is
systemd-modules-load which when run with no config files in
/etc/modules-load.d does exactly nothing. The
ConditionDirectoryNotEmpty=/etc/modules-load.d line in its service file
hence has no actual effect -- with the expection of making things a bit
faster in the common case where no file exists in that directory.

I'd very much prefer not having to extend the condition language to more
than what it currently covers. So, before we think about this more, I'd
like to hear a very good use case for this. Your example doesn't really
convince me, and I'd suggest a different fix (see above) instead.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list