I am working on a configuration-as-code tool, and want to create systemd provider for it.
Now, suppose user describes in their configuration that they want
NetworkManager.service enabled, and they want
We can (un)link corresponding unit files using
systemctl enable NetworkManager.service and
systemctl disable cups.service respectively, but now we need to stop services that need to be stopped and start services, that need to be started.
I was hoping that there is a command, that would do exactly that for me - "Stop everything that runs, but need to be stopped, and start everything that is stopped, but needs to run".
systemctl daemon-reload is, unfortunately, not what I look for.
Is there such functionality built into
systemctl, or will I have to manipulate every service individually?
P.S. This should actually be a separate question, but I suppose that there will be usecases, where my users will run my program from chrooted/containerized environment, where PID 1 is not systemd. Trying to invoke any unit manipulation actions leads to
systemctl exiting with status 1 and message
System has not been booted with systemd as init system (PID 1). Can't operate.. Is there a way I could check for such circumstances beforehand, or the best I can do is just trying and catching error?