alfred: Fix procd process handling for disable state
authorSven Eckelmann <sven@narfation.org>
Mon, 15 Feb 2021 20:03:57 +0000 (21:03 +0100)
committerSven Eckelmann <sven@narfation.org>
Mon, 15 Feb 2021 20:03:57 +0000 (21:03 +0100)
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: 45db0e60d2ff ("alfred: use procd")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
alfred/Makefile
alfred/files/alfred.init

index 14a2ca8f2c21d58b851e05d6e087d3551d940c2a..8ca6ecb82fe07c536eb9369742c51cd860ef582a 100644 (file)
@@ -4,7 +4,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=alfred
 PKG_VERSION:=2021.0
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION)
index 0c35e65ca5205aea52f9e01d68a020676a3ffa4f..e439be10f71647adb17c52743cec3f819ae31439 100755 (executable)
@@ -24,10 +24,12 @@ wait_for_dir() {
                        [ -d "$dir" ] && break
                        if [ $i = $timeout ] ; then
                                echo "$ifce not detected, alfred not starting."
-                               exit 1
+                               return 1
                        fi
                done
        fi
+
+       return 0
 }
 
 wait_for_ll_address() {
@@ -45,13 +47,13 @@ wait_for_ll_address() {
                        $1 ~ /^fe80/ && $5 ~ /^[012389ab]/ && $6 == "'"$iface"'" { RET=0 }
                        END { exit RET }
                ' /proc/net/if_inet6; then
-                       return
+                       return 0
                fi
                sleep 1
        done
 
        echo "$iface address not detected, alfred not starting."
-       exit 1
+       return 1
 }
 
 append_interface()
@@ -86,7 +88,7 @@ alfred_start() {
        append args "-b $batmanif"
 
        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
 
        append alfred_args "$args"
@@ -107,7 +109,7 @@ start_service() {
        config_load "alfred"
        config_foreach alfred_start alfred
 
-       [ "$enable" = "0" ] && exit 0
+       [ "$enable" = "0" ] && return 0
 
        procd_open_instance "alfred"
        procd_set_param command /usr/sbin/alfred