#! /bin/sh

. /etc/rc.status
. /etc/rc.config

rc_reset
case "$1" in
    start)
        echo -n "Starting hp ProLiant Remote Insight Board Driver"
	sh /opt/compaq/cpqrid/cpcpqrid start
	rc_status
	rc_status -v
	;;
    stop)
        MYPID=`ps -x | grep cmanic | awk '{ print $5 }'`
        for i in $MYPID
        do
                if [ "$i" != "grep" ]
                then
                        echo "WARNING: cmanic agent running!"
                        echo "         You must stop this process first."
			echo "         usage:  /etc/rc.d/cmanic stop"
                        exit 1
                fi
        done
        MYPID=`ps -x | grep cmastor | awk '{ print $5 }'`
        for i in $MYPID
        do
                if [ "$i" != "grep" ]
                then
                        echo "WARNING: cmastor agent running!"
                        echo "         You must stop this process first."
			echo "         usage:  /etc/rc.d/cmastor stop"
                        exit 1
                fi
        done
        MYPID=`ps -x | grep cmasvr | awk '{ print $5 }'`
        for i in $MYPID
        do
                if [ "$i" != "grep" ]
                then
                        echo "WARNING: cmasvr agent running!"
                        echo "         You must stop this process first."
			echo "         usage:  /etc/rc.d/cmasvr stop"
                        exit 1
                fi
        done
        MYPID=`ps -x | grep cmafdtn | awk '{ print $5 }'`
        for i in $MYPID
        do
                if [ "$i" != "grep" ]
                then
                        echo "WARNING: cmafdtn agent running!"
                        echo "         You must stop this process first."
			echo "         usage:  /etc/rc.d/cmafdtn stop"
                        exit 1
                fi
        done
        echo -n "Stopping hp ProLiant Remote Insight Board Driver"
	sh /opt/compaq/cpqrid/cpcpqrid stop
	rc_status
	rc_status -v
	;;
    status)
	echo "Here is the module executing:"
	lsmod |grep Module
	lsmod |grep cpqrid
	rc_status
	rc_status -v
	;;
    *)
	echo "Usage: $0 {start|stop}"
	exit 1
esac
rc_exit
