[PATCH v2 2/2] vpn-select: Indent contents of make_config function
Adrian Schmutzler
freifunk at adrianschmutzler.de
So Jul 29 12:36:37 CEST 2018
This is a purely cosmetic change to enhance the readability
of the function.
Also added some empty lines and comments for overview.
Signed-off-by: Adrian Schmutzler <freifunk at adrianschmutzler.de>
---
Introduced in v2.
---
.../fff/fff-vpn-select/files/usr/sbin/vpn-select | 91 ++++++++++++----------
1 file changed, 48 insertions(+), 43 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 ddd21a1..4a978d8 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,51 +7,56 @@
hoodfile="$1"
make_config() {
-# remove old config
->/etc/config/tunneldigger
-rm /tmp/fastd_fff_peers/*
-count=0
-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 ipv4 \"${address}\" port ${port};" >> "$filename"
- echo "" >> "$filename"
- echo "float yes;" >> "$filename"
-
- # ask for Broker and select the tunnel
- if [ "l2tp" = "$(wget -T10 "${address}/vpn.txt" -O - 2>/dev/null)" ]; then
- # Gateway offers l2tp
- L2PORT=$((port + 10000))
- UUID=$hostname
+ # remove old config
+ >/etc/config/tunneldigger
+ rm /tmp/fastd_fff_peers/*
- uci set tunneldigger.$count=broker
- uci set tunneldigger.$count.address="${address}:$L2PORT"
- uci set tunneldigger.$count.uuid="$UUID"
- uci set tunneldigger.$count.interface="l2tp$count"
- uci set tunneldigger.$count.enabled="1"
- uci set tunneldigger.$count.hook_script='/etc/tunneldigger/tunneldigger.hook'
- uci -c /tmp commit tunneldigger
- count=$((count + 1))
- # remove this fastd-peer
- rm "$filename"
+ # prepare
+ count=0
+ 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 ipv4 \"${address}\" port ${port};" >> "$filename"
+ echo "" >> "$filename"
+ echo "float yes;" >> "$filename"
+
+ # set up tunneldigger: ask for Broker and select the tunnel
+ if [ "l2tp" = "$(wget -T10 "${address}/vpn.txt" -O - 2>/dev/null)" ]; then
+ # Gateway offers l2tp
+ L2PORT=$((port + 10000))
+ UUID=$hostname
+
+ uci set tunneldigger.$count=broker
+ uci set tunneldigger.$count.address="${address}:$L2PORT"
+ uci set tunneldigger.$count.uuid="$UUID"
+ uci set tunneldigger.$count.interface="l2tp$count"
+ uci set tunneldigger.$count.enabled="1"
+ uci set tunneldigger.$count.hook_script='/etc/tunneldigger/tunneldigger.hook'
+ uci -c /tmp commit tunneldigger
+ count=$((count + 1))
+
+ # remove this fastd-peer (no connection via fastd AND tunneldigger)
+ rm "$filename"
+ fi
fi
- fi
- json_select ".." # back to vpn
- Index=$(( Index + 1 ))
-done
-json_select ".." # back to root
+ json_select ".." # back to vpn
+ Index=$(( Index + 1 ))
+ done
+ json_select ".." # back to root
}
# main
--
2.11.0
Mehr Informationen über die Mailingliste franken-dev