#! /usr/bin/sh
#
#ident	"@(#)rcptree.sh	1.6	04/12/08 SMI"
#
# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
# by Mark F. Logan

if [ $# -ne 1 ]
then
	echo usage: $0 remote-machine
	exit 1
fi

echo You must set up .rhosts on $1 to allow rcp

echo Runtime: $RUNTIME seconds
sleep $RUNTIME &
sleepid=$!

echo Changing local directory to /tmp
cd /tmp

local=`hostname`
iter=1

while [ -d /proc/$sleepid ]
do
	date
	rcp -rp /kernel $1:/export/home/tmp/kernel.$local.$$
	rcp -rp $1:/export/home/tmp/kernel.$local.$$ kernel.$$
	if diff -r kernel.$$ /kernel
	then
		rm -rf kernel.$$ &
		rsh $1 rm -rf /export/home/tmp/kernel.$local.$$ < /dev/null
		wait
	else
		echo "!ERROR: diff failed on iteration $iter"
		exit $?
	fi
	iter=`expr $iter + 1`
	sleep 1
done

echo "!PASS: Completed $iter copies successfully"
