#!/usr/local/bin/bash
#
#    ========== licence begin  GPL
#    Copyright (C) 2001 SAP AG
#
#    This program is free software; you can redistribute it and/or
#    modify it under the terms of the GNU General Public License
#    as published by the Free Software Foundation; either version 2
#    of the License, or (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#    ========== licence end
#
# nachtRelease.bash
#
# complete night run test script to run a single release
#

Usage()
{
  echo "Syntax:$0 release nacht|weekend [32BitOnly|64BitOnly|32__64Bit]"
  echo "Start compilation and tests normal or at weekend (clears worktree)"
  exit 0
}

if [ $# -lt 2 ]
then
 Usage
fi

User=cron
Release=$1
shift
Mode=$1
shift
Schedule=$1
shift

. /rel/TOOL/tool/bin/SetupMachineEnv.bash ${Release}

giveup()
{
	echo "$0 terminated by signal....";
	exit 0;
}

trap "giveup" HUP INT QUIT TERM PIPE

echo =====================================================================
echo "Complete night run mode Release $Release $Mode $Schedule"

if [ "x$Mode" = "xweekend" ]; then

   echo =====================================================================
   echo "Clearing working directories"
   echo =====================================================================
   if [ "$BIT32Supported" = "NO" -o "$BIT64Supported" = "NO" ]
   then
       echo rm -rf xxx /rel/$Release/sys/wrk
       echo rm -rf xxx /rel/$Release/sys/wrk32
       echo rm -rf xxx /rel/$Release/tmp/*
   else
       echo rm -rf xxx /rel/${Release}_*/sys/wrk
       echo rm -rf xxx /rel/${Release}_*/sys/wrk32
       echo rm -rf xxx /rel/${Release}_*/tmp/*
   fi
   echo $Release clearing complete

fi
