#!/bin/sh export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/mod/sbin:/mod/bin:/mod/usr/sbin:/mod/usr/bin export LD_LIBRARY_PATH=/mod/lib:/mod/usr/lib DAEMON=snmpd SNMPDOPTS='-Lf /dev/null -p /var/run/snmpd.pid' case "$1" in ""|load|start|restart) if [ ! -r "/mod/etc/conf/netsnmp.cfg" ]; then echo "Error[netsnmp]: not configured" 1>&2 exit 1 fi . /mod/etc/conf/netsnmp.cfg; ;; esac start() { echo -n 'Starting snmpd...' $DAEMON $SNMPDOPTS exitval=$? if [ "$exitval" -eq 0 ]; then echo 'done.' else echo 'failed.' exit $exitval fi } stop() { echo -n 'Stopping snmpd...' killall $DAEMON > /dev/null 2>&1 exitval=$? if [ "$exitval" -eq 0 ]; then echo 'done.' else echo 'failed.' exit $exitval fi } case "$1" in ""|load) modreg cgi 'netsnmp' 'Net-SNMP' if [ "$NETSNMP_ENABLED" != "yes" ]; then echo "$DAEMON is disabled" 1>&2 exit 1 fi start ;; unload) stop ;; start) start ;; stop) stop ;; restart) stop sleep 1 start ;; status) if [ -z "$(pidof "$DAEMON")" ]; then echo 'stopped' else echo 'running' fi ;; *) echo "Usage: $0 [load|unload|start|stop|restart|status]" 1>&2 exit 1 ;; esac exit 0