File: //etc/lsi_mrdsnmp/lsi_mrdsnmpd.suse
#! /bin/sh
#chkconfig 2345 55 80
#LSI SNMP Agent startup/shutdown script
### BEGIN INIT INFO
# Provides: lsi_mrdsnmpd
# Required-Start: $syslog
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 6
# Description: lsi_mrdsnmpd Daemon
### END INIT INFO
#Source Function library
. /etc/rc.status
#. /etc/rc.config
#snmpagtdir="/etc/1030snmp"
megadevice="megasnmp"
agent="/usr/sbin/lsi_mrdsnmpagent"
agent_name="lsi_mrdsnmpagent"
vendor="LSI SNMP"
# SNMPDCONF=/etc/snmpd.conf
if [ -f /etc/SuSE-release ]; then
suse_ver=`cat /etc/SuSE-release | grep 'VERSION = 9'| wc -l` # Check for SUSE 9 Operating System
if [ "$suse_ver" == "1" ]; then
SNMPDCONF=/etc/snmpd.conf
else
SNMPDCONF=/etc/snmp/snmpd.conf
fi
fi
# Determine the base and follow a runlevel link name.
base=${0##*/}
link=${base#*[SK][0-9][0-9]}
# Shell functions sourced from /etc/rc.status:
# rc_check check and set local and overall rc status
# rc_status check and set local and overall rc status
# rc_status -v ditto but be verbose in local rc status
# rc_status -v -r ditto and clear the local rc status
# rc_failed set local and overall rc status to failed
# rc_reset clear local rc status (overall remains)
# rc_exit exit appropriate to overall rc status
# First reset status of this service
statuscheck() {
local base=${1##*/}
local pid
# Test syntax.
if [ "$#" = 0 ] ; then
echo $"Usage: status {program}"
return 1
fi
# First try "pidof"
pid=`pidof -o $$ -o $PPID -o %PPID -x $1 || \
pidof -o $$ -o $PPID -o %PPID -x ${base}`
if [ -n "$pid" ]; then
echo $"${base} (pid $pid) is running..."
return 0
fi
# Next try "/var/run/*.pid" files
if [ -f /var/run/${base}.pid ] ; then
read pid < /var/run/${base}.pid
if [ -n "$pid" ]; then
echo $"${base} dead but pid file exists"
return 1
fi
fi
# See if /var/lock/subsys/${base} exists
if [ -f /var/lock/subsys/${base} ]; then
echo $"${base} dead but subsys locked"
return 2
fi
echo $"${base} is stopped"
return 3
}
rc_reset
case "$1" in
start)
echo -n "Starting $vendor Agent"
## Start daemon with startproc(8). If this fails
## the echo return value is set appropriate.
#[ -r ${snmpagtdir}/$megadevice ] && rm ${snmpagtdir}/$megadevice
#megamajor=`cat /proc/devices|awk '/megaraid_sas_ioctl/{print$1}' `
#Check for error
#if [ "$megamajor" = "" ]
#then
# echo MegaRAID driver not loaded.
# echo $vendor Agent will not be loaded.
# exit 1
#fi
#mknod ${snmpagtdir}/$megadevice c $megamajor 0 2>/dev/null
spid=`pidof snmpd`
agentpid=`pidof $agent`
if [ "$agentpid" != "" ] ; then
echo " is Already Running";
return 0
fi
if [ "$spid" = "" ] ; then
if [ -x /etc/init.d/snmpd ] ; then
/etc/init.d/snmpd start
elif [ -x /usr/local/sbin/snmpd ] ; then
/usr/local/sbin/snmpd
else
echo SNMP Daemon not started
fi
fi
startproc $agent -c ${SNMPDCONF}
# Remember status and be verbose
rc_status -v
;;
restart)
$0 stop
sleep 20
$0 start
;;
stop)
echo -n "Shutting down $vendor Agent"
## Stop daemon with killproc(8) and if this fails
## set echo the echo return value.
#rm -f ${snmpagtdir}/$megadevice 2>/dev/null
killproc $agent
# Remember status and be verbose
rc_status -v
;;
status)
statuscheck ${agent_name}
RETVAL=$?
;;
*)
echo "Usage: $0 {start|stop|status}"
exit 1
;;
esac
rc_exit