fff-vpn-select: improve logic for fastd start/stop

The start/stop part of fff-vpn-select currently uses a subshell
for what is meant to be logic grouping. Address that by swapping
condition levels and add comment to explain what is actually done.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
This commit is contained in:
Adrian Schmutzler 2020-12-14 13:30:21 +01:00
parent 4f76367b5a
commit dadde41b3c
2 changed files with 6 additions and 4 deletions

View File

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=fff-vpn-select
PKG_RELEASE:=5
PKG_RELEASE:=6
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)

View File

@ -52,10 +52,12 @@ if [ -s "$hoodfile" ]; then
# fastd start/stop for various situations
pidfile="/tmp/run/fastd.fff.pid"
if [ "$(ls /etc/fastd/fff/peers/* 2>/dev/null)" ]; then
([ -s "$pidfile" ] && [ -d "/proc/$(cat "$pidfile")" ]) || /etc/init.d/fastd start
if [ -s "$pidfile" ] && [ -d "/proc/$(cat "$pidfile")" ]; then
# Stop if service is running but no peers present
[ "$(ls /etc/fastd/fff/peers/* 2>/dev/null)" ] || /etc/init.d/fastd stop
else
([ -s "$pidfile" ] && [ -d "/proc/$(cat "$pidfile")" ]) && /etc/init.d/fastd stop
# Start if service is not running but peers are present
[ "$(ls /etc/fastd/fff/peers/* 2>/dev/null)" ] && /etc/init.d/fastd start
fi
fi
exit 0