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

Closed
adschm wants to merge 1 commits from adschm/firmware:vpnlogic into master
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