I'm trying to set up a systemd
service that takes a parameter, and uses it in a couple places. I think I'm very close: with my config file name myservice@.service
, I can run systemctl start myservice@foo myservice@bar
, and use %i
in the config to get foo
and bar
in the service instances.
The trick is that I need the parameter to be upper case in one section, but lowercase in another.
# foo instance
User=myuser-%i # myuser-foo
ExecStart=my_command /data/%i # needs to be /data/FOO
# bar instance
User=myuser-%i # myuser-bar
ExecStart=my_command /data/%i # needs to be /data/BAR
So far the only way I can think to do this is write a wrapper script, and change to ExecStart=my_wrapper.sh %i
to let the wrapper do the necessary string formatting. That seems clunky though, is this possible directly in the service config?