Is it possible in some way to have dynamic environment variables in Linux?
I have a webserver where sites follow this layout:
site/
qa/
production/
I would like to have an environment variable (e.g. APPLICATION_ENV) that is set to “qa” when I’m in the qa directory, and to “production” when I’m in the production directory. The reason for this is that various sites can use many different processes that all need to know if it’s the QA or production environment. Some sites use PHP under Apache, some use Node.js, some sites come with commandline tools, cron jobs, etcetera. I would like to have one authorative source on whether it’s a QA or a production environment.
Based on
rvm‘s override:Just put this function in
.bashrcor some other sourced environment file, and try tocdintoqa,production, or one of their subdirectories.