From 80dcb446ff77812a58a14cecfacf0a279be7cd36 Mon Sep 17 00:00:00 2001 From: binhex Date: Tue, 29 Sep 2020 16:02:13 +0100 Subject: [PATCH] pick up port from port line if defined, relax digit check for port to 2-5 --- build/root/install.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/build/root/install.sh b/build/root/install.sh index 0ffac8a..0901e80 100644 --- a/build/root/install.sh +++ b/build/root/install.sh @@ -202,11 +202,13 @@ if [[ $VPN_ENABLED == "yes" ]]; then continue fi - vpn_remote_port_cut=$(echo "${vpn_remote_line_item}" | cut -d " " -f2 | grep -P -o '^[\d]{4,5}$' || true) - + vpn_remote_port_cut=$(cat "${VPN_CONFIG}" | grep -P -o '(?<=^port\s).*' || true) if [[ -z "${vpn_remote_port_cut}" ]]; then - echo "[warn] VPN configuration file ${VPN_CONFIG} remote port is missing or malformed, assuming port '1194'" | ts '%Y-%m-%d %H:%M:%.S' - vpn_remote_port_cut="1194" + vpn_remote_port_cut=$(echo "${vpn_remote_line_item}" | cut -d " " -f2 | grep -P -o '^[\d]{2,5}$' || true) + if [[ -z "${vpn_remote_port_cut}" ]]; then + echo "[warn] VPN configuration file ${VPN_CONFIG} remote port is missing or malformed, assuming port '1194'" | ts '%Y-%m-%d %H:%M:%.S' + vpn_remote_port_cut="1194" + fi fi vpn_remote_protocol_cut=$(cat "${VPN_CONFIG}" | grep -P -o '(?<=^proto\s).*' || true)