ampr-ripd: script improvements and add QA script

Added test.sh
Predetermine count used by for loops in Makefile postrm
Implemented extra_command in initscript
Resolved shellcheck issues
Bump release

Signed-off-by: Dan Srebnick <k2ie@k2ie.net>
This commit is contained in:
Dan Srebnick
2025-09-01 11:45:15 -04:00
committed by George Sapkin
parent 7de0c8799b
commit 551ef4a7c1
3 changed files with 33 additions and 36 deletions

View File

@@ -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)
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
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)
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
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)
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
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)
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
uci del firewall.@zone["$$i"]
fi
done
uci commit firewall

View File

@@ -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

3
net/ampr-ripd/test.sh Normal file
View File

@@ -0,0 +1,3 @@
#!/bin/sh
"$1" -h 2>&1 | grep "$PKG_VERSION"