I may have a problem in the include chain for the profiles, or something may be awry in either my system, or my understanding of profile.d (RHEL7).
I added a
.sh script which is for a node installation, whilst trying to clean up the .bashrc. The problem is that it is not appending to the
$PATH like I had hoped.
Note, the issue is happening both via my main terminal (ssh via putty), but also directly from the console itself as well.
$ cat ~/.bash_profile # # .bash_profile # # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi
$ cat /etc/profile.d/nvm_path.sh # This adds node/nvm(node version manager) to path, and then initializes nvm, and its bash completion #Load NVM if [ -f ~/.nvm ]; then export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" if [ -f $NVM_DIR/bash_completion ]; then [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion fi fi # Force npm onto the path (only needed if its not available on your node installation) if [ -f ~/.npm/ ]; then PATH=$PATH:$HOME/.npm fi # Include node_mod bins in PATH, which are usually symlinked here (gulp, # cordova, etc..) if [ -f $HOME/.npm-packages/bin ]; then #note is a hyphen, not an underscore PATH=$PATH:$HOME/.npm-packages/bin fi export PATH
/etc/profile itself, its my understanding the perms are ok as read-only since they are sourced, as opposed to executed, so i think this isnt an issue.
-rw-r--r--. 1 root root 1795 May 4 2016 profile
What have i missed?
I'm thinking the problem is somewhere along the lines of since the scripts are initially loaded by root the paths are invalid. The problem: where I try to load the user paths. What can be done about this? Do I need to add in a $LOGGED_USER variable in place of
if [ -f ~/.nvm ] and maybe even
$HOME? What is that variable?
After further research, it appears the problem is that root is loading the script, so $HOME, even $USER, is never available, even if I set a condition in there to check if root is loading or not, since root is always sourcing the script.
e.g. if [[ $EUID -ne 0 ]]; then USERDIR=$HOME else USERDIR=/home/$USER fi if [ -f $USERDIR/.nvm ]; then #...
I would need to have the var check happen once the user logs in, not when root sources it.
It appears something like this is destined for /etc/skel/.bash_profile, unless someone comes up with a clever bash script idea. Any ideas on how to accomplish this here, so that I don't have to use /etc/skel?