[systemd-devel] Systemd -- Using Environment variable in a Unit file from Environment File

Lennart Poettering lennart at poettering.net
Mon May 29 09:12:24 UTC 2017


On Fri, 26.05.17 15:06, Raghavendra. H. R (raghuhr84 at gmail.com) wrote:

> Hi All,
> 
> I'm in the situation where path of my server changes due to version change.
> I don't want to modify my systemd unit file everytime, instead I want to go
> ahead with my environement file for modification.

Please do not use environment files for that. Simply add or remove
unit drop-in files. i.e. if you want to make minor changes to a unit
file foobar.service then add
/etc/systemd/system/foobar.service.d/50-quux.conf or so, and add the
necessary settings there. "systemctl edit" helps you in doing so, and
make this easy.

> EnvironmentFile=/home/raghu/system.env
> *WorkingDirectory=${SERVER_PATH}*

Please read the documentation about EnvironmentFile=, its environment
variables configured what is passed to the executed processes, and may
be referenced in the ExecXYZ= line, but not in any other configuration
lines. THis is because the precise environment is determined at the
moment of activation, and settings generally have a broader definition
than that.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list