#! /bin/sh
#
# Usage: push [file]
#
# Push a file from MASTER to all other machines
#
# ATTENTION specify full pathname, e.g. /etc/passwd
#
# Author: rdm
#
USAGE='Usage: push file'
MACHINES=/usr/local/root/proof/etc/cluster.conf

MASTER=pcna49a
DOMAIN=cern.ch

case $# in
    0|2|3|4|5|6)  echo $USAGE >&2; exit 1
esac

if [ `hostname` != $MASTER.$DOMAIN ]
then
   echo "Must run on $MASTER" >&2; exit 1
fi

file=$1

if [ -f $MACHINES ]
then
   machines=`cat $MACHINES`
   echo -n "File $file pushed to"
   for i in $machines
   do
      if [ $i != $MASTER ]
      then
         echo -n " $i"
         rcp $file $i:$file
      fi
   done
   echo
fi
