diff options
author | Nick Hainke <vincent@systemli.org> | 2022-01-19 18:40:16 +0100 |
---|---|---|
committer | Nick Hainke <vincent@systemli.org> | 2022-01-20 02:04:50 +0100 |
commit | 69c81790d1045e064cd9c643a1643a0f919f448d (patch) | |
tree | e5fe7b9e6f04d55b87031bb41a6451468b59681c /net/wg-installer/wg-server/hotplug.d | |
parent | 8ca0439f97197d8bebe4337846e9209b2f0f1a0d (diff) |
wg-installer: rework code
Use shellcheck to rework the code. Use "export" to return variables from
a function call. Further, fix typos.
Signed-off-by: Nick Hainke <vincent@systemli.org>
Diffstat (limited to 'net/wg-installer/wg-server/hotplug.d')
-rw-r--r-- | net/wg-installer/wg-server/hotplug.d/99-mesh-babeld | 14 | ||||
-rw-r--r-- | net/wg-installer/wg-server/hotplug.d/99-mesh-olsrd | 10 |
2 files changed, 12 insertions, 12 deletions
diff --git a/net/wg-installer/wg-server/hotplug.d/99-mesh-babeld b/net/wg-installer/wg-server/hotplug.d/99-mesh-babeld index 1f8646e28..49c2f1f18 100644 --- a/net/wg-installer/wg-server/hotplug.d/99-mesh-babeld +++ b/net/wg-installer/wg-server/hotplug.d/99-mesh-babeld @@ -6,31 +6,31 @@ if [ "${DEVTYPE}" != "wireguard" ]; then fi # check if correct naming -slicedint=$(echo $INTERFACE | cut -c1-3) +slicedint=$(echo "$INTERFACE" | cut -c1-3) if [ "${slicedint}" != "wg_" ]; then exit 0 fi -if [ "${ACTION}" == "add" ]; then +if [ "${ACTION}" = "add" ]; then uci add babeld interface uci set babeld.@interface[-1].ifname="${INTERFACE}" uci get wgserver.@babeld_hotplug[0].rxcost - if [ $? ]; then + if [ $? -eq 0 ]; then babeld_rxcost="$(uci get wgserver.@babeld_hotplug[0].rxcost)" uci set babeld.@interface[-1].rxcost="$babeld_rxcost" fi - uci -c "$(dirname $(realpath /etc/config/babeld))" commit babeld + uci -c "$(dirname "$(realpath /etc/config/babeld)")" commit babeld /etc/init.d/babeld reload fi -if [ "${ACTION}" == "remove" ]; then +if [ "${ACTION}" = "remove" ]; then i=0 while uci get babeld.@interface[$i] &> /dev/null ; do - if [ "$(uci get babeld.@interface[$i].ifname)" == "${INTERFACE}" ]; then + if [ "$(uci get babeld.@interface[$i].ifname)" = "${INTERFACE}" ]; then uci delete babeld.@interface[$i] fi i=$((i+1)); done - uci -c "$(dirname $(realpath /etc/config/babeld))" commit babeld + uci -c "$(dirname "$(realpath /etc/config/babeld)")" commit babeld /etc/init.d/babeld reload fi diff --git a/net/wg-installer/wg-server/hotplug.d/99-mesh-olsrd b/net/wg-installer/wg-server/hotplug.d/99-mesh-olsrd index ebc2e1f64..afb84ecba 100644 --- a/net/wg-installer/wg-server/hotplug.d/99-mesh-olsrd +++ b/net/wg-installer/wg-server/hotplug.d/99-mesh-olsrd @@ -6,15 +6,15 @@ if [ "${DEVTYPE}" != "wireguard" ]; then fi # check if correct naming -slicedint=$(echo $INTERFACE | cut -c1-3) +slicedint=$(echo "$INTERFACE" | cut -c1-3) if [ "${slicedint}" != "wg_" ]; then exit 0 fi -if [ "${ACTION}" == "add" ]; then - ubus call olsrd add_interface '{"ifname":'\"$INTERFACE\"'}' +if [ "${ACTION}" = "add" ]; then + ubus call olsrd add_interface '{"ifname":'\""$INTERFACE"\"'}' fi -if [ "${ACTION}" == "remove" ]; then - ubus call olsrd del_interface '{"ifname":'\"$INTERFACE\"'}' +if [ "${ACTION}" = "remove" ]; then + ubus call olsrd del_interface '{"ifname":'\""$INTERFACE"\"'}' fi |