#!/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
# pidfile: /var/run/snmpd

# source function library
#. /etc/init.d/functions

export LD_LIBRARY_PATH=/usr/local/lib

OPTIONS="-Lsd -Lf /dev/null -p /var/run/snmpd -a"
RETVAL=0
prog="snmpd"

start() {
        echo -n $"Starting $prog: "
        if [ $UID -ne 0 ]; then
                RETVAL=1
                failure
        else
                /usr/local/sbin/snmpd $OPTIONS
                RETVAL=$?
        fi;
        echo 
        return $RETVAL
}

stop() {
        echo -n $"Stopping $prog: "
        if [ $UID -ne 0 ]; then
                RETVAL=1
                failure
        else
                pkill snmpd
                RETVAL=$?
        fi;
        echo
        return $RETVAL
}

reload(){
        echo -n $"Reloading $prog: "
         /usr/bin/pkill -HUP snmpd
        RETVAL=$?
        echo
        return $RETVAL
}

restart(){
	stop
	start
}

case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart)
	restart
        ;;
  reload)
	reload
        ;;
  status)
        status snmpd
	RETVAL=$?
        ;;
  *)
	echo $"Usage: $0 {start|stop|status|restart|reload}"
	RETVAL=1
esac

exit $RETVAL
