Subject: Redhat Init revisited

From: Fire Eater <[email-masked]>
Date: Sat, 20 Nov 2004 01:39:52 -0700

In that ...  I, as well as other, run into the occasional problem of
having multiple instances of Argus getting started. I did a little
modification to my init file. Also added a stopall and a status section.

#!/bin/sh
#
# Argusd init script
#
# chkconfig: 2345 99 10
# description: starts and stops argusd
# probe: true
# Provides: $argusd
#
#
# source function library
#. /etc/rc.d/init.d/functions

cd /var/argus

PID=`ps awx -o pid,command | grep "Argus" | grep -v 'grep' | awk
' {print $1}'`

case "$1" in

start)
                if [ "${PID}" != "" ]; then
                        echo ""
                        echo "Argus Monitor Already Running !"
                        echo "          Aborting!"
                        echo ""
                else
                        /usr/local/sbin/argusd -a /var/argus -u apache -
g apache
                        echo "Argus Monitor Started !"

                fi
        exit 0;

        /usr/local/sbin/argusd -a /var/argus -u apache -g apache
        echo "Argus Monitor Started !"
        #/usr/local/sbin/argusd -u apache -g apache
        ;;

stop)
        /usr/local/sbin/argusctl shutdown reason="rc.argusd stop"
        echo "Argus Monitor Shutdown !"
        ;;

stopall)
		kill $PID
          echo "Killing all Argus PID's"
		;;

restart)
        /usr/local/sbin/argusctl shutdown reason="rc.argusd stop"
        /usr/local/sbin/argusd -a /var/argus
        echo "Argus Monitor Restarted !"
        ;;

reload)
        /usr/local/sbin/argusctl hup
        echo "Argus Monitor Reloaded !"
        ;;
status)
                if [ "${PID}" != "" ]; then
                        echo ""
                        echo "Argus Monitor is Running !"
                        echo "PID's Running are:"
                        echo""
                        echo $PID
                        echo ""
                else
                        echo ""
                        echo "Argus Monitor is NOT Running !"
                        echo ""

                fi
        exit 0;

        ;;

*)
        echo usage: $0 'start|stop|stopall|restart|reload|status'
        exit 1
        ;;

esac
exit 0

---

From: Fire Eater <[email-masked]>
Date: Sat, 20 Nov 2004 14:14:59 -0700

Sorry, I pasted the wrong file.... 
Here is the correct version.

#!/bin/sh
#
# Argusd init script
#
# chkconfig: 2345 99 10
# The user and group Argusd should run as
ARGUSUSER=apache
ARGUSGROUP=apache
ARGUSDIR=/var/argus
cd $ARGUSDIR
#

case "$1" in

start)
                if [ "${PID}" != "" ]; then
                        echo ""
                        echo "Argus Monitor Already Running !"
                        echo "          Aborting!"
                        echo ""
                else
                        /usr/local/sbin/argusd -a /var/argus -u
$ARGUSUSER -g $ARGUSGROUP
                        echo "Argus Monitor Started !"

                fi
        exit 0;
        ;;

stop)

stopall)
                kill $PID
          echo "Killing all Argus Monitor PID's"
                ;;

restart)

               if [ "${PID}" != "" ]; then
                        echo ""
                        echo "Stopping Argus Monitor"
                        echo ""
                        /usr/local/sbin/argusctl shutdown
reason="rc.argusd stop"
                        echo "Argus Monitor Stopped"
                        sleep 5
                        echo ""
                        /usr/local/sbin/argusd -a /var/argus -u
$ARGUSUSER -g $ARGUSGROUP
                        echo "Argus Monitor Restarted !"
                        else
                        echo "Argus Monitor Is Not Running"

                fi
        exit 0;
        ;;

reload)

status)

                fi
        exit 0;
        ;;

*)

esac
exit 0

### set file ownership, permissions and enable service at boot###
# /etc/rc.d/init.d/argusd
#chown root /etc/rc.d/init.d/argusd; chmod 744 /etc/rc.d/init.d/argusd;
chkconfig argusd on