[systemd-devel] Shell expressions in EnvironmentFile
Lennart Poettering
lennart at poettering.net
Wed Oct 8 02:48:38 PDT 2014
On Tue, 07.10.14 19:18, Simon Peeters (peeters.simon at gmail.com) wrote:
> 2014-10-07 19:12 GMT+02:00 Jon Stanley <jonstanley at gmail.com>:
> > 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:
>
> Which is logical since no system exists to modify the environment of
> the parent proces.
>
> > [Service]
> > ExecStartPre=/something/that/sets/var
> > ExecStart=/some/file $var
>
> ExecStart=/bin/sh -c ". /something/that/sets/var; /some/file $var"
THis would certainly work, but I'd strongly advise to use "exec" for
executing /some/file at the end, so that the shell process is replaced
by the actual daemon process, instead of continuing running with the
demon process as child.
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list