[OpenWrt-Devel] [PATCH 2/2] wireguard.sh: Run through shellcheck
Rosen Penev
rosenp at gmail.com
Tue Dec 31 21:08:22 EST 2019
Missing local variables and quoting fixes.
Signed-off-by: Rosen Penev <rosenp at gmail.com>
---
.../network/utils/wireguard-tools/files/wireguard.sh | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/package/network/utils/wireguard-tools/files/wireguard.sh b/package/network/utils/wireguard-tools/files/wireguard.sh
index 1e424e7959..561a304ef3 100644
--- a/package/network/utils/wireguard-tools/files/wireguard.sh
+++ b/package/network/utils/wireguard-tools/files/wireguard.sh
@@ -68,7 +68,7 @@ proto_wireguard_setup_peer() {
[ "${persistent_keepalive}" ] && echo "PersistentKeepalive=${persistent_keepalive}"
} >> "${wg_cfg}"
- if [ ${route_allowed_ips} -ne 0 ]; then
+ if [ "${route_allowed_ips}" -ne 0 ]; then
for allowed_ip in ${allowed_ips}; do
case "${allowed_ip}" in
*:*/*)
@@ -95,7 +95,11 @@ proto_wireguard_setup() {
local private_key
local listen_port
+ local addresses
local mtu
+ local fwmark
+ local ip6prefix
+ local nohostroute
config_load network
config_get private_key "${config}" "private_key"
@@ -126,7 +130,7 @@ proto_wireguard_setup() {
config_foreach proto_wireguard_setup_peer "wireguard_${config}"
# apply configuration file
- ${WG} setconf ${config} "${wg_cfg}"
+ ${WG} setconf "${config}" "${wg_cfg}"
WG_RETURN=$?
rm -f "${wg_cfg}"
@@ -162,7 +166,7 @@ proto_wireguard_setup() {
if [ "${nohostroute}" != "1" ]; then
wg show "${config}" endpoints | \
sed -E 's/\[?([0-9.:a-f]+)\]?:([0-9]+)/\1 \2/' | \
- while IFS=$'\t ' read -r key address port; do
+ while IFS="$(printf '\t')" read -r address port; do
[ -n "${port}" ] || continue
proto_add_host_dependency "${config}" "${address}"
done
--
2.24.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list