From: Nicolas Thill Date: Wed, 16 Nov 2011 09:44:31 +0000 (+0000) Subject: packages/mini_snmpd: use new service functions, various changes: X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=3039b41c5a6bdb6fa5e16e5b8edfdb81e4fc5bc3;p=openwrt%2Fsvn-archive%2Farchive.git packages/mini_snmpd: use new service functions, various changes: * changes 'disks' & 'interfaces' options to list * default 'enabled' to false * mark '/etc/config/mini_snmpd' as a config file SVN-Revision: 29182 --- diff --git a/net/mini_snmpd/Makefile b/net/mini_snmpd/Makefile index 846ac579b8..a6182a3fae 100644 --- a/net/mini_snmpd/Makefile +++ b/net/mini_snmpd/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mini_snmpd PKG_VERSION:=1.2b -PKG_RELEASE:=4 +PKG_RELEASE:=5 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=http://members.aon.at/linuxfreak/linux/ @@ -54,4 +54,8 @@ define Package/mini-snmpd/install $(INSTALL_BIN) ./files/mini_snmpd.init $(1)/etc/init.d/mini_snmpd endef +define Package/mini-snmpd/conffiles +/etc/config/mini_snmpd +endef + $(eval $(call BuildPackage,mini-snmpd)) diff --git a/net/mini_snmpd/files/mini_snmpd.config b/net/mini_snmpd/files/mini_snmpd.config index 43ab93141f..e41bdc9578 100644 --- a/net/mini_snmpd/files/mini_snmpd.config +++ b/net/mini_snmpd/files/mini_snmpd.config @@ -1,8 +1,16 @@ config mini_snmpd - option enabled 1 + option enabled 0 option ipv6 0 - option community public - option location '' + option community 'public' option contact '' - option disks '/tmp,/jffs' - option interfaces 'lo,br-lan,eth0.1,eth1' # Max 4 + option location '' + + # enable basic disk usage statistics on specified mountpoint + list disks '/jffs' + list disks '/tmp' + + # enable basic network statistics on specified interface + # 4 interfaces maximum, as named in /etc/config/network + list interfaces 'loopback' + list interfaces 'lan' + list interfaces 'wan' diff --git a/net/mini_snmpd/files/mini_snmpd.init b/net/mini_snmpd/files/mini_snmpd.init index cc051c0bdb..fe57fbbbfa 100644 --- a/net/mini_snmpd/files/mini_snmpd.init +++ b/net/mini_snmpd/files/mini_snmpd.init @@ -1,10 +1,23 @@ #!/bin/sh /etc/rc.common -# Copyright (C) 2009 OpenWrt.org +# Copyright (C) 2009-2011 OpenWrt.org -NAME=mini_snmpd -PROG=/usr/bin/$NAME START=50 +SERVICE_DAEMONIZE=1 +SERVICE_WRITE_PID=1 + +append_disk() { + local disk="$1" + append disks "$disk" ',' +} + +append_interface() { + local name="$1" + local interface + config_get interface "$name" 'ifname' + append interfaces "$interface" ',' +} + append_string() { local section="$1" local option="$2" @@ -14,28 +27,39 @@ append_string() { [ -n "$_val" ] && append args "$3 $_val" } -mini_snmpd_config() { +start_instance() { local cfg="$1" - args="" + local args="" + local disks="" + local interfaces="" + local ipv6 append_string "$cfg" community "-c" append_string "$cfg" location "-L" append_string "$cfg" contact "-C" - append_string "$cfg" disks "-d" - append_string "$cfg" interfaces "-i" config_get_bool ipv6 "$cfg" "ipv6" '0' [ "$ipv6" -gt 0 ] && append args "-6" config_get_bool enabled "$cfg" "enabled" '1' - [ "$enabled" -gt 0 ] && $PROG $args & + [ "$enabled" -gt 0 ] || return 1 + + config_list_foreach "$section" 'disks' append_disk + args="${args}${disks:+ -d $disks}" + + config_list_foreach "$section" 'interfaces' append_interface + args="${args}${interfaces:+ -i $interfaces}" + + service_start /usr/bin/mini_snmpd $args } start() { - config_load mini_snmpd - config_foreach mini_snmpd_config mini_snmpd + include /lib/network + scan_interfaces + config_load 'mini_snmpd' + config_foreach start_instance 'mini_snmpd' } stop() { - killall mini_snmpd + service_stop /usr/bin/mini_snmpd }