Last fixed patch ;)
Please use only that and ignore the two patch before

On Saturday 15 October 2011 10:39:13 Gioacchino Mazzurco wrote:
> Better patch also more openwrt styled makefile
> 
> On Friday 14 October 2011 12:23:45 Gioacchino Mazzurco wrote:
> > I have done a patch that make mini_snmpd more uci style
> > 
> > +Instead of one option with comma separated interfaces now use uci list
> > +Intestad of use only real interface name now can use also uci interface
> > name the init script check if the interface name specified is from uci
> > than traslate it to real name interface if not check if the interface
> > exist then add it if not exist print an error message and ignore the
> > interface
> > 
> > suggestion are welcomed ;)
> > 
> > On Friday 14 October 2011 11:04:20 you wrote:
> > > Hey all!
> > > 
> > > I see that in mini_snmpd config you have to use a list of real name
> > > interfaces comma separated, that not the uci style...
> > > 
> > > I am thinking to write a patch to use uci list instead of option and
> > > more over you can use uci network name also instead of real name
> > > interface only
> > > 
> > > What do you thinks about that ?
Index: net/mini_snmpd/files/mini_snmpd.init
===================================================================
--- net/mini_snmpd/files/mini_snmpd.init	(revision 28448)
+++ net/mini_snmpd/files/mini_snmpd.init	(working copy)
@@ -5,7 +5,8 @@
 PROG=/usr/bin/$NAME
 START=50
 
-append_string() {
+append_string()
+{
 	local section="$1"
 	local option="$2"
 	local value="$3"
@@ -14,7 +15,8 @@
 	[ -n "$_val" ] && append args "$3 $_val"
 }
 
-mini_snmpd_config() {
+mini_snmpd_config()
+{
 	local cfg="$1"
 	args=""
 
@@ -22,8 +24,23 @@
 	append_string "$cfg" location "-L"
 	append_string "$cfg" contact "-C"
 	append_string "$cfg" disks "-d"
-	append_string "$cfg" interfaces "-i"
 
+
+	local confInterfaces;	config_get confInterfaces "$cfg" "interfaces"
+	local interfaces
+
+	for interface in $confInterfaces
+	do
+	  ifname=$(uci -P /var/state get network.$interface.ifname 2>&-)
+	  [ ! "void$ifname" = "void" ]		&& interfaces="$interfaces,$ifname"	&& continue 
+	  [ -d "/sys/class/net/$interface" ]	&& interfaces="$interfaces,$interface"	&& continue
+	  
+	  echo "Can't add interface $interface - ignoring"
+	done
+
+	interfaces=$(echo $interfaces | sed 's/^[,\t]*//;s/[,\t]*$//')
+	append args "-i $interfaces"
+
 	config_get_bool ipv6 "$cfg" "ipv6" '0'
 	[ "$ipv6" -gt 0 ] && append args "-6"
 
@@ -31,11 +48,13 @@
 	[ "$enabled" -gt 0 ] && $PROG $args &
 }
 
-start() {
+start()
+{
 	config_load mini_snmpd
 	config_foreach mini_snmpd_config mini_snmpd
 }
 
-stop() {
+stop()
+{
 	killall mini_snmpd
 }
Index: net/mini_snmpd/files/mini_snmpd.config
===================================================================
--- net/mini_snmpd/files/mini_snmpd.config	(revision 28448)
+++ net/mini_snmpd/files/mini_snmpd.config	(working copy)
@@ -1,8 +1,14 @@
 config mini_snmpd
-	option enabled 1
-	option ipv6 0
-	option community public
-	option location ''
-	option contact ''
-	option disks '/tmp,/jffs'
-	option interfaces 'lo,br-lan,eth0.1,eth1' # Max 4
+	option	enabled		1
+	option	ipv6		1
+	option	community	public
+	option	location	''
+	option	contact		''
+	option	disks		'/tmp,/jffs'
+	list	interfaces	'loopback'
+	list	interfaces	'lan'
+	list	interfaces	'wan'
+
+## REMOVEME: On the wiki [0] is reported Max 4 interfaces
+## REMOVEME: Maybe a mini_snmpd code limitation...
+## REMOVEME: [0] http://wiki.openwrt.org/doc/uci/mini_snmpd
Index: net/mini_snmpd/Makefile
===================================================================
--- net/mini_snmpd/Makefile	(revision 28448)
+++ net/mini_snmpd/Makefile	(working copy)
@@ -7,27 +7,28 @@
 
 include $(TOPDIR)/rules.mk
 
-PKG_NAME:=mini_snmpd
+PKG_NAME:=eigen-mini-snmpd
 PKG_VERSION:=1.2b
-PKG_RELEASE:=3
+PKG_RELEASE:=4
 
-PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SNAME:=mini_snmpd
+PKG_SOURCE:=$(PKG_SNAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=http://members.aon.at/linuxfreak/linux/
 PKG_MD5SUM:=9e432c50ba8216d7fab0983b11b7112a
 
-PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)/$(PKG_NAME)
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)/$(PKG_SNAME)
 PKG_BUILD_PARALLEL:=1
 PKG_INSTALL:=1
 
 include $(INCLUDE_DIR)/package.mk
 
-define Package/mini-snmpd/Default
+define Package/$(PKG_NAME)/Default
   TITLE:=SNMP server for embedded systems
   URL:=http://members.aon.at/linuxfreak/linux/mini_snmpd.html
 endef
 
-define Package/mini-snmpd
-$(call Package/mini-snmpd/Default)
+define Package/$(PKG_NAME)
+$(call Package/$(PKG_NAME)/Default)
   SECTION:=net
   CATEGORY:=Network
   TITLE+= Mini Snmpd
@@ -50,7 +51,7 @@
 	$(call Build/Compile/Default,mini_snmpd)
 endef
 
-define Package/mini-snmpd/install
+define Package/$(PKG_NAME)/install
 	$(INSTALL_DIR) $(1)/usr/bin
 	$(CP) $(PKG_INSTALL_DIR)/sbin/mini_snmpd $(1)/usr/bin/
 	$(INSTALL_DIR) $(1)/etc/config
@@ -59,6 +60,6 @@
 	$(INSTALL_BIN) ./files/mini_snmpd.init $(1)/etc/init.d/mini_snmpd
 endef
 
-Package/mini-snmpd6/install=$(Package/mini-snmpd/install)
+Package/mini-snmpd6/install=$(Package/$(PKG_NAME)/install)
 
-$(eval $(call BuildPackage,mini-snmpd))
+$(eval $(call BuildPackage,$(PKG_NAME)))
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to