digital adj. Having digits.     peer n. A comrade; a companion; a fellow; an associate. inmotion    
   
Recent Articles
Securing your Wireless LAN
Wednesday, August 18, 2010
Some tips and things you might not know about your wireless network.
Using Different Subversion Client Versions
Wednesday, August 18, 2010
Handling a Subversion Repository URL Change
Sunday, May 3, 2009
If your repository URL changes, you can use the following command to fix existing snapshots.
vfat Mounts Default to Lowercase Shortnames
Tuesday, April 21, 2009
I want a "this is brain-damage" quote from Linus for this mess.
VirtualBox or VMWare Virtual Machine at Login
Sunday, April 12, 2009
How to start a virtual machine in X when a user logs in.
Dialog Progress Bar Through Pipe
Sunday, April 12, 2009
How to use dialog to display a script progress bar and communicate progress to it through a named pipe.
Mount JFFS2 Image
Saturday, October 25, 2008
Example of how to mount a JFFS2 image using mtdblock.
Ottawa Linux Symposium 2008
Sunday, July 27, 2008
Here are some pictures from the 2008 Linux Symposium.

Be nice to nerds. Chances are you'll end up working for one.
- Bill Gates

Sys Admin-Linux...-General Tips-File...

File Distribution Using rsnyc

Saturday, July 17, 2004 by digitalpeer

The following script is used to distribute account files to different computers using rsync over ssh. Of course, it is important to note that the computer that runs this script as a cron job is the only computer that account files should be edited on. This includes hiding or aliasing the "passwd" command from users on the other machines. Also, if you want the ssh login to work automagically, you'll have to setup ssh keys.

However, maybe somebody with a little more drive can write up a script to run on all machines and merge changed files.

#!/bin/bash
#
# Smart File Distribution Script
#
# Distribute list of files to via rsync to a list of hosts if they have been modified locally
#

# each file to distribute
D_FILES="/etc/passwd /etc/shadow /etc/group /etc/gshadow";

# each server to distribute to
D_HOSTS="dp1 dp2 dp8";

# loop through each file
for D_FILE in $D_FILES; do
	# if the file exists
	if [ -e $DFILE ]; then
		# if update file is older than real file
		if [ $D_FILE -nt $D_FILE.lastupdate ]
		then
			# update update file
			touch $D_FILE.lastupdate

			# distribute to each host
			for D_HOST in $D_HOSTS; do
				if [ $D_HOST != `hostname` ]
        			then
					#sync the file
					rsync -p -e ssh $D_FILE $D_HOST:$D_FILE
					echo "Distributing $D_FILE to $D_HOST"
			        fi
			done
		fi
	else
		echo "File $D_FILE doesn't even exist!"
	fi
done

External Links Summary
Debian Administration :: Password-less logins with OpenSSH [www.debian-administration.org]

Submit Comment to This Article - Be the first!
Please post a comment if you have something to add, find something wrong, or would like more information on the topic at hand. Do not use the comment form to contact the author about unrelated concerns!

Name: Email (optional):
Enter verification number here: