#!/bin/bash

# TrackStudio auto-start
#
# description: Auto-starts TrackStudio
# processname: jetty

#if [ -z "$JDK_HOME" ]; then
#   echo ERROR: cannot start TrackStudio.
#   echo No JDK found to run TrackStudio. Please validate either JDK_HOME points to valid JDK installation
#fi

if [ -e "jetty" ]; then
    TS_HOME=`pwd`
fi

if [ -z "$TS_HOME" ]; then
   echo ERROR: cannot start TrackStudio.
   echo No TS_HOME found to run TrackStudio. Please validate either TS_HOME points to valid TrackStudio installation
fi

opwd=`pwd`

cd $TS_HOME

case $1 in
   start)
     echo -n Starting TrackStudio:
     bash startJetty &>/dev/null &
     echo
     ;;

   stop)
     echo -n Stopping TrackStudio
     bash stopJetty &>/dev/null &
     echo
     ;;
     
   restart)
     echo -n Restarting TrackStudio
     bash stopJetty &>/dev/null &
     sleep 3
     bash startJetty &>/dev/null &
     echo
     ;;
     
   *)
     echo "usage: $0 {start|stop|restart}"
esac

cd $opwd
exit 0