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

2011-11-01 Thread Lennart Poettering
On Thu, 25.08.11 13:09, Nick Jones (nick.jo...@network-box.com) wrote:

 
 On Wed, 2011-08-24 at 21:21 +0200, Lennart Poettering wrote: 
  On Wed, 24.08.11 21:12, Marius Tolzmann (tolzm...@molgen.mpg.de) wrote:
  
   
   On 24.08.2011 18:52, Lennart Poettering wrote:
   Hmm, yeah, if ExecStartPre= we put the unit in failure mode.
   
   So, let me see if I got this right: you are looking for something like
   ExecStartPre= but twhere the program when it returns non-zero should
   just cause the service to be skipped but not be put in failure state?
   
   Yes. that's my request.
   
   something like ConditionExec=/bin/true and ConditionExec=/bin/false
   so i can implement any thinkable logic outside of systemd and still
   maintain access to all features like Restart= etc.
   
   I thought this may be an easy way to expand the already existent
   conditions (ConditionPathExists= etc.)  without implementing too
   many special conditional tests in systemd itself. (e.g. check if the
   current hostname matches some pattern - which was my original issue
   i tried to solve) 8)
  
  I have now added this to the TODO list. It won't be easy to add this
  though, as execution extrernal processes synchronously is not an
  option. More likely I'll add an additional prefix char to ExecStart=
  (like -) which would indicate skip-on-fail or so.
  
  Lennart
  
 
 Would it make sense to emit a virtual unit label if a given unit
 fails?

That already exists with OnFailure=.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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

2011-08-25 Thread Barry Scott
On Wednesday 24 August 2011 17:25:40 Marius Tolzmann wrote:
 On 24.08.2011 16:01, Lennart Poettering wrote:
  On Tue, 02.08.11 17:06, Marius Tolzmann (tolzm...@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.
 

snip...

Why not have the complex logic run before the system reboots and
chaneg the systemd dependancies? For example in our application
a TV card is optional. We could check at run time during boot,
but it seemed cleaner to us to change the dependancies.

Barry
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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

2011-08-24 Thread Lennart Poettering
On Tue, 02.08.11 17:06, Marius Tolzmann (tolzm...@molgen.mpg.de) wrote:

 
 hi..
 
 since conditions specifying wheter a service should start are
 somehow limited to the existence of some files/directories/etc. i
 was searching for something more complex to handle conditional
 service starts.
 
 is there a way to execute a program and take its exit status to
 evaluate the condition? like ConditionExec or whatever.
 
 currently we need a service that only starts if the current hostname
 matches some value, i.e. only start service on hostA.
 
 or we need to start a service only if some special IP is configured
 on a network interface.
 
 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.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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

2011-08-24 Thread Marius Tolzmann

On 24.08.2011 16:01, Lennart Poettering wrote:

On Tue, 02.08.11 17:06, Marius Tolzmann (tolzm...@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..
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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

2011-08-24 Thread Marius Tolzmann

On 24.08.2011 18:52, Lennart Poettering wrote:

Hmm, yeah, if ExecStartPre= we put the unit in failure mode.

So, let me see if I got this right: you are looking for something like
ExecStartPre= but twhere the program when it returns non-zero should
just cause the service to be skipped but not be put in failure state?


Yes. that's my request.

something like ConditionExec=/bin/true and ConditionExec=/bin/false so i 
can implement any thinkable logic outside of systemd and still maintain 
access to all features like Restart= etc.


I thought this may be an easy way to expand the already existent 
conditions (ConditionPathExists= etc.)  without implementing too many 
special conditional tests in systemd itself. (e.g. check if the current 
hostname matches some pattern - which was my original issue i tried to 
solve) 8)


bye, marius..

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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

2011-08-24 Thread Lennart Poettering
On Wed, 24.08.11 21:12, Marius Tolzmann (tolzm...@molgen.mpg.de) wrote:

 
 On 24.08.2011 18:52, Lennart Poettering wrote:
 Hmm, yeah, if ExecStartPre= we put the unit in failure mode.
 
 So, let me see if I got this right: you are looking for something like
 ExecStartPre= but twhere the program when it returns non-zero should
 just cause the service to be skipped but not be put in failure state?
 
 Yes. that's my request.
 
 something like ConditionExec=/bin/true and ConditionExec=/bin/false
 so i can implement any thinkable logic outside of systemd and still
 maintain access to all features like Restart= etc.
 
 I thought this may be an easy way to expand the already existent
 conditions (ConditionPathExists= etc.)  without implementing too
 many special conditional tests in systemd itself. (e.g. check if the
 current hostname matches some pattern - which was my original issue
 i tried to solve) 8)

