#!/bin/sh

#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_agent/bin/hinemos_agent.cfg

if [ -f $HINEMOS_LOG_AGENT_PID ] ; then
	read AGENT_PID < $HINEMOS_LOG_AGENT_PID
	ps -p $AGENT_PID e | grep $HINEMOS_LOG_AGENT_HOME > /dev/null && TMP=1
	if [ "$TMP" ] ; then
	        echo "Log Agent already started!"
        	exit 1
	fi
fi

nohup $JAVA_PROC -cp $HINEMOS_LOG_AGENT_HOME/lib/log_agent:$HINEMOS_LOG_AGENT_HOME/lib/log_agent/logagent.jar:$HINEMOS_LOG_AGENT_HOME/lib/commons-logging.jar:$HINEMOS_LOG_AGENT_HOME/lib/jbossall-client.jar:$HINEMOS_LOG_AGENT_HOME/lib/log4j.jar:$HINEMOS_LOG_AGENT_HOME/lib/LogTransferEJB.jar:$HINEMOS_LOG_AGENT_HOME/lib/RepositoryEJB.jar:$HINEMOS_LOG_AGENT_HOME/lib/MonitorEJB.jar:$HINEMOS_LOG_AGENT_HOME/lib/clustercontrol.jar:$HINEMOS_AGENT_HOME/lib/hinemos-commons.jar com.clustercontrol.logagent.Agent $HINEMOS_LOG_AGENT_HOME/lib/log_agent/Agent.properties 2>> ${HINEMOS_LOG_AGENT_HOME}/bin/log_nohup.out &
echo $! > $HINEMOS_LOG_AGENT_PID  
echo "Log Agent started"
