Listing 2: mfp

#!/bin/sh  
# The next line contains the SCCS keywords.
# @(#)mfp.sh	1.2 1/5/93
#
# mfp - Machine file push - Push a file to a specified group of machines 
#       creating a backup of that file in the same dir as the original.
#       Brett Wynkoop 91/07/23
#
#  It is suggested that this script be run as root to operate properly.
#
#

PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/local/etc
ME=`whoami`
MYNAME=`basename $0`

#  TESTECHO should be blank, except when testing
#TESTECHO=echo

LISTGROUP=/usr/local/etc/listgroup 
HOSTNAME=`hostname`


if [ x${ME} != xroot ]
then
     echo 
     echo " You are not root.  You will only be able to push where you have"
     echo " write permission. Control-C now if you want to abort...."
     echo
     sleep 5
fi
echo 
echo "This program will push a new file to many machines."
echo -n "Are you sure you want to do this? (y or n)"
read RESP
if [ x${RESP} != xy ]
then
    exit 0
fi

echo -n "Filename to push out: "
read SOURCE
SOURCEFILE=`basename $SOURCE`

echo
echo -n "Machine group to push file to: "
read GROUP
export GROUP
echo
echo -n "Destination directory: "
read DEST
set -x
for MACHINE in `$LISTGROUP ${GROUP} `
do
if [ $MACHINE = $HOSTNAME ]
	then
	echo "\
$0: not pushing the file to host $HOSTNAME,"
	echo "\
    which is where the source file resides."
	continue
fi

$TESTECHO rsh $MACHINE "(cd $DEST; cp -p $SOURCEFILE $SOURCEFILE.bak )"
$TESTECHO rdist -c $SOURCE $MACHINE:$DEST/$SOURCEFILE
done