I have now added this to the TODO list. It won't be easy to add this
though, as execution extrernal processes synchronously is not an
option. More likely I'll add an additional prefix char to ExecStart=
(like -) which would indicate skip-on-fail or so.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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

2011-08-24 Thread Marius Tolzmann

On 24.08.2011 21:21, Lennart Poettering wrote:

On Wed, 24.08.11 21:12, Marius Tolzmann (tolzm...@molgen.mpg.de) wrote:



On 24.08.2011 18:52, Lennart Poettering wrote:

Hmm, yeah, if ExecStartPre= we put the unit in failure mode.

So, let me see if I got this right: you are looking for something like
ExecStartPre= but twhere the program when it returns non-zero should
just cause the service to be skipped but not be put in failure state?


Yes. that's my request.


I have now added this to the TODO list. It won't be easy to add this
though, as execution extrernal processes synchronously is not an
option. More likely I'll add an additional prefix char to ExecStart=
(like -) which would indicate skip-on-fail or so.


I think you mean ExecStartPre= here!?

And thanks for considering implementing this feature sometime.. 8)

regards, marius..
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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

2011-08-24 Thread Lennart Poettering
On Wed, 24.08.11 23:54, Marius Tolzmann (tolzm...@molgen.mpg.de) wrote:

 
 On 24.08.2011 21:21, Lennart Poettering wrote:
 On Wed, 24.08.11 21:12, Marius Tolzmann (tolzm...@molgen.mpg.de) wrote:
 
 
 On 24.08.2011 18:52, Lennart Poettering wrote:
 Hmm, yeah, if ExecStartPre= we put the unit in failure mode.
 
 So, let me see if I got this right: you are looking for something like
 ExecStartPre= but twhere the program when it returns non-zero should
 just cause the service to be skipped but not be put in failure state?
 
 Yes. that's my request.
 
 I have now added this to the TODO list. It won't be easy to add this
 though, as execution extrernal processes synchronously is not an
 option. More likely I'll add an additional prefix char to ExecStart=
 (like -) which would indicate skip-on-fail or so.
 
 I think you mean ExecStartPre= here!?

Indeed. Sorry for the confusion.

 And thanks for considering implementing this feature sometime.. 8)

Lennart

-- 
Lennart Poettering - Red Hat, Inc.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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

2011-08-02 Thread Marius Tolzmann


hi..

since conditions specifying wheter a service should start are somehow 
limited to the existence of some files/directories/etc. i was searching 
for something more complex to handle conditional service starts.


is there a way to execute a program and take its exit status to evaluate 
the condition? like ConditionExec or whatever.


currently we need a service that only starts if the current hostname 
matches some value, i.e. only start service on hostA.


or we need to start a service only if some special IP is configured on a 
network interface.


is this already possible without getting a failed service?

bye m.


--
Dipl.-Inf. Marius Tolzmann marius.tolzm...@molgen.mpg.de
--.--
MPI f. molekulare Genetik |
Ihnestrasse 63-73, D-14195 Berlin |   == MarIuX GNU/Linux ==
Phone: +49 (0)30 8413 1709|
--^--
God put me on earth to accomplish a certain number of things.
Right now I am so far behind..
   ..I will never die. by calvin from calvinhobbes ;)
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel