2

Do systemd unit files support preserving existing environment variables?

(Something similar to sudo -E?)

Not referring to Environment= or EnvironmentFile= here.

It would be be useful if systemd could for example leave the DPKG_MAINTSCRIPT_PACKAGE environment variable intact. Then the service had a chance to determine wheter it was restarted as part of a an upgrade (apt-get / dpkg set the DPKG_MAINTSCRIPT_PACKAGEenvironment variable.) vs manually/at boot.

1 Answer 1

6

That would not make sense because the started service is not a child of the process which caused the start. systemctl connects to the running systemd and makes it start the processes. So even if the environment was preserved (maybe it even is...) then it would be systemd's environment that gets inherited. And that does not contain the entries you want.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .