From a8f7dce6fc16aa526e23e74ef7339b49e462ac39 Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Fri, 17 Apr 2020 17:54:49 +0200 Subject: [PATCH] vpn-select: indent contents of make_config function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a purely cosmetic change to enhance the readability of the function. Also add some empty lines and comments for overview. Signed-off-by: Adrian Schmutzler Reviewed-by: Fabian Bläse --- src/packages/fff/fff-vpn-select/Makefile | 2 +- .../fff-vpn-select/files/usr/sbin/vpn-select | 56 ++++++++++--------- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/packages/fff/fff-vpn-select/Makefile b/src/packages/fff/fff-vpn-select/Makefile index 267ed447..55825555 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:=4 +PKG_RELEASE:=5 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 b3efc6b8..30883f50 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 @@ -7,34 +7,36 @@ hoodfile="$1" make_config() { -# remove old config -rm /tmp/fastd_fff_peers/* -Index=1 -json_load "$(cat "$hoodfile")" -json_select vpn -# get fastd peers -while json_select "$Index" > /dev/null -do - json_get_var protocol protocol - if [ "$protocol" = "fastd" ]; then - json_get_var servername name - filename="/etc/fastd/fff/peers/$servername" - echo "#name \"${servername}\";" > "$filename" - json_get_var key key - echo "key \"${key}\";" >> "$filename" - json_get_var address address - json_get_var port port - echo "remote \"${address}\" port ${port};" >> "$filename" - echo "" >> "$filename" - echo "float yes;" >> "$filename" - fi - json_select ".." # back to vpn - Index=$(( Index + 1 )) -done -json_select ".." # back to root -} + # remove old config + rm /tmp/fastd_fff_peers/* -# main + # prepare + Index=1 + json_load "$(cat "$hoodfile")" + json_select vpn + + # get fastd peers + while json_select "$Index" > /dev/null + do + json_get_var protocol protocol + if [ "$protocol" = "fastd" ]; then + # set up fastd + json_get_var servername name + filename="/etc/fastd/fff/peers/$servername" + echo "#name \"${servername}\";" > "$filename" + json_get_var key key + echo "key \"${key}\";" >> "$filename" + json_get_var address address + json_get_var port port + echo "remote \"${address}\" port ${port};" >> "$filename" + echo "" >> "$filename" + echo "float yes;" >> "$filename" + fi + json_select ".." # back to vpn + Index=$(( Index + 1 )) + done + json_select ".." # back to root +} # Only do something if file is there and not empty; otherwise exit 1 if [ -s "$hoodfile" ]; then