using export in an EnvironmentFile

2

I'm converting an Upstart config file to a systemd unit file. We use lots of environment variables to store magic variables that are imported with the EnvironmentFile directive

export EC2_URL="https://ec2.us-west-1.amazonaws.com"

I've found empirically that systemd doesn't like this and that removing the export command makes it less unhappy. But I can't find where in the systemd documentation or elsewhere (the Web), where it says what kind of syntax is allowed in an environment variable file. Does systemd use export implicitly?

highpost

Posted 2015-09-16T17:20:32.787

Reputation: 123

Same problem here. Wanna use the EnvironmentFile in .bashrc as well. – Sven R. Kunze – 2018-01-24T19:45:45.367

Answers

4

Environment variable files are not shell scripts.

They are data files, readable by anything that understands a simple name=value with # for comments syntax.

Don't expect to write them in a shell language.

I can't find where in the systemd documentation or elsewhere (the Web), where it says what kind of syntax is allowed in an environment variable file.

It's in the systemd.exec manual page in the very first paragraph under the EnvironmentFile= subheading.

JdeBP

Posted 2015-09-16T17:20:32.787

Reputation: 23 855