#!/bin/bash
export PATH=$PATH:/opt/java/bin
export CLASSPATH=/opt/emsweb/emonster/bin:/opt/resin/lib/jsdk22.jar:/opt/resin/lib/xalan_1_2_D02.jar:/opt/resin/lib/xerces_1_2.jar:/opt/resin/lib/
cd /opt/emsweb/emonster/bin
case "$1" in
start)
	if [[ -f emonster.pid ]]
	then 
		echo "Already running"
		exit 1;
	else
		echo "Starting emonster"
		nohup java emonster &
		echo $! > emonster.pid
		exit 0
	fi
	;;
stop)
	echo "Stopping emonster"
	kill `cat emonster.pid`
	rm -f emonster.pid
	exit 0
	;;
*)
	echo "Usage: (stop|start)"
	exit 1
	;;
esac

