0

I have a bunch of services that have the same service file that changes based on the parameter. Something like this:

[Unit]
Description=device_bridge instance %i

# Rate limit for restarts applies to both 'voluntary' and 'involuntary' restarts:
# no more than 5 restarts per day.
StartLimitIntervalSec=1d
StartLimitBurst=5
[email protected]%i.service
[email protected]%i.service

[Service]
Type=simple
ExecCondition=/bin/config_query -a device_bridge -i %i
ExecStart=/bin/device_bridge -i %i
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

The application ran in

ExecCondition
checks the system configuration file to see if this service should be running. I also need it to be restarted (up to 5 times) if ti crashes. However, if
ExecCondition
returns 1 (no need to run) systemd still restarts it.

Is there any way not to restart if

ExecCondition
is set to 1?