#!/bin/sh
#
# $Id: soagent.mdk90.in,v 1.1 2002/09/08 01:06:32 jakob Exp $
#
# (C) 1999, 2000, 2001, 2002 - Evalesco ApS.
#     http://www.evalesco.com
#
# Agent init-script for SysOrb 2.6 (build-2556)
#
# For Mandrake Linux 9.0
#
# chkconfig: 35 91 11
# description: Starts and stops the SysOrb network monitoring agent. \
#		(for more information see http://www.sysorb.com)
# processname: soagent
#

SOAGENT=/opt/sysorb-agent/bin/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)
	gprintf "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
		failure "soagent startup"
		echo
		gprintf "Error starting SysOrb agent:\n"
		gprintf "%s\n" "$OUTPUT"
		exit 1
	fi
	success "soagent startup"
	echo
	touch /var/lock/subsys/sysorb-agent
	;;
  stop)
        gprintf "Shutting down SysOrb Agent: "
	killproc soagent
	echo
        rm -f /var/lock/subsys/sysorb-agent
        ;;
  restart)
	$0 stop 
	$0 start
	;;
  reload)
	$0 restart
	;;
  status)
	status soagent
	;;
  *)
        gprintf "Usage: soagent {start|stop|restart|reload|status}\n"
        exit 1
esac

exit 0

