Set System-wide Environment Variables in Ubuntu-20
OS environment variables used for consistency between updates through vcs and security.
Do not edit `/etc/environment` or `/etc/profile` or `/etc/bash.bashrc` as some may say so. Why? Check the doc page linked bellow
Create a file named freightapp.sh
in /etc/profile.d
.
Put appropriate values in repo/freightapp-envvars.sh
and copy it to /etc/profile.d
.
# assuming you are in the repo root directory
sudo cp freightapp-envvars.sh /etc/profile.d/freightapp.sh
There put the values as:
# inside /etc/profile.d/freightapp.sh
export ENVVARS=value
There is already a file with the required env-vars, check repo_root/freightapp-envvars.sh
. Set your values there and move it to /etc/profile.d
# assuming you are in project root and set your values in the file
sudo mv freightapp-envvars.sh /etc/profile.d/freightapp.sh
Modify a System-wide environment variable already set
Sometimes you may need to update one or more values in /etc/profile.d/freightapp.sh
, e.g., database change. Simply edit the file with updated values. Then do logout-login.
Beware of sudo caveat.
Server needs logout-login to take in effect for all processes. No shortcut for that!
Read More: