#!/bin/bash

#-------------------------------------------------------------------------------
#
# Removes the scratch directories on the $FILE_SYSTEM_NUMBER on each
# of the $TEST_HOSTS:
#
#    /bin/rm -rf /export/<test_host><file_system_number>/users/$USER/scratch
#
#-------------------------------------------------------------------------------

trap 'exit 1' 2 #traps Ctrl-C (signal 2)

if [ -z "$TEST_HOSTS" ]
then
  echo "Environment variable TEST_HOSTS is not set."
  exit 0
fi

if [ -z "$FILE_SYSTEM_NUMBER" ]
then
  echo "Environment variable FILE_SYSTEM_NUMBER is not set."
  exit 0
fi

j=$FILE_SYSTEM_NUMBER
for i in $TEST_HOSTS
do
  echo removing directory /export/$i$j/users/$USER/scratch
  /bin/rm -rf /export/$i$j/users/$USER/scratch
  echo removing directory /export/$i$j/users/$USER/scratchdisk
  /bin/rm -rf /export/$i$j/users/$USER/scratchdisk
done
