[systemd-devel] EnvironmentFile generated during ExecStartPre phase

Mantas Mikulėnas grawity at gmail.com
Wed Oct 31 07:46:55 PDT 2012


On Wed, Oct 31, 2012 at 3:28 PM, Honza Horak <hhorak at redhat.com> wrote:
> My use case is the following: the service should be started with some
> environment variables defined, but the variable values are not static, but
> rather dynamically generated using some script. This could be solved by
> using EnvironmentFile=-/var/run/myservice, while this file would be
> generated in ExecStartPre=/usr/libexec/myservice-gen-env.

This could also be solved by using the script directly as ExecStart,
and having it `exec` the real service (possibly `exec "$@"`) as its
last step. That way, you wouldn't need to actually generate a file
(just `export` the variables before exec'ing) or rely on specific
execution order.

-- 
Mantas Mikulėnas


More information about the systemd-devel mailing list