-
Sven Mäder authoredSven Mäder authored
envrcd
An environment switcher for shared system accounts.
Motivation
An admin is probably more efficient and certainly much happier in his customized environment. That includes settings like aliases, colors, environment variables, program configurations etc. Of course this does not apply for real hacker gurus in front of a green shimmering CRT screen, they just need one color, that is green, and the defaults. But some noob admins, like me, don't even know how to move the cursor if vim is in compatibility mode. With only /root/.bashrc
all admins need to agree on a common environment. Nobody will be completely happy. This project tries to solve that problem.
envrcd.d
Reserved files in These files should only exist locally and are ignored by git
-
00-local
:ENVRCD_SET_*
(contains user settings, exists only in your private home) -
20-host
:ENVRCD_INVENTORY
(host specific environment vars) -
90-host-late
: host aliases (host specific alias overrides)
~/.envrcd/envrcd.d/00-local
00-local: Create this file to set local user settings. Only use this in your users home directory. Do not use this file for root.
export ENVRCD_SET_USER="<username>" # set envrcd user name
export ENVRCD_SET_PROFILE="<profile>" # set envrcd profile to use (leave empty for default)
export ENVRCD_SET_DEBUG="true" # enable debugging messages
export ENVRCD_NO_ENVRCD="true" # abort loading advance envrcd settings, can be used should something go wrong
~/.envrcd/envrcd.d/20-host
20-host: Create this file to set host specific settings.
export ENVRCD_INVENTORY="testing" # set inventory group
~/.envrcd/envrcd.d/90-host-late
90-host-late: Create this file to set host specific settings that should override possible user settings. Useful to define host specific aliases.
Basic operation
The script works by sending environment variables prefixed with ENVRCD_SET_*
via SSH to the remote host. The following variables are supported:
-
ENVRCD_SET_USER
: Set this to your name -
ENVRCD_SET_PROFILE
: Profile to load -
ENVRCD_SET_DEBUG
: Set to enable debugging mode -
ENVRCD_SET_NOENVRCD
: Set to disable advanced user envrcd and load system root defaults
Load order:
- The script first loads its configuration from
~/.envrcd/envrcd.d/
- Then if
ENVRCD_SET_PROFILE
is set, it will try to load the profile from~/.envrcd/profile/${ENVRCD_SET_PROFILE}
- If it is unset it will load the defaults from
~/.encrcd/profile/default