#!/bin/bash
#
#
# 26-May-04 amo Continuously test the connection thruput
#
#
#
# After Aborting ( ^C ) this script: ( killing the test )
# ---------------------------------
#	kill -9 "pid-of-wl.scp.sh"
#	kill -9 "pid-of-scp"
#	fuser -muv /mnt/test
#	kill -9 "pid-of-bash"
#	umount /mnt/test
#
#
CNT=0
#
# Number of Passes
NUM=10
#
# Test File to Copy
SRC="linux-2.4.23-ow1.bin.tgz"
#
# Check the copied SRC against original
ORG="linux-2.4.23-ow1.bin.orig.tgz"
#
#
# Umount it first
# ---------------
#
mnt=`df | grep /mnt/test `
#
# echo "mnt=$mnt.."
#
if [ ! -z "$mnt" ];
then
  cmd="umount /mnt/test"
  echo ""
  echo "$cmd"
  $cmd
  #
fi
#
#
# Mount the test files we are gonna copy over
# -------------------------------------------
cmd="mount 192.168.1.11:/tmp /mnt/test"
echo "#"
echo "# $cmd"
echo "#"
$cmd
#
if [ $? != 0 ];
then
  echo ""
  echo "ERROR: $cmd : failed"
  echo ""
  #
  exit 1
fi
#
# ---------------------------------------------------------
# Loop forever
# ------------
#
while [ $CNT -lt $NUM ];
do
  DATE=`date `
  #
  echo "$DATE Cnt=$CNT.. "
  #
  rm -f $SRC
  # ls -la $SRC
  #
  #
  # mount 192.168.1.11:/tmp /mnt/test
  #
  cmd="scp -pv /mnt/test/$SRC ."
  # echo "$cmd"
  $cmd
  #
  sync
  #
  cmd="diff $SRC $ORG"
  $cmd
  #
  if [ $? != 0 ];
  then
    echo "#"
    echo "# ERROR: New File Didn't Compare: $cmd "
    echo "#"
    #
    # be nice and cleanup first
    umount /mnt/test
    exit 1
  fi
  #
  # umount /mnt/test
  #
  let CNT=CNT+1
  #
  #
done
#
date
#
umount /mnt/test
#
#
# End of file

