[systemd-devel] and again about conditions

Alexey Shabalin a.shabalin at gmail.com
Fri May 20 08:42:41 PDT 2011


I want to check settings before starting the service.
Check only True or False.

For example, i can only install mdadm package, but have not configured
any raid disk. Then don't need run mdadm.service.

mdadm.service
[Unit]
ConditionKernelCommandLine=|!noraidtab
Condition... =| $(grep -qs
'^[[:space:]]*\(MAILADDR\|PROGRAM\)[[:space:]]\+[^[:space:]]'
/etc/mdadm.conf)
Condition... =| $(grep -qs '^md[0-9]\+[[:space:]]*:' /proc/mdstat)

or check in ExecStartPre and exit without run ExecStart
[Service]
ExecStartPre= grep -qs
'^[[:space:]]*\(MAILADDR\|PROGRAM\)[[:space:]]\+[^[:space:]]'
/etc/mdadm.conf || exit

-- 
Alexey Shabalin


More information about the systemd-devel mailing list