#!/bin/bash

#Copyright (C) 2006, 2007 NTT DATA Corporation
#
#This program is free software; you can redistribute it and/or
#Modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation, version 2.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details

. /opt/hinemos/hinemos.cfg

if [ "$1" == "start" ] ; then
	if [ -f $HINEMOS_JBOSS_PID ] ; then
		read JBOSS_PID < $HINEMOS_JBOSS_PID
		ps -p $JBOSS_PID e | grep $JBOSS_HOME > /dev/null && TMP=1
		if [ "$TMP" ] ; then
		        echo "JBoss already started!"
			exit 1
		fi
	fi

	${JBOSS_HOME}/bin/run_hinemos.sh 2>&1 >/dev/null &
	
elif [ "$1" == "stop" ] ; then

	${JBOSS_HOME}/bin/shutdown_hinemos.sh -S

else
	echo $"Usage: hinemos_jboss {start|stop}"
	exit 1;
fi

exit 0;
