diff --git a/net/ampr-ripd/Makefile b/net/ampr-ripd/Makefile index 511fef29f5..27dce8a145 100644 --- a/net/ampr-ripd/Makefile +++ b/net/ampr-ripd/Makefile @@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ampr-ripd PKG_VERSION:=2.4.2 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tgz PKG_SOURCE_URL:=https://yo2loj.ro/hamprojects @@ -24,7 +24,8 @@ define Package/ampr-ripd endef define Package/ampr-ripd/description - Routing daemon written in C similar to Hessu's rip44d including optional resending of RIPv2 broadcasts for router injection. + Routing daemon written in C similar to Hessu's rip44d including + optional resending of RIPv2 broadcasts for router injection. endef CONFIGURE_VARS+= \ @@ -48,46 +49,43 @@ define Package/ampr-ripd/postrm [ -z "$${IPKG_INSTROOT}" ] || exit 0 echo "Removing firewall rules..." -for i in $$(seq 99 -1 0); do - if [ $$(uci -q get firewall.@rule[$$i]) ]; then - name=$$(uci get firewall.@rule[$$i].name) - if [ "$$name" = "Net 44 ICMP Echo Request" ] \ - || [ "$$name" = "Net 44 Router ICMP" ] \ - || [ "$$name" = "ipip" ]; then - uci del firewall.@rule[$$i] - fi +count=$$(( $$(uci show firewall | grep -c "=rule") - 1 )) +for i in $$(seq "$$count" -1 0); do + name=$$(uci get firewall.@rule["$$i"].name) + if [ "$$name" = "Net 44 ICMP Echo Request" ] \ + || [ "$$name" = "Net 44 Router ICMP" ] \ + || [ "$$name" = "ipip" ]; then + uci del firewall.@rule["$$i"] fi done uci commit firewall echo "Removing network rules..." -for i in $$(seq 99 -1 0); do - if [ $$(uci -q get network.@rule[$$i]) ]; then - lookup=$$(uci get network.@rule[$$i].lookup) - if [ "$$lookup" = "44" ]; then - uci del network.@rule[$$i] - fi +count=$$(( $$(uci show network | grep -c "=rule") - 1 )) +for i in $$(seq "$$count" -1 0); do + lookup=$$(uci get network.@rule["$$i"].lookup) + if [ "$$lookup" = "44" ]; then + uci del network.@rule["$$i"] fi done uci commit network echo "Removing firewall zone forwarding rules..." -for i in $$(seq 99 -1 0); do - if [ $$(uci -q get firewall.@forwarding[$$i]) ]; then - name=$$(uci get firewall.@forwarding[$$i].src) - if [ "$$name" = "amprlan" ] || [ "$$name" = "amprwan" ]; then - uci del firewall.@forwarding[$$i] - fi +count=$$(( $$(uci show firewall | grep -c "=forwarding") -1 )) +for i in $$(seq "$$count" -1 0); do + name=$$(uci get firewall.@forwarding["$$i"].src) + if [ "$$name" = "amprlan" ] || [ "$$name" = "amprwan" ]; then + uci del firewall.@forwarding["$$i"] fi done +uci commit firewall echo "Removing firewall zones..." -for i in $$(seq 99 -1 0); do - if [ $$(uci -q get firewall.@zone[$$i]) ]; then - name=$$(uci get firewall.@zone[$$i].name) - if [ "$$name" = "amprlan" ] || [ "$$name" = "amprwan" ]; then - uci del firewall.@zone[$$i] - fi +count=$$(( $$(uci show firewall | grep -c "=zone") -1 )) +for i in $$(seq "$$count" -1 0); do + name=$$(uci get firewall.@zone["$$i"].name) + if [ "$$name" = "amprlan" ] || [ "$$name" = "amprwan" ]; then + uci del firewall.@zone["$$i"] fi done uci commit firewall diff --git a/net/ampr-ripd/files/ampr-ripd-init b/net/ampr-ripd/files/ampr-ripd-init index 6f1a8f426e..e1df78aca0 100755 --- a/net/ampr-ripd/files/ampr-ripd-init +++ b/net/ampr-ripd/files/ampr-ripd-init @@ -3,8 +3,7 @@ START=95 STOP=10 -EXTRA_COMMANDS="configure" -EXTRA_HELP=" configure Configure service parameters" +extra_command "configure" "Configure service parameters" start() { default_addr="44.127.254.254" @@ -66,12 +65,9 @@ configure() { uci set network.amprlan.netmask="$amprmask" uci set network.amprwan.ipaddr="$amprhost" uci set network.amprwan.netmask="$amprmask" - for i in $(seq 0 -1 -99); do - if [ ! -z $(uci -q get network.@rule[$i].src) ] && \ - [ "$(uci get network.@rule[$i].lookup)" = "44" ] && \ - [ "$(uci get network.@rule[$i].priority)" = "45" ]; then - uci set network.@rule[$i].src="$tunnet" - break + for i in $(uci show network | awk -F= "/@rule/ && /lookup='44'/ {split(\$1, conf, /[.=]/); print conf[2]}"); do + if [ "$(uci -q get "network.$i.priority")" = "45" ]; then + uci set "network.$i.src=$tunnet" fi done uci commit network diff --git a/net/ampr-ripd/test.sh b/net/ampr-ripd/test.sh new file mode 100644 index 0000000000..c8a730ae27 --- /dev/null +++ b/net/ampr-ripd/test.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +"$1" -h 2>&1 | grep "$PKG_VERSION"