'Referencing Other Environment Variables in Systemd
Is is possible to reference other environment variables when setting new ones in systemd?
[Service]
EnvironmentFile=/etc/environment
Environment=HOSTNAME=$COREOS_PRIVATE_IPV4
Environment=IP=$COREOS_PRIVATE_IPV4
Environment=FELIX_FELIXHOSTNAME=$COREOS_PRIVATE_IPV4
The above code does not seem to be working.
Solution 1:[1]
In my case, the only way that worked to load the system environment variables into systemd script was to load them inside the script itself, like described here:
# Import our environment variables from systemd
for e in $(tr "\000" "\n" < /proc/1/environ); do
eval "export $e"
done
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Lucas |
