On Sun, 2019-12-08 at 11:15:57 -0800, Russ Allbery wrote: > > Sure, help fir that would be nice. Thanks for the offer. (Probably > > should have an own bug for that.) Nethertheless, this is the line that > > causes my problems and needs to be transferred: > > https://salsa.debian.org/debian/gmrender-resurrect/blob/master/debian/gmediarender.default#L8 > > Ah, I see, the problem is the $(hostname) part, which isn't supported by > EnvironmentFile in systemd (which is the normal way to solve this > problem). > > After looking at this for a bit, my inclination if I were you would be to > write a tiny shell script that loads /etc/default/gmediarender, constructs > the command line, and then execs the daemon; install that script as > /usr/share/gmediarender/start; and then invoke that script via > start-stop-daemon in the init script and via ExecStart in the systemd unit > file. It's a little bit overkill because most of what the /etc/default > file is doing is simple, but it looks like the easiest way to handle > $(hostname).
I'd avoid using the wrapper for the init script TBH, because even though that will make this a bit WET, it would otherwise make it more complex there (having to use --startas and --exec to cope with the intermediate interpreter usage). I think shared wrappers make more sense when used to offload some kind of pre/post "hook" work, which gets called from Exec{Start,Stop}{Pre,Post} systemd service file directives (and init scripts). But here you do have another option, but I'm not sure it might be described as nicer TBH, :) something like this, or variations on this theme: [Service] Type=simple EnvironmentFile=/etc/default/service-static-vars EnvironmentFile=-/run/service-dynamic-vars ExecStartPre=-/bin/sh -c 'echo NAME=$(hostname) >/run/service-dynamic-vars' ExecStart=/usr/bin/daemon --option ${NAME} Thanks, Guillem