Forum: [software]
Vote for this forum
May 18, 2008
PC Update
by mike (Mike Macgirvin)
Here's a little shell script I cooked up to aid in managing large groups of Windows/Linux dual boot client workstations. It essentially makes the Linux systems 'call home' whenever they boot up so that we can have a series of scripts on the server which will bring them up to date. The alternative is to walk around to each workstation and type some commands. This gets old after you've done several hundred. It was also necessary to do this from a client side process, as there exist tools to push down changes from the server already, but we never know when Linux will be running. The PC might be running Windows for weeks. We just want everything to sync up the next time somebody boots Linux.
Anyway, here it is - I call it 'pcu':
#!/bin/sh -f##
##
## Update client workstations from a
## sequentially ordered set of update scripts
## located on a network drive.
##
## Scripts may be named numerically to be processed
## in order. Only scripts with ctime newer than the
## time of last invocation will be processed.
##
##
##
## Configuration:
##
## For synchronizing clock
NTP_BINARY='/usr/sbin/ntpdate'
TIMESERVER='ntp.example.com'
##
## Server/path containing scripts. This dir is NFS mounted locally.
PCUSERVER='pcu.example.com'
BASEPATH='/home/pcu'
##
## Where to find the files locally
## Default is $LOCALPATH/$FAMILY/$HOSTNAME
## or $LOCALPATH/$FAMILY/default if no $HOSTNAME dir exists.
##
## $FAMILY is used to group scripts of similar
## machines/architectures/lab configurations
LOCALPATH='/etc/pcu'
FTIMESTAMP='/etc/pcu.time'
FAMILYCONF='/etc/pcu.family'
INSTALLOC='/etc/init.d/pcu'
DEFAULTFAMILY='general'
########################################################
##
## Install
##
if [[ ! -x $INSTALLOC ]] ; then
echo "PCU installation commences. $0 "
cp $0 $INSTALLOC
chmod 755 $INSTALLOC
update-rc.d pcu start 99 2 3 4 5 .
mkdir $LOCALPATH
touch $FTIMESTAMP
echo "PCU installed."
fi
##
########################################################
if [[ -x $NTP_BINARY ]] ; then
$NTP_BINARY -su $TIMESERVER
fi
mount -t nfs $PCUSERVER:$BASEPATH $LOCALPATH
if [[ ! -x $LOCALPATH ]] ; then
exit
fi
if [[ ! -e $FTIMESTAMP ]] ; then
exit
fi
if [[ -e $FAMILYCONF ]] ; then
FAMILY=`cat $FAMILYCONF`
else
FAMILY=$DEFAULTFAMILY
fi
echo "Processing Updates for $FAMILY"
if [[ ! -x $LOCALPATH/$FAMILY ]] ; then
echo "$0: Warning: $LOCALPATH/$FAMILY ($PCUSERVER:$BASEPATH/$FAMILY) is not ac
cessible."
umount $LOCALPATH
exit 0
fi
if [[ -x $LOCALPATH/$FAMILY/`hostname` ]] ; then
UPDATEPATH=$LOCALPATH/$FAMILY/`hostname`
else
UPDATEPATH=$LOCALPATH/$FAMILY/default
fi
if [[ ! -x $UPDATEPATH ]] ; then
echo "$0: Warning: $UPDATEPATH ($PCUSERVER:$BASEPATH/$FAMILY/default) is not a
ccessible."
umount $LOCALPATH
exit 0
fi
for a in `find $UPDATEPATH -type f -newer $FTIMESTAMP | sort -n` ; do
echo -e "\t" `basename $a`
sh $a
done
umount $LOCALPATH
date > $FTIMESTAMP
No votes
Birds are entangled by their feet and men by their tongues.
pcu.dist
Digg
Delicious
Netscape
Technorati