Guillem Jover <guil...@debian.org> writes:

> 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}

This is a nice approach, but I don't think it quite preserves the original
behavior.  As you wrote it above, if someone changed the setting in the
/etc/default file, that would have no effect and the default would still
be used.  If you reverse the order of EnvironmentFile, it avoids that
problem, but now the legacy setting with $(hostname) will be used if it
hasn't been changed, and that will result in a literal $(hostname) in the
value.

-- 
Russ Allbery (r...@debian.org)              <https://www.eyrie.org/~eagle/>

Reply via email to