#!/bin/bash # net-snmp init file for snmpd # # chkconfig: 345 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/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ ${NETWORKING} = "no" ] && exit 0 [ -x /usr/sbin/snmpd -a -f /etc/snmp/snmpd.conf ] || exit 0 OPTIONS="-s -l /dev/null -P /var/run/snmpd -a" RETVAL=0 prog="snmpd" start() { gprintf "Starting %s: " "$prog" daemon /usr/sbin/snmpd $OPTIONS RETVAL=$? echo touch /var/lock/subsys/snmpd return $RETVAL } stop() { gprintf "Stopping %s: " "$prog" killproc /usr/sbin/snmpd RETVAL=$? echo rm -f /var/lock/subsys/snmpd return $RETVAL } reload(){ gprintf "Reloading %s: " "$prog" killproc /usr/sbin/snmpd -HUP RETVAL=$? echo return $RETVAL } restart(){ stop start } condrestart(){ [ -e /var/lock/subsys/snmpd ] && restart return 0 } case "$1" in start) start ;; stop) stop ;; restart) restart ;; reload) reload ;; condrestart) condrestart ;; status) status snmpd RETVAL=$? ;; *) gprintf "Usage: %s {start|stop|status|restart|condrestart|reload}\n" "$0" RETVAL=1 esac exit $RETVAL