From dadde41b3c242d65b042be6c89389c138c42ba85 Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Mon, 14 Dec 2020 13:30:21 +0100 Subject: [PATCH] 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 --- src/packages/fff/fff-vpn-select/Makefile | 2 +- src/packages/fff/fff-vpn-select/files/usr/sbin/vpn-select | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/packages/fff/fff-vpn-select/Makefile b/src/packages/fff/fff-vpn-select/Makefile index ad481c6d..8f3d3599 100644 --- a/src/packages/fff/fff-vpn-select/Makefile +++ b/src/packages/fff/fff-vpn-select/Makefile @@ -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) diff --git a/src/packages/fff/fff-vpn-select/files/usr/sbin/vpn-select b/src/packages/fff/fff-vpn-select/files/usr/sbin/vpn-select index 30883f50..9efb0137 100755 --- a/src/packages/fff/fff-vpn-select/files/usr/sbin/vpn-select +++ b/src/packages/fff/fff-vpn-select/files/usr/sbin/vpn-select @@ -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