[systemd-devel] Shell expressions in EnvironmentFile

Mantas Mikulėnas grawity at gmail.com
Tue Oct 7 10:19:39 PDT 2014


On Tue, Oct 7, 2014 at 8:12 PM, Jon Stanley <jonstanley at gmail.com> wrote:
> Since EnvironmentFile in a service isn't sourced by any shell, shell
> expressions in it will obviously not work the way that they did in a
> SysV style script.
>
> Nor does it seems that the environment gets preserved between
> ExecStartPre (where one could run a script that sets environment
> variables to be later used in the starting of the service) and
> ExecStart, so something like the following won't work:
>
> [Service]
> ExecStartPre=/something/that/sets/var
> ExecStart=/some/file $var
>
> Is there some way to get dynamically determined data into the
> environment such that it can be passed to the daemon at start?

Dynamic arguments sound like a bad idea in general. But the easiest
way to do this is by pointing ExecStart at a wrapper script which
first generates & exports variables, then just `exec`'s the actual
daemon.

-- 
Mantas Mikulėnas <grawity at gmail.com>


More information about the systemd-devel mailing list