[systemd-devel] Conditional dependency
Lennart Poettering
lennart at poettering.net
Tue Jan 28 17:25:27 UTC 2020
On Mo, 27.01.20 12:33, prashantkumar dhotre (prashantkumardhotre at gmail.com) wrote:
> Hi,
> Is there a way to specify conditional dependency in service files ?
> My use case is : I have a include file my.include that contains
> 'After=core.service' among other things.
Note that we explicitly do not support ".include" expressions
anymore, and have not supported them in a long time. Yes, the code
still parses them, but don't use that. Use drop-ins for unit files
instead.
> I have services A,B,C and X. As of now , all include my.include.
> Now my requirement is - I want services A,B and C to be dependent on
> core.service but X service should not depend on core.service.one solution
> i thought is -
> Instead of include my.include in all 4 services, I can create 2
> separate include files and include appropriate files in those services.
> Is there any other better way ?
First: Do not use include files. Use drop-ins, i.e. foor X.service add
an extension drop-in X.service.d/foobar.conf or so.
If you want to extend your units with different contents depending on
the unit then you probably should use different drop-ins for them.
Lennart
--
Lennart Poettering, Berlin
More information about the systemd-devel
mailing list