Skip to content

Commit

Permalink
falter-berlin-uplink-notunnel: apply shellcheck fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Hübner <martin.hubner@web.de>
  • Loading branch information
Akira25 committed Jun 11, 2023
1 parent b869f3a commit ce886b1
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/falter-berlin-uplink-notunnel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=falter-berlin-uplink-notunnel
PKG_VERSION:=2
PKG_VERSION:=3

include $(INCLUDE_DIR)/package.mk

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/sh

# shellcheck source=/dev/null
# shellcheck disable=SC2154

[ "$INTERFACE" = wan ] || exit

. /lib/functions.sh
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/sh

# shellcheck disable=SC2154
# shellcheck source=/dev/null

[ "$INTERFACE" = wan ] || exit

. /lib/functions.sh
Expand All @@ -12,9 +15,9 @@ config_get ffuplink preset current
# Make sure ffuplink is not already up
. /usr/share/libubox/jshn.sh
json_load "$(ubus call network.interface.ffuplink status)"
json_select $1
json_select "$1"
json_get_vars up
[ "$up" == "0" ] || exit
[ "$up" = "0" ] || exit

# Internet connectivity via WAN is up, start the ffuplink interface
# In the case where ffuplink is set disabled '1', then ifup dies quietly
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
#!/bin/sh

# shellcheck shell=dash

# shellcheck source=/dev/null

# shellcheck disable=SC2034
# shellcheck disable=SC2155
# shellcheck disable=SC2140

THIS_UPLINKNAME="notunnel"

. /lib/functions/freifunk-berlin-network.sh
. /lib/functions/freifunk-berlin-network.sh
. /lib/functions/guard.sh
. /lib/functions.sh

Expand All @@ -11,11 +19,11 @@ uci set firewall.zone_ffuplink.masq=1
uci commit firewall

current_preset=$(uci get ffberlin-uplink.preset.current)
if [ ${current_preset} != ${THIS_UPLINKNAME} ]; then
if [ "${current_preset}" != ${THIS_UPLINKNAME} ]; then
# do not track preset when it was 'undefined', aka never configured
if [ ${current_preset} != "undefined" ]; then
if [ "${current_preset}" != "undefined" ]; then
logger -t "ffuplink" "uplink-preset has been changed."
uci set ffberlin-uplink.preset.previous=${current_preset}
uci set ffberlin-uplink.preset.previous="${current_preset}"
create_ffuplink
fi
uci set ffberlin-uplink.preset.current=${THIS_UPLINKNAME}
Expand All @@ -24,15 +32,15 @@ fi
uci set ffberlin-uplink.uplink.auth=none

# disable tunneldigger for ffuplink, if tunneldigger was the previous setup
if [ ${current_preset} == "tunnelberlin_tunneldigger" ]; then
if [ "${current_preset}" = "tunnelberlin_tunneldigger" ]; then
uci set tunneldigger.ffuplink.enabled=0
uci commit tunneldigger
fi

macaddr=$(uci -q get ffberlin-uplink.uplink.macaddr)
if [ -z "$macaddr" ]; then
macaddr=$(generate_random_mac_hex "fe")
uci set ffberlin-uplink.uplink.macaddr=$macaddr
uci set ffberlin-uplink.uplink.macaddr="$macaddr"
fi

uci commit ffberlin-uplink
Expand All @@ -44,25 +52,25 @@ uci set network.ffuplink_dev=device
uci set network.ffuplink_dev.type=veth
uci set network.ffuplink_dev.name=ffuplink
uci set network.ffuplink_dev.peer_name=ffuplink_wan
uci set network.ffuplink_dev.macaddr=$macaddr
uci set network.ffuplink_dev.macaddr="$macaddr"
uci commit network.ffuplink_dev

# add ffuplink_dev to the br-wan bridge if not there
devname=$(uci get network.wan.device)
handle_wan_device() {
local config=$1
local config="$1"
local name=""
local ports=""
local wandev=$(uci -q get network.wan.device)
if [ -z $wandev ]; then
local wandev="$(uci -q get network.wan.device)"
if [ -z "$wandev" ]; then
return
fi

config_get name $config name
if [ "X${name}X" == "Xbr-wanX" ]; then
config_get ports $config ports
list_contains ports ffuplink_wan || uci add_list network.${config}.ports="ffuplink_wan"
uci commit network.${config}
config_get name "$config" name
if [ "X${name}X" = "Xbr-wanX" ]; then
config_get ports "$config" ports
list_contains ports ffuplink_wan || uci add_list network."${config}".ports="ffuplink_wan"
uci commit network."${config}"
fi
}

Expand All @@ -71,6 +79,6 @@ config_load network
config_foreach handle_wan_device device

uci set network.ffuplink.proto=dhcp
uci set network.ffuplink.hostname=freifunk-$(echo $macaddr|tr -d :)-uplink
uci set network.ffuplink.hostname=freifunk-"$(echo "$macaddr"|tr -d :)"-uplink
uci commit network.ffuplink

0 comments on commit ce886b1

Please sign in to comment.