#!/bin/bash

# Script name: TrcRunTrp test_request revision
# 
# Purpose: Allow TRC to invoke TRP when necessary
#
# Arguments:
#    test_request - A valid submitted test request name
#    revision - A test requestion revision number in the format x.y for
#       example 2.3
#
# Notes: There's no reason this can't be run standalone but its typical
#    usage is to be invoked by TRC
#
# History:
#    11/06/13 - Rob Janes - Initial release

. find_database.sh
. /cyflex/cmds/trs/jars.sh

ARGS=-DPropertiesFile=/cell/cui_properties.txt
TRS=/cell/trs_properties.txt
TRS_ARGS=-Dtrs_properties=$TRS

BASE=`grep cyflex.trs.cvsci_base $TRS | grep -v '^#' | cut -f2 -d\ `
BASE_DIR=-DbaseDirectory=$BASE

export JAVA_HOME=/cyflex/java_jdk
PATH=$JAVA_HOME/bin:$PATH
java $ARGS $TRS_ARGS $BASE_DIR $DB \
   com.cybermetrix.trs.trp.TRP $1 $2 >/tmp/trp.log 2>&1
result=$?
# Remove the log file if the status is zero.
if (( $result == 0)) ; then
   rm -f /tmp/trp.log
   rm -f velocity.log
fi
# Terminate with the status TRP returned.
exit $result
