alfred: Fix procd process handling for disable state

Alfred can be stopped during a (re)start or reload when:

* disabled = 1
* batman-adv interface is missing
* MAC based EUI64 IPv6 link-local address not set

It is assumed that procd detects that the procd instance definition
disappeared and the currently running instance must be stopped. But all
these checks were triggering an "exit" which then stopped the alfred init
script and the wrapper from /lib/functions/procd.sh. And thus procd was
never informed about the instances which should be changed.

The correct handling is to return the result of the function instead of
directly killing the init scripts.

Fixes: 45db0e60d2 ("alfred: use procd")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
This commit is contained in:
Sven Eckelmann 2021-02-15 21:03:57 +01:00
parent 58e0a4d5c3
commit 993f03cecb
2 changed files with 8 additions and 6 deletions

View file

@ -4,7 +4,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=alfred PKG_NAME:=alfred
PKG_VERSION:=2021.0 PKG_VERSION:=2021.0
PKG_RELEASE:=1 PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION) PKG_SOURCE_URL:=https://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION)

View file

@ -24,10 +24,12 @@ wait_for_dir() {
[ -d "$dir" ] && break [ -d "$dir" ] && break
if [ $i = $timeout ] ; then if [ $i = $timeout ] ; then
echo "$ifce not detected, alfred not starting." echo "$ifce not detected, alfred not starting."
exit 1 return 1
fi fi
done done
fi fi
return 0
} }
wait_for_ll_address() { wait_for_ll_address() {
@ -45,13 +47,13 @@ wait_for_ll_address() {
$1 ~ /^fe80/ && $5 ~ /^[012389ab]/ && $6 == "'"$iface"'" { RET=0 } $1 ~ /^fe80/ && $5 ~ /^[012389ab]/ && $6 == "'"$iface"'" { RET=0 }
END { exit RET } END { exit RET }
' /proc/net/if_inet6; then ' /proc/net/if_inet6; then
return return 0
fi fi
sleep 1 sleep 1
done done
echo "$iface address not detected, alfred not starting." echo "$iface address not detected, alfred not starting."
exit 1 return 1
} }
append_interface() append_interface()
@ -86,7 +88,7 @@ alfred_start() {
append args "-b $batmanif" append args "-b $batmanif"
if [ "$batmanif" != "none" ]; then if [ "$batmanif" != "none" ]; then
wait_for_dir "$batmanif" "/sys/devices/virtual/net/$batmanif" wait_for_dir "$batmanif" "/sys/devices/virtual/net/$batmanif" || return 1
fi fi
append alfred_args "$args" append alfred_args "$args"
@ -107,7 +109,7 @@ start_service() {
config_load "alfred" config_load "alfred"
config_foreach alfred_start alfred config_foreach alfred_start alfred
[ "$enable" = "0" ] && exit 0 [ "$enable" = "0" ] && return 0
procd_open_instance "alfred" procd_open_instance "alfred"
procd_set_param command /usr/sbin/alfred procd_set_param command /usr/sbin/alfred