#!/bin/csh
#
# Run the demo.  We assume that the database is created, but not running.
# On entry, this script respects certain environment variables listed below:
#
# Variable:		Default Value if Unset in Environment:
# ---------		--------------------------------------
# ORACLE_PSRV		TPCB
# ORACLE_HOSTHOME	/usr/local/orahost
# ORACLE_HOME		$ORACLE_HOSTHOME/orahome
# TPCB_HOME		$ORACLE_HOSTHOME/demo
# NROOTLOCAL		/usr/ncube/current/local
#
# Also, the scripts expects the file $TPCB_HOME/config/$ORACLE_PSRV.params
# to exist and contain your configuration information.  If you have no such
# file, then copy TPCB.params from the same directory and modify it accordingly.

# Set up our environment
if ($?ORACLE_PSRV == 0)     setenv ORACLE_PSRV 	   TPCB
if ($?ORACLE_HOSTHOME == 0) setenv ORACLE_HOSTHOME /usr/local/orahost
if ($?ORACLE_HOME == 0)     setenv ORACLE_HOME     $ORACLE_HOSTHOME/orahome
if ($?TPCB_HOME == 0) 	    setenv TPCB_HOME       $ORACLE_HOSTHOME/demo
if ($?NROOTLOCAL == 0) 	    setenv NROOTLOCAL      /usr/ncube/current/local

# Grab data from the configuration files.
set config_file = $TPCB_HOME/config/$ORACLE_PSRV.params
echo $config_file
if ( ! -r $config_file ) then
  echo "Before running this script, you need to create "
  echo "a personalized $config_file"
  exit
endif
source $config_file
source $TPCB_HOME/config/general.params

# Make sure DISPLAY environment variable is set
echo $DISPLAY >& /dev/null
if ( $status != 0 ) \
   exit 1

# Start up the database.
$ORACLE_HOSTHOME/bin/pstart $VERBOSE -c $TPCB_HOME/config/${ORACLE_PSRV}tpcb.conf -n $NUM_INST

# Bring up the meters.
$TPCB_HOME/bin/meters.sh

# Run the demo.
set sharepid = "`xnc $NROOTLOCAL/bin/ncube/nspcmd lookup ${ORACLE_PSRV}nhold`"
$TPCB_HOME/bin/xtp1 -sp $sharepid -prog $TPCB_HOME/bin/tpcb -inst $NUM_INST

# Shut down the database when the demo is done.
$ORACLE_HOSTHOME/bin/pstop -c $TPCB_HOME/config/${ORACLE_PSRV}tpcb.conf 
