#!/bin/ksh
#
#
# update ALL hosts or just one?
#
if [[ -z $1 ]] ; then
	PATTERN='*'
else
	PATTERN='*'$1'*'
fi
#
# which archive am I doing?
#
CLASS=python
# local
LARCHIVE="/home/sdo/class/${CLASS}/archive"
# remove
RARCHIVE="archives/${CLASS}.archive"
#
# which local ssh client to use
#
LOCAL_SSH="ssh -2"
#
# files to NOT send
#
EXCLUDES='--exclude=core --exclude CVS'
#
# where to find rdist on the other side
#
RPATH="--rsync-path=bin/arch/rsync"
#
# first, make sure all files are readable
#
echo "Fixing directory permissions"
chmod 755 `find ${LARCHIVE} -type d`
echo "Fixing file permissions"
chmod og+r,og-w `find ${LARCHIVE} -type f`
#
#
# do it
#
for HOST in \
	p1.cs.ohiou.edu \
	ace.cs.ohiou.edu \
	defiant.cs.ohiou.edu \
	
do
    if [[ ${HOST} = ${PATTERN} ]] ; then
	echo "============================================================"
	echo "===  $HOST -- ${LARCHIVE} ==> ${RARCHIVE}"
	echo "============================================================"
	rsync -av -e "${LOCAL_SSH}" ${EXCLUDES} ${RPATH}  ${LARCHIVE}/ ${HOST}:${RARCHIVE}
    fi
done
