I'm actually working on a modular system with multiple services. In this system, I already have a configuration file and I would like to use this configuration file to enable or disable some services running with systemd. The configuration file could contain something like that:


At first I just thought of another service parsing my configuration file and creating little files depending of the configuration so my services could use the ConditionPathExists parameter but I don't find this solution elegant.

Is there other way to dynamically enable or disable some services with the help of my configuration files?


Having your own configuration file with service state duplicates the service manager (systemd). Don't, that would add an unfamiliar layer of indirection.

Rather, write and release service manager configuration, in this case as systemd units. Many of them is fine, nothing wrong with dozens of units.

Set the desired behavior using features like dependencies, restart settings, and maybe socket activation. Document how to start and stop the primary unit, plus which optional units make sense to disable.

Unit generators are a thing, but they are not necessary unless you have variable number of units and an algorithm to create them.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.