2004-09-09 09:10:41 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# ucd-snmp init file for snmpd
|
|
|
|
#
|
|
|
|
# chkconfig: - 50 50
|
|
|
|
# description: Simple Network Management Protocol (SNMP) Daemon
|
|
|
|
#
|
|
|
|
# processname: /usr/sbin/snmpd
|
|
|
|
# config: /etc/snmp/snmpd.conf
|
|
|
|
# config: /usr/share/snmp/snmpd.conf
|
2007-06-25 09:33:00 +00:00
|
|
|
# pidfile: /var/run/snmpd.pid
|
2004-09-09 09:10:41 +00:00
|
|
|
|
2008-01-28 12:49:25 +00:00
|
|
|
### BEGIN INIT INFO
|
|
|
|
# Provides: snmpd
|
|
|
|
# Required-Start: $local_fs $network
|
|
|
|
# Required-Stop: $local_fs $network
|
|
|
|
# Should-Start:
|
|
|
|
# Should-Stop:
|
|
|
|
# Default-Start:
|
|
|
|
# Default-Stop:
|
|
|
|
# Short-Description: start and stop Net-SNMP daemon
|
|
|
|
# Description: Simple Network Management Protocol (SNMP) Daemon
|
|
|
|
### END INIT INFO
|
|
|
|
|
2004-09-09 09:10:41 +00:00
|
|
|
# source function library
|
|
|
|
. /etc/init.d/functions
|
|
|
|
|
2008-02-12 15:28:05 +00:00
|
|
|
|
2009-07-09 12:19:27 +00:00
|
|
|
OPTIONS="-Lsd -Lf /dev/null -p /var/run/snmpd.pid"
|
2008-02-12 15:28:05 +00:00
|
|
|
if [ -e /etc/sysconfig/snmpd ]; then
|
|
|
|
. /etc/sysconfig/snmpd
|
2006-07-12 12:32:23 +00:00
|
|
|
fi
|
|
|
|
|
2004-09-09 09:10:41 +00:00
|
|
|
RETVAL=0
|
|
|
|
prog="snmpd"
|
2008-01-28 12:49:25 +00:00
|
|
|
binary=/usr/sbin/snmpd
|
|
|
|
pidfile=/var/run/snmpd.pid
|
2004-09-09 09:10:41 +00:00
|
|
|
|
|
|
|
start() {
|
2008-01-28 12:49:25 +00:00
|
|
|
[ -x $binary ] || exit 5
|
2004-09-09 09:10:41 +00:00
|
|
|
echo -n $"Starting $prog: "
|
|
|
|
if [ $UID -ne 0 ]; then
|
|
|
|
RETVAL=1
|
|
|
|
failure
|
|
|
|
else
|
2008-01-28 12:49:25 +00:00
|
|
|
daemon --pidfile=$pidfile $binary $OPTIONS
|
2004-09-09 09:10:41 +00:00
|
|
|
RETVAL=$?
|
|
|
|
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/snmpd
|
|
|
|
fi;
|
|
|
|
echo
|
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
|
|
|
echo -n $"Stopping $prog: "
|
|
|
|
if [ $UID -ne 0 ]; then
|
|
|
|
RETVAL=1
|
|
|
|
failure
|
|
|
|
else
|
2008-01-28 12:49:25 +00:00
|
|
|
killproc -p $pidfile $binary
|
2004-09-09 09:10:41 +00:00
|
|
|
RETVAL=$?
|
|
|
|
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/snmpd
|
|
|
|
fi;
|
|
|
|
echo
|
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
|
|
|
reload(){
|
|
|
|
echo -n $"Reloading $prog: "
|
2008-01-28 12:49:25 +00:00
|
|
|
killproc -p $pidfile $binary -HUP
|
2004-09-09 09:10:41 +00:00
|
|
|
RETVAL=$?
|
|
|
|
echo
|
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
|
|
|
restart(){
|
|
|
|
stop
|
|
|
|
start
|
|
|
|
}
|
|
|
|
|
|
|
|
condrestart(){
|
|
|
|
[ -e /var/lock/subsys/snmpd ] && restart
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
start
|
2008-01-28 12:49:25 +00:00
|
|
|
RETVAL=$?
|
2004-09-09 09:10:41 +00:00
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
stop
|
2008-01-28 12:49:25 +00:00
|
|
|
RETVAL=$?
|
2004-09-09 09:10:41 +00:00
|
|
|
;;
|
|
|
|
restart)
|
|
|
|
restart
|
2008-01-28 12:49:25 +00:00
|
|
|
RETVAL=$?
|
2004-09-09 09:10:41 +00:00
|
|
|
;;
|
2009-09-14 09:53:25 +00:00
|
|
|
reload|force-reload)
|
2004-09-09 09:10:41 +00:00
|
|
|
reload
|
2008-01-28 12:49:25 +00:00
|
|
|
RETVAL=$?
|
2004-09-09 09:10:41 +00:00
|
|
|
;;
|
2008-01-28 12:49:25 +00:00
|
|
|
condrestart|try-restart)
|
2004-09-09 09:10:41 +00:00
|
|
|
condrestart
|
2008-01-28 12:49:25 +00:00
|
|
|
RETVAL=$?
|
2004-09-09 09:10:41 +00:00
|
|
|
;;
|
|
|
|
status)
|
|
|
|
status snmpd
|
|
|
|
RETVAL=$?
|
|
|
|
;;
|
|
|
|
*)
|
2009-09-14 09:53:25 +00:00
|
|
|
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload|force-reload}"
|
2008-01-28 12:49:25 +00:00
|
|
|
RETVAL=2
|
2004-09-09 09:10:41 +00:00
|
|
|
esac
|
|
|
|
|
|
|
|
exit $RETVAL
|