From 6017a5751aa760fddb1011d1ab25c0fe59bb5d6b Mon Sep 17 00:00:00 2001 From: Robert Langhammer Date: Wed, 16 Mar 2022 11:36:22 +0100 Subject: [PATCH 1/2] fff-vpn-select: do not configure peers on vpn-stop There are two reasons why there should be no peers. Meshrouter without wan or no peers in hoodfile for a protocol. With this patch there is only one condition left for vpn-start-stop. Peers present or not. And it is less complicated to implement start/stop. Signed-off-by: Robert Langhammer --- .../fff-vpn-select/files/usr/sbin/vpn-select | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) 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 8f9be37e..565b1daa 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 @@ -24,19 +24,21 @@ done # configure vpn -if [ -n "$hoodfile" ] && [ -s "$hoodfile" ] ; then - json_load "$(cat "$hoodfile")" - json_select hood - json_get_var id id - json_select ".." - json_select vpn - json_get_keys vpn_keys - for key in $vpn_keys; do - json_select $key - json_get_var protocol protocol - "${protocol}_addpeer" - json_select ".." # back to vpn - done +if [ "$0" != "/usr/sbin/vpn-stop" ] ; then + if [ -n "$hoodfile" ] && [ -s "$hoodfile" ] ; then + json_load "$(cat "$hoodfile")" + json_select hood + json_get_var id id + json_select ".." + json_select vpn + json_get_keys vpn_keys + for key in $vpn_keys; do + json_select $key + json_get_var protocol protocol + "${protocol}_addpeer" + json_select ".." # back to vpn + done + fi fi # start/restart/stop vpnservices -- 2.39.2 From 7fff54218a4f919740dd7c3337a1f893f9bf194e Mon Sep 17 00:00:00 2001 From: Robert Langhammer Date: Wed, 16 Mar 2022 11:44:12 +0100 Subject: [PATCH 2/2] fff-fastd: fix fastd start/stop fastd startup changed to procd. That's why it's broken. Now a fastd reload can be used for all conditions. An extra fastd stop is implemented to bring down the Interface. fastd reload doesn't do that. Fixes: #215 Signed-off-by: Robert Langhammer --- .../fff/fff-fastd/files/usr/lib/vpn-select.d/fastd | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/packages/fff/fff-fastd/files/usr/lib/vpn-select.d/fastd b/src/packages/fff/fff-fastd/files/usr/lib/vpn-select.d/fastd index 0fde6809..2474ae17 100644 --- a/src/packages/fff/fff-fastd/files/usr/lib/vpn-select.d/fastd +++ b/src/packages/fff/fff-fastd/files/usr/lib/vpn-select.d/fastd @@ -1,7 +1,7 @@ protocol=fastd fastd_clear() { - rm /tmp/fastd_fff_peers/* + rm /tmp/fastd_fff_peers/* 2>/dev/null } fastd_addpeer() { @@ -21,14 +21,9 @@ fastd_addpeer() { } fastd_start_stop() { - /etc/init.d/fastd reload # does nothing if fastd was not running - - # fastd start/stop for various situations - # this is needed for first start and if fastd comes up or disappears in hoodfile - 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 ls /etc/fastd/fff/peers/* &>/dev/null; then + /etc/init.d/fastd reload else - ([ -s "$pidfile" ] && [ -d "/proc/$(cat "$pidfile")" ]) && /etc/init.d/fastd stop + /etc/init.d/fastd stop fi } -- 2.39.2