[systemd-devel] conditional start with external condition
lennart at poettering.net
Mon Aug 11 06:11:13 PDT 2014
On Mon, 11.08.14 13:41, Markus Weißmann (markus.weissmann at in.tum.de) wrote:
> I've got an embedded system which can run in two configurations;
> configuration 1 will run daemon A, B and C
> configuration 2 will run daemon A and D
> The configuration is chosen at boot-time with a hardware switch. The
> position of this switch is accessible with a userland tool (via
> serial interface).
My recommendation would be to define two distinct target units for your
two modes, and then write a small "generator" tool that checks the
switch, and then creates a symlink /etc/systemd/system/default.target
that points to the appropriate target for the mode.
Note that this will only work if the serial port is on-board (and not
usb or so) and hence available without restrictions already at the time
the generators run.
> Bonus question: Will the ConditionPathExists be checked only once
> and if so when exactly? And does this interfere with setting
> Restart=always? (will it be re-evaluated if the daemon needs to be
> restarted, only once, ..?)
conditions are checked immediately before we'd normally start the first
service process for each service.
Lennart Poettering, Red Hat
More information about the systemd-devel