Sharing .bashrc/.bash_profile/.bash_logout and bin dirs with slave users -- DreamHost best practices

As previously mentioned I have a custom .bashrc/.bash_profile setup for my DreamHost accounts.  Also, because of my '_user / _web user strategy', I have multiple users that all need to have the same bash environment. 

Rather than having duplicating my .bashrc file among all these users, I want to have just one copy in my main user account's space and share them among all the (slave) users.  This is easy enough -- I just replace the .bashrc, .bash_login, and .bash_logout files from the slave user's directory with links to the master user's version.

In a similar vein, I want to make avaiable the contents of the master user's ~/bin directory to the slave users.  Because my .bashrc file recursively adds subdirectories of ~/bin to the PATH (see previous link, line 38), all I have to do is create a symlink from ~master/bin to ~slave/bin/master.  This new directory will then be automatically added to the PATH.

I have packaged this all up in a script 'fixSlave.sh':

#!/bin/bash

# Replaces a slave user's .bashrc, .bash_profile, & .bash_logout files
# with a link to the master user's corresponding files and creates a link from
# the master user's ~/bin directory to slave's ~/bin/master

if [ $# -ne 1 ]; then
        echo "Usage $0 <master user>"
        return
fi

/bin/rm -f ~/.bashrc ~/.bash_profile ~/.bash_logout
ln -s /home/${1}/.bashrc .
ln -s /home/${1}/.bash_profile .
ln -s /home/${1}/.bash_logout .
cd ~/bin
/bin/rm -f ./master
ln -s /home/${1}/bin ./master

 Running this script as a slave user ($ fixSlave.sh <master user>) will set up all these links...

Free Tag:

Comments

Note, this script and the rest of my DreamHost scripts are now available as part of my DreamHost Script Library