#!/bin/sh
#
# $Id: soagent.redhat52.in,v 1.3 2002/03/01 13:45:41 ksm Exp $
#
# (C) 1999, 2000, 2001, 2002 - Evalesco ApS.
#     http://www.evalesco.com
#
# Agent init-script for SysOrb 2.6 (build-2556)
#
# For RedHat Linux 5.2
#
# chkconfig: 35 91 11
# description: Starts and stops the SysOrb network monitoring agent. \
#		(for more information see http://www.sysorb.com)
# processname: soagent
#

SOAGENT=/usr/sbin/soagent

#
# You can change this setting if you do now want the sysorb
# client to run as root.  This will cause various checks to
# not function (!)
#
ALLOW_ROOT=YES

#
# No user serviceable parts below
#
test -x "$SOAGENT" || exit 0

. /etc/rc.d/init.d/functions

case "$1" in
  start)
	echo -n "Starting SysOrb Agent: "

	if test "$ALLOW_ROOT" = YES; then
	    OUTPUT="`$SOAGENT 2>&1`"
	else
	    OUTPUT="`su -c \"$SOAGENT 2>&1\" -s /bin/sh sysorb`"
	fi
	if test -n "$OUTPUT"; then
		echo
		echo "Error starting SysOrb agent:"
		echo "$OUTPUT"
		exit 1
	fi
	echo soagent
	touch /var/lock/subsys/soagent
	;;
  stop)
        echo -n "Shutting down SysOrb Agent: "
	killproc soagent
	echo
        rm -f /var/lock/subsys/soagent
        ;;
  restart)
	$0 stop 
	$0 start
	;;
  status)
	echo -n "Shutting down SysOrb Agent: "
	if test -n "`ps aux | grep $SOAGENT | grep -v grep`";
	then
	    echo "running";
	else
	    echo "stopped";
	fi

	;;
  *)
        echo "Usage: soagent {start|stop|restart|status}"
        exit 1
esac

exit 0

