#!/bin/sh
#
# chkconfig: 2345 50 50
# description: RC(Remote Console) Agent

# source function library
. /etc/rc.d/init.d/functions

HOME=`pwd`
ROOT=/usr/local/share/asmagent/rca

case "$1" in
  start)
	if [ -f /var/lock/subsys/rca ]; then
		echo "rca is already started"
		exit 0
	fi
	echo -n "Starting rca:                                              "
	cd ${ROOT}
	./thk_load
	./kbd_load
	#./aux_load
	./rcmserver&
	cd ${HOME}
	echo_success
	echo
	touch /var/lock/subsys/rca
	;;
  stop)
	if [ ! -f /var/lock/subsys/rca ]; then
		echo "rca is already stopped"
		exit 0
	fi
	echo -n "Stopping rca:                                              "
	cd ${ROOT}
	killall -q rcmserver
	#./thk_unload
	./kbd_unload
	#./aux_unload
	cd ${HOME}
	echo_success
	echo
	rm -f /var/lock/subsys/rca
	;;
  restart)
	$0 stop
	$0 start
	;;
  status)
	status rcmserver
	;;
  *)
	echo "Usage: rca {start|stop|restart|status}"
	exit 1
esac

exit 0
