Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

share .bashrc over a network

Status
Not open for further replies.

keak

Programmer
Sep 12, 2005
247
CA
Hi there,
I have 3 machines that are very similar in terms of installed software, commands, etc.

I was wondering if there was anyways I can share configuration files (.bashrc, .emacs, .login, etc) between these 3 machines, meaning that when I edit a .bashrc in one machine, the function/alias is updated in the other 2.
 
You could reference an NFS share containing the network-wide bashrc. I'd recommend you keep the local ones anyway, and add code like:

Code:
if [[ -x /nfs/share/globalbashrc ]]
then
    . /nfs/share/globalbashrc
else
    echo NFS share unavailable, unable to load global bashrc.
fi

That way they will fail gracefull if the share is unavailable.

Otherwise you could decide which server has the 'master' copy and use rsync or similar to keep the other ones up to date.

Annihilannic.
 
I assume this code segment will go into the individual .bashrc files ?

I am not sure what
. /nfs/share/globalbashrc
is doing.

We first test to see if /nfs/share/globalbashrc exists, and if it does, we tell our system that /nfs/share/globalbashrc is the bash file that we're suppose to read?

Is that what this . /nfs/share/globalbashrc is doing?
 
In the bash man page have a look at the . (dot) aka source shell builtin.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks for the replys all.

If I use rsync, it is very likely that I'll have to execute a shell script after making changes to a bashrc file. (unless there is a way to automatically execute a script after a .bashrc is edited with emacs, but I think this will be kind of a hack, dont know if its done before).


The nfs approach sounds like a better approach in terms of seeing the changes immediately when a bashrc file is edited at one system, but then has the possibility of becoming inaccesible.
 
With rsync you would typically schedule it to run regularly in cron, so the result would not be available immediately, but quite soon, depending on the frequency of the job.

Annihilannic.
 
The nfs approach will use much more system & network resource. Like Annihilannic states create a crontab entry to run say every 20 to 30 minutes that starts the rsync.

Mike

"A foolproof method for sculpting an elephant: first, get a huge block of marble, then you chip away everything that doesn't look like an elephant."

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top