[systemd-devel] How to source a variable file using systemd

Soumya Koduri skoduri at redhat.com
Tue Oct 27 05:17:36 PDT 2015


Thanks Richard & Mantas. That did the trick.

-Soumya

On 10/27/2015 04:11 PM, Richard Maw wrote:
> On Tue, Oct 27, 2015 at 04:05:18PM +0530, Soumya Koduri wrote:
> <snip>
>> EnvironmentFile=/etc/myconfig
>> ....
>> ExecStart=/bin/bash -c 'source ${MY_ENV_FILE} && echo ${MY_ENV_VAR}'
>
> Systemd also does shell-like variable substitution, so potentially it's decided
> to interpolate in the value of $MY_ENV_VAR before `source $MY_ENV_FILE` found
> it.
>
> Both those variables should be set in the environment appropriately when
> ExecStart= is loaded, so I'd suggest escaping the $ as $$ so that bash gets to
> do the interpolation instead of systemd.
>


More information about the systemd-devel mailing list