Blame SOURCES/net-snmpd.init

8a419f
#!/bin/bash
8a419f
# ucd-snmp init file for snmpd
8a419f
#
8a419f
# chkconfig: - 50 50
8a419f
# description: Simple Network Management Protocol (SNMP) Daemon
8a419f
#
8a419f
# processname: /usr/sbin/snmpd
8a419f
# config: /etc/snmp/snmpd.conf
8a419f
# config: /usr/share/snmp/snmpd.conf
8a419f
# pidfile: /var/run/snmpd.pid
8a419f
8a419f
### BEGIN INIT INFO
8a419f
# Provides: snmpd
8a419f
# Required-Start: $local_fs $network
8a419f
# Required-Stop: $local_fs $network
8a419f
# Should-Start: 
8a419f
# Should-Stop: 
8a419f
# Default-Start: 
8a419f
# Default-Stop: 
8a419f
# Short-Description: start and stop Net-SNMP daemon
8a419f
# Description: Simple Network Management Protocol (SNMP) Daemon
8a419f
### END INIT INFO
8a419f
8a419f
# source function library
8a419f
. /etc/init.d/functions
8a419f
8a419f
8a419f
OPTIONS="-LS0-6d -Lf /dev/null -p /var/run/snmpd.pid"
8a419f
if [ -e /etc/sysconfig/snmpd ]; then
8a419f
  . /etc/sysconfig/snmpd
8a419f
fi
8a419f
8a419f
RETVAL=0
8a419f
prog="snmpd"
8a419f
binary=/usr/sbin/snmpd
8a419f
pidfile=/var/run/snmpd.pid
8a419f
8a419f
start() {
8a419f
        [ -x $binary ] || exit 5
8a419f
        echo -n $"Starting $prog: "
8a419f
        if [ $UID -ne 0 ]; then
8a419f
                RETVAL=1
8a419f
                failure
8a419f
        else
8a419f
                daemon --pidfile=$pidfile $binary $OPTIONS
8a419f
                RETVAL=$?
8a419f
                [ $RETVAL -eq 0 ] && touch /var/lock/subsys/snmpd
8a419f
        fi;
8a419f
        echo 
8a419f
        return $RETVAL
8a419f
}
8a419f
8a419f
stop() {
8a419f
        echo -n $"Stopping $prog: "
8a419f
        if [ $UID -ne 0 ]; then
8a419f
                RETVAL=1
8a419f
                failure
8a419f
        else
8a419f
                killproc -p $pidfile $binary
8a419f
                RETVAL=$?
8a419f
                [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/snmpd
8a419f
        fi;
8a419f
        echo
8a419f
        return $RETVAL
8a419f
}
8a419f
8a419f
reload(){
8a419f
        echo -n $"Reloading $prog: "
8a419f
        killproc -p $pidfile $binary -HUP
8a419f
        RETVAL=$?
8a419f
        echo
8a419f
        return $RETVAL
8a419f
}
8a419f
8a419f
restart(){
8a419f
	stop
8a419f
	start
8a419f
}
8a419f
8a419f
condrestart(){
8a419f
    [ -e /var/lock/subsys/snmpd ] && restart
8a419f
    return 0
8a419f
}
8a419f
8a419f
case "$1" in
8a419f
  start)
8a419f
	start
8a419f
	RETVAL=$?
8a419f
	;;
8a419f
  stop)
8a419f
	stop
8a419f
	RETVAL=$?
8a419f
	;;
8a419f
  restart)
8a419f
	restart
8a419f
	RETVAL=$?
8a419f
        ;;
8a419f
  reload|force-reload)
8a419f
	reload
8a419f
	RETVAL=$?
8a419f
        ;;
8a419f
  condrestart|try-restart)
8a419f
	condrestart
8a419f
	RETVAL=$?
8a419f
	;;
8a419f
  status)
8a419f
        status snmpd
8a419f
	RETVAL=$?
8a419f
        ;;
8a419f
  *)
8a419f
	echo $"Usage: $0 {start|stop|status|restart|condrestart|reload|force-reload}"
8a419f
	RETVAL=2
8a419f
esac
8a419f
8a419f
exit $RETVAL