I created init scripts for SysVinit and systemd to distribute with one of our software packages (it should run a non-interactive, background daemon for a network service). The installer asks the user if he wants to install the service; if so, the daemons' user plus home dir are created and the right script (depending on image name of process 1) is copied to the right location.
Since some details depend on the user's specific configuration or company policy (Where to install our tool? What should the daemons user be called? Where should his home directory be?), I used placeholders such as
%%TOOL_USER%%, and my setup script replaces those via sed. The automatic stuff works well for CentOS and Debian, so I am already quite happy.
But of course every system is a bit different, so the customer might choose to manually install the service (e.g. if he doesn't use syslog, or just generally has a high level of security, which is the case some of our customers). In that case he needs to adapt the init script.
In the case of sysv init this is easy, since that one is basically a shell script and I just put three variables
user=%%TOOL_USER%% executable=%%TOOL_EXEC%% working_dir=%%TOOL_HOME%%
on the top, together with some configuration hints.
For systemd on the other hand, I didn't find a possibility to set and reference custom variables, so all I can do is instruct the user to replace all occurrences of
%%TOOL_*%% with the appropriate value.
While I generally like the way the new systemd scripts work, I would prefer a more failsafe approach like with my init script; now the user might miss an occurrence. Anything I might have missed?
As reference I looked at the freedesktop.org systemd.service docs.