#! /bin/sh
. /fnal/ups/etc/setups.sh
ulimit -d unlimited -s unlimited -c 0
umask 002
echo __________________________________________________________________
date
echo Begin setup of products needed
setup dp v13_37  
echo Done setup of products needed
echo __________________________________________________________________
date
echo PATH = $PATH
echo __________________________________________________________________
date
printenv | grep _DIR | sort
echo __________________________________________________________________
date
if [ -f /opdb/d1/data/tileChunk/chunk42/stuffCompleteTile.log ]
then
  if [ -f /opdb/d1/data/tileChunk/chunk42/stuffCompleteTile.log.OLD ]
  then
    cat /opdb/d1/data/tileChunk/chunk42/stuffCompleteTile.log >> /opdb/d1/data/tileChunk/chunk42/stuffCompleteTile.log.OLD
    rm /opdb/d1/data/tileChunk/chunk42/stuffCompleteTile.log
  else
    mv /opdb/d1/data/tileChunk/chunk42/stuffCompleteTile.log /opdb/d1/data/tileChunk/chunk42/stuffCompleteTile.log.OLD
  fi
fi
if [ -f /opdb/d1/data/tileChunk/chunk42/stuffCompleteTile.err ]
then
  if [ -f /opdb/d1/data/tileChunk/chunk42/stuffCompleteTile.err.OLD ]
  then
    cat /opdb/d1/data/tileChunk/chunk42/stuffCompleteTile.err >> /opdb/d1/data/tileChunk/chunk42/stuffCompleteTile.err.OLD
    rm /opdb/d1/data/tileChunk/chunk42/stuffCompleteTile.err
  else
    mv /opdb/d1/data/tileChunk/chunk42/stuffCompleteTile.err /opdb/d1/data/tileChunk/chunk42/stuffCompleteTile.err.OLD
  fi
fi
date
setup ts
echo __________________________________________________________________
date
echo Begin stuffing completeTile
ts -noTk -command "stuff_completeTile chunk42 hlin" 
if [ $? -ne 0 ]
then
  echo Error: Stuffing of completeTile for chunk chunk42 failed.
  exit 1
fi
echo Done stuffing completeTile
echo __________________________________________________________________
date
echo ALL DONE
exit

