[systemd-devel] EnvironmentFile generated during ExecStartPre phase

Honza Horak hhorak at redhat.com
Wed Oct 31 07:56:20 PDT 2012


On 10/31/2012 03:46 PM, Mantas Mikulėnas wrote:
> 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.

Thanks for that idea, I was thinking about that too, but didn't like 
adding a new executable only for that purpose... However, thinking a bit 
more about it again, I like it more, since it is cleaner. So I'll 
probably choose this way.

Honza


More information about the systemd-devel mailing list