[systemd-devel] several Conditions (AND or OR)
Andrey Borzenkov
arvidjaar at mail.ru
Tue Feb 8 03:01:27 PST 2011
On Tue, Feb 8, 2011 at 1:47 PM, Alexey Shabalin <a.shabalin at gmail.com> wrote:
> On Tue, Feb 8, 2011 at 12:21 PM, Lennart Poettering wrote:
>> On Mon, 07.02.11 14:24, Alexey Shabalin wrote:
>>> How chenge (Condition1 || Condition2) to (Condition1 && Condition2)
>> 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.
>
> Ok. Let's look at fedora-storage-init.service and
This is bad example actually. Historically RH had monolithic startup
script so everything had to be stuffed into it and it required
extensive checks whether code applied at all. Having rc-like
rc.sysinit would render all those checks redundant, because every
package would install code together with all needed binaries.
> ExecStart=/lib/systemd/fedora-storage-init from initscripts in Fedora,
> for example.
> We see in fedora-storage-init
>
> if ! strstr "$cmdline" nompath && [ -f /etc/multipath.conf ] && \
> [ -x /sbin/multipath ]; then
> modprobe dm-multipath > /dev/null 2>&1
> /sbin/multipath -v 0
> if [ -x /sbin/kpartx ]; then
> /sbin/dmsetup ls --target multipath --exec
> "/sbin/kpartx -a -p p" >/dev/null
> fi
> fi
>
> it would be easier to see it as
> [Unit]
> ConditionKernelCommandLine=!nompath
> ConditionPathExists=/etc/multipath.conf
> ConditionPathExists=/sbin/multipath
> ConditionPathExists=/sbin/kpartx
>
> [Service]
> ExecStartPre=modprobe dm-multipath
> ExecStart=/sbin/multipath -v 0
> ExecStart=/sbin/dmsetup ls --target multipath --exec "/sbin/kpartx -a
> -p p" >/dev/null
>
Move this unit into multipath package and you are left with a single
condition - kernel command line.
More information about the systemd-devel
mailing list