Tell your users to override the service by creating a drop-in snippet through the use of the edit
option in systemctl.
Firstly, start with some sane defaults. Let's assume the ExecStart
part of your service declares the following:
[Service]
ExecStart=./program arg1
Now any user of this service can decide that they want to use a different set of arguments for running the program. They can do that by creating a drop-in snippet with:
systemctl edit myservice.service
In the new file, they simply write the following to override the ExecStart
:
[Service]
ExecStart=
ExecStart=./program arg1 arg2
The benefit of doing it this way is that the end result does not involve modifying the system-installed service which may conflict with some package managers.
And that's it!
Now just reload systemd (systemctl daemon-reload
) and restart the service (systemctl restart myservice.service
).
When the service restarts, it will always also load the user's modifications.
I hope that helps
Sources: