forked from freifunk-franken/firmware
vpn-select: indent contents of make_config function
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 <freifunk@adrianschmutzler.de> Reviewed-by: Fabian Bläse <fabian@blaese.de>
This commit is contained in:
parent
91808ad710
commit
a8f7dce6fc
|
@ -1,7 +1,7 @@
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=fff-vpn-select
|
PKG_NAME:=fff-vpn-select
|
||||||
PKG_RELEASE:=4
|
PKG_RELEASE:=5
|
||||||
|
|
||||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
|
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
|
||||||
|
|
||||||
|
|
|
@ -7,34 +7,36 @@
|
||||||
hoodfile="$1"
|
hoodfile="$1"
|
||||||
|
|
||||||
make_config() {
|
make_config() {
|
||||||
# remove old config
|
# remove old config
|
||||||
rm /tmp/fastd_fff_peers/*
|
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
|
|
||||||
}
|
|
||||||
|
|
||||||
# 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
|
# Only do something if file is there and not empty; otherwise exit 1
|
||||||
if [ -s "$hoodfile" ]; then
|
if [ -s "$hoodfile" ]; then
|
||||||
|
|
Loading…
Reference in New Issue
Block a user