#! /bin/ksh
#
# @(#)mcontrol 
# No jre version.

ARCH="$(uname -p)"
#echo "ARCH = $ARCH"

PROGNAME="$(whence $0)"
#echo "PROGNAME = $PROGNAME"

DEMO_HOME="$(dirname $PROGNAME)"
#echo "DEMO_HOME = $DEMO_HOME"

if (whence vic | wc -l) > /dev/null
then
   #print "OK: vic found in your path at" `whence vic`
   sleep 0
else
   print "WARNING: vic was not found in your path."
fi

if (whence vat | wc -l) > /dev/null
then
   #print "OK: vat found in your path at" `whence vat`
   sleep 0
else
   if (whence rat | wc -l) > /dev/null
   then
     #print "OK: rat found in your path at" `whence rat`
     sleep 0
   else
     print "WARNING: neither vat or rat was not found in your path."
  fi
fi

if (whence rtpplay | wc -l) > /dev/null
then
   #print "OK: rtpplay found in your path at" `whence rtpplay`
   sleep 0
else
   print "FATAL ERROR: rtpplay was not found in your path."
   exit
fi

if (whence rtpdump | wc -l) > /dev/null
then
   #print "OK: rtpdump found in your path at" `whence rtpdump`
   sleep 0
else
   print "FATAL ERROR: rtpdump was not found in your path."
   exit
fi

if (whence java | wc -l) > /dev/null
then
  unset JAVA_HOME
  export CLASSPATH=$DEMO_HOME
  echo "exec java mcontrol $* &"
  exec java mcontrol $* & 
else
  if (whence jre | wc -l) > /dev/null
  then
    # We explicitly do not want the environment's CLASSPATH and JAVA_HOME.
    unset JAVA_HOME
    unset CLASSPATH
    echo "exec jre -cp $DEMO_HOME mcontrol $* &"
    exec jre -cp $DEMO_HOME mcontrol $* &
  else
    echo "FATAL ERROR: Neither java or jre were in your path."
  fi
fi
