michael@325: #!@l_prefix@/bin/openpkg rc michael@325: ## michael@325: ## rc.snmp -- Run-Commands michael@325: ## michael@325: michael@325: %config michael@325: snmp_enable="$openpkg_rc_def" michael@325: snmp_daemons="snmpd snmptrapd" michael@325: snmp_listen="127.0.0.1" michael@325: snmp_listentrap="127.0.0.1" michael@325: snmp_log_prolog="true" michael@325: snmp_log_epilog="true" michael@325: snmp_log_numfiles="10" michael@325: snmp_log_minsize="1M" michael@325: snmp_log_complevel="9" michael@325: michael@325: %common michael@325: snmp_pidfile_snmptrapd="@l_prefix@/var/snmp/snmptrapd.pid" michael@325: snmp_pidfile_snmpd="@l_prefix@/var/snmp/snmpd.pid" michael@325: snmp_signal () { michael@325: [ -f $snmp_pidfile_snmptrapd ] \ michael@325: && kill -$1 `cat $snmp_pidfile_snmptrapd` michael@325: local rc_snmptrapd=$? michael@325: [ -f $snmp_pidfile_snmpd ] \ michael@325: && kill -$1 `cat $snmp_pidfile_snmpd` michael@325: local rc_snmpd=$? michael@325: [ $rc_snmptrapd -eq 0 -o $rc_snmpd -eq 0 ] michael@325: } michael@325: michael@325: %status -u @l_susr@ -o michael@325: snmp_usable="no" michael@325: snmp_active="no" michael@325: rcService snmp enable yes && \ michael@325: snmp_usable="yes" michael@325: rcService snmp enable yes && \ michael@325: snmp_signal 0 && snmp_active="yes" michael@325: echo "snmp_enable=\"$snmp_enable\"" michael@325: echo "snmp_usable=\"$snmp_usable\"" michael@325: echo "snmp_active=\"$snmp_active\"" michael@325: michael@325: %start -u @l_susr@ michael@325: rcService snmp enable yes || exit 0 michael@325: rcService snmp active yes && exit 0 michael@325: for daemon in $snmp_daemons; do michael@325: case "$daemon" in michael@588: snmpd ) @l_prefix@/sbin/snmpd -p $snmp_pidfile_snmpd -Lsd $snmp_listen ;; michael@588: snmptrapd ) @l_prefix@/sbin/snmptrapd -p $snmp_pidfile_snmptrapd -Lsd $snmp_listentrap ;; michael@325: esac michael@325: done michael@325: michael@325: %stop -u @l_susr@ michael@325: rcService snmp enable yes || exit 0 michael@325: rcService snmp active no && exit 0 michael@325: snmp_signal TERM michael@325: michael@325: %restart -u @l_susr@ michael@325: rcService snmp enable yes || exit 0 michael@325: rcService snmp active no && exit 0 michael@325: rc snmp stop michael@325: sleep 2 michael@325: rc snmp start michael@325: michael@325: %daily -u @l_susr@ michael@325: rcService snmp enable yes || exit 0 michael@325: shtool rotate -f \ michael@325: -n ${snmp_log_numfiles} -s ${snmp_log_minsize} -d \ michael@325: -z ${snmp_log_complevel} -o @l_rusr@ -g @l_rgrp@ -m 644 \ michael@325: -P "${snmp_log_prolog}" \ michael@325: -E "${snmp_log_epilog}" \ michael@325: @l_prefix@/var/snmp/snmp.log michael@325: