diff mbox series

[OpenWrt-Devel,2/2] wireguard.sh: run through shellcheck

Message ID 20200106023457.170813-2-rosenp@gmail.com
State Deferred
Headers show
Series [OpenWrt-Devel,1/2] wireguard.sh: batch file writes | expand

Commit Message

Rosen Penev Jan. 6, 2020, 2:34 a.m. UTC
Missing local variables and quoting fixes.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 package/network/utils/wireguard-tools/Makefile         |  2 +-
 .../network/utils/wireguard-tools/files/wireguard.sh   | 10 +++++++---
 2 files changed, 8 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/package/network/utils/wireguard-tools/Makefile b/package/network/utils/wireguard-tools/Makefile
index 2f6d307094..3336353af1 100644
--- a/package/network/utils/wireguard-tools/Makefile
+++ b/package/network/utils/wireguard-tools/Makefile
@@ -12,7 +12,7 @@  include $(INCLUDE_DIR)/kernel.mk
 PKG_NAME:=wireguard-tools
 
 PKG_VERSION:=1.0.20191226
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=wireguard-tools-$(PKG_VERSION).tar.xz
 PKG_SOURCE_URL:=https://git.zx2c4.com/wireguard-tools/snapshot/
diff --git a/package/network/utils/wireguard-tools/files/wireguard.sh b/package/network/utils/wireguard-tools/files/wireguard.sh
index 4bea67e033..5a81bcc1fb 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