#!/sbin/sh
#
# hinemos_agent This shell script takes care of starting and stopping
#               hinemos_agent.
#
# chkconfig: 2345 99 01
# description: Hinemos Agent

#Copyright (C) since 2006 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

# Source config
. /opt/hinemos_agent/bin/hinemos_agent.cfg

RETVAL=0
HINEMOS_AGENT_START=${HINEMOS_AGENT_HOME}/bin/agent_start.sh
HINEMOS_AGENT_STOP=${HINEMOS_AGENT_HOME}/bin/agent_stop.sh
HINEMOS_AGENT_LOCK_FILE=/var/run/hinemos_agent
prog="hinemos_agent"

case "$1" in
'start')
	echo "Starting $prog: \c"
	${HINEMOS_AGENT_START}
	RETVAL=$?
	[ $RETVAL -eq 0 ] && touch ${HINEMOS_AGENT_LOCK_FILE}
	;;

'stop')
	echo "Stopping $prog: \c"
	${HINEMOS_AGENT_STOP}
	RETVAL=$?
	[ $RETVAL -eq 0 ] && rm -f ${HINEMOS_AGENT_LOCK_FILE} ${HINEMOS_AGENT_PID}
       	;;

*)
        echo "Usage: $0 { start | stop }"
        exit 1
        ;;
esac
exit $RETVAL 
