Jeremy Davis's picture

But re SystemD, it sounds like you will want to use the ExecPreStart= directive in your service file. I would assume that would do what you are hoping for?!

The Systemd service doc page is pretty handy IMO.

Assuming that there is an existing service file you wish to update, the correct way to do that is either copy the file (from /lib/systemd/system/...) to /etc/systemd/system/ and edit the copy in /etc (the file in /etc will be used instead of the one in /lib). Or create a file with a path like /etc/systemd/system/MY_SERVICE.service.d/override.conf and include overrides/additions there. IMO the easiest way to do the latter is use the "systemctl edit MY_SERVICE" command.

Alternatively, it's also an option to call an init.d script from a Systemd service file. E.g. stuff like this:

ExecStart=/etc/init.d/MY_SERVICE start
ExecStop=/etc/init.d/MY_SERVICE stop