#!/bin/sh

SERVER="yoursvnserver"

HOST=`hostname -s`
I=0
ABORT_ON_FAIL="true"
LOGDIR="/tmp/nfs/"
if [ ! -d $LOGDIR ] ; then
   mkdir -p $LOGDIR
fi   
while [ $I -lt 1000 ]; do
	I=$[ $I + 1 ]
        TMPDIR=`mktemp -d Kernel-$HOST-$I.XXXXXXXXXX`
        LOGFILE="${LOGDIR}/${TMPDIR}.log"
	if [ ! -d "$TMPDIR" ] ;  then  
	   echo "creating TMPDIR:$TMPDIR failed" >$LOGFILE
	   exit 1
	  else 
  	   echo "creating TMPDIR:$TMPDIR success" >$LOGFILE   	  
	fi
	echo "run $I svn co svn://${SERVER}/srv/media/tmp/svn_kernel/kernel "$TMPDIR" >> $LOGFILE 2>&1"
        echo "start runcounter: $I" >> $LOGFILE	
	svn co svn://${SERVER}/srv/tmp/svn_kernel/kernel "$TMPDIR" > $LOGFILE 2>&1
	RESULT=$?
	echo `date`,$RESULT	
	if [ $RESULT != 0 ] ; then
	   echo `date`,$RESULT >> $LOGFILE
	   echo "runcounter: $I" >> $LOGFILE
	   if [ "x${ABORT_ON_FAIL}" == "xtrue" ] ; then
	      # kill remaining test runs
	      echo "stop all processing with: killall"
	      echo "stop processing with: killall -9 svn_run.sh" >>$LOGFILE
	      logger "End of run. killing checkouts"
	      killall -9 svn_run.sh
	      exit 1
	   fi
	fi   
	echo "exit: $RESULT on run: $I" >> $LOGFILE
	rm -rf -- "$TMPDIR"
done
