96ebc7d181
Use net-snmp-config package to package script and service file for net-snmp package. Removed servcie/config/script related patches and let net-snmp-config package be responsible for it. Keep another meta patch for build configuration related changes. Deployment test and ping test between VMs pass Config,serivce and script files check pass. Story: 2003768 Task: 27586 Depends-on: https://review.openstack.org/#/c/616097 Change-Id: Ic64543447d04543fdf9eafdc3d9ae4e2521c10df Signed-off-by: zhipengl <zhipengs.liu@intel.com>
96 lines
2.0 KiB
Bash
96 lines
2.0 KiB
Bash
#! /bin/sh
|
|
# /etc/init.d/snmpd: start snmp daemon.
|
|
. /etc/init.d/functions
|
|
|
|
# Linux Standard Base (LSB) Error Codes
|
|
RETVAL=0
|
|
GENERIC_ERROR=1
|
|
INVALID_ARGS=2
|
|
NOT_RUNNING=3
|
|
NOT_INSTALLED=5
|
|
|
|
#set environment variables
|
|
export SNMPCONFPATH=/etc/snmp
|
|
export MIBDIRS=/usr/share/snmp/mibs
|
|
|
|
SNMPDOPTS='oamcontroller -u snmpd -LS6d -Lf /dev/null -p /var/run/snmpd.pid'
|
|
PIDFILE=/var/run/snmpd.pid
|
|
SNMPTRAPDCONFIG=${SNMPCONFPATH}/snmpdtrapd.conf
|
|
SNMPDCONFIG=${SNMPCONFPATH}/snmpd.conf
|
|
SNMPDNAME=snmpd
|
|
SNMPD="/usr/sbin/${SNMPDNAME}"
|
|
|
|
test -x ${SNMPD} || exit ${NOT_INSTALLED}
|
|
|
|
# Reads config file (will override defaults above)
|
|
[ -r /etc/default/snmpd ] && . /etc/default/snmpd
|
|
|
|
case "$1" in
|
|
start)
|
|
echo -n "Starting network management services: "
|
|
status ${SNMPD} >/dev/null
|
|
if [ $? -eq 0 ]; then
|
|
echo -n "is already running "
|
|
RETVAL=0
|
|
elif [ -f ${SNMPDCONFIG} ]; then
|
|
start-stop-daemon -o --start --quiet --name ${SNMPDNAME} --pidfile "$PIDFILE" \
|
|
--exec ${SNMPD} -- ${SNMPDOPTS}
|
|
RETVAL=$?
|
|
else
|
|
logger "${SNMPDCONFIG} is missing"
|
|
RETVAL=${GENERIC_ERROR}
|
|
fi
|
|
if [ ${RETVAL} -eq 0 ] ; then
|
|
pid=`pidof ${SNMPDNAME}`
|
|
echo "OK"
|
|
logger "${SNMPDNAME} (${pid})"
|
|
else
|
|
echo "FAIL"
|
|
RETVAL=${GENERIC_ERROR}
|
|
fi
|
|
|
|
;;
|
|
stop)
|
|
status ${SNMPD} >/dev/null
|
|
if [ $? -ne 0 ]; then
|
|
echo "$SNMPDNAME is not running"
|
|
RETVAL=0
|
|
else
|
|
echo -n "Stopping network management services "
|
|
killproc ${SNMPDNAME}
|
|
if [ -n "`pidof ${SNMPDNAME}`" ] ; then
|
|
logger "Going to SIGKILL ${SNMPDNAME}"
|
|
killproc -KILL ${SNMPDNAME}
|
|
fi
|
|
/bin/rm -rf $PIDFILE
|
|
status ${SNMPD} >/dev/null
|
|
if [ $? -ne 0 ]; then
|
|
echo "Stopped"
|
|
RETVAL=0
|
|
else
|
|
echo "Failed"
|
|
RETVAL=${GENERIC_ERROR}
|
|
fi
|
|
fi
|
|
;;
|
|
status)
|
|
status ${SNMPD} >/dev/null
|
|
RETVAL=$?
|
|
if [ ! ${RETVAL} -eq 0 ] ; then
|
|
RETVAL=${NOT_RUNNING}
|
|
fi
|
|
|
|
;;
|
|
restart|reload|force-reload)
|
|
$0 stop
|
|
sleep 1
|
|
$0 start
|
|
|
|
;;
|
|
*)
|
|
echo "Usage: /etc/init.d/snmpd {start|stop|status|restart|reload|force-reload}"
|
|
exit ${GENERIC_ERROR}
|
|
esac
|
|
|
|
exit $RETVAL
|