[systemd-devel] start service only on specific exit status of some prog

Marius Tolzmann tolzmann at molgen.mpg.de
Wed Aug 24 09:25:40 PDT 2011


On 24.08.2011 16:01, Lennart Poettering wrote:
> On Tue, 02.08.11 17:06, Marius Tolzmann (tolzmann at molgen.mpg.de) wrote:
>>
>> is there a way to execute a program and take its exit status to
>> evaluate the condition? like ConditionExec or whatever.
>>
>> is this already possible without getting a "failed" service?
>
> Hmm, so I think we should make sure that systemd unit files don't become
> a programming language. i.e. there needs to be a limit on what we want
> to allow to be expressed in unit files. I am tempted to say that checks
> like this are probably beyond that limit, and fall into the domain where
> shell scripts should be used. I.e. write a tiny shell script that is
> executed in ExecStartPre invokes your tool, checks the return code and
> then fails if needed.

Hi... thanks for the reply..

i really don't want to implement complex checks within unit files.. but 
currently systemd lacks a clean possibility to implement complex checks 
outside of unit files.

I first tried the StartExecPre= approach.. but it turns out to be 
somehow destructive in combination with Restart=always.. and you end 
with a failed service.

Currently we have a unit that starts a script which starts other units 
via systemctl.. it works.. but this too is not really nice, because you 
can still directly start those unit files by mistake and they won't 
complain about any external conditions..

since i can't figure out a nice way to evaluate complex conditions i 
asked for some help here and proposed something like 
ConditionExec=/some/prog to be able to implement some small c-program to 
do complex condition checking outside of systemd... We just need a way 
to integrate the result without loosing some cool systemd features.. 8)

may be this could be implemented in future releases or is this a real no-go?

regards, marius..


More information about the systemd-devel mailing list