From 3b0cce8c4fb56341545384f5fa6533a74b9173ff Mon Sep 17 00:00:00 2001 From: binhex Date: Thu, 2 Jan 2025 10:02:30 +0000 Subject: [PATCH] fix regex to parse endpoint for wireguard --- build/root/install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/root/install.sh b/build/root/install.sh index 84ca973..4043af3 100755 --- a/build/root/install.sh +++ b/build/root/install.sh @@ -169,7 +169,7 @@ if [[ "${VPN_ENABLED}" == "yes" ]]; then /usr/local/bin/dos2unix.sh "${VPN_CONFIG}" # get endpoint line from wireguard config file - export VPN_REMOTE_SERVER=$(cat "${VPN_CONFIG}" | grep -P -o '(?<=^Endpoint\s=\s)[^:]+' || true) + export VPN_REMOTE_SERVER=$(cat "${VPN_CONFIG}" | grep -P -o '(?<=^Endpoint(\s+)?=(\s+)?)[^:]+' || true) if [[ -z "${VPN_REMOTE_SERVER}" ]]; then echo "[crit] VPN configuration file ${VPN_CONFIG} does not contain 'Endpoint' line, showing contents of file before exit..." | ts '%Y-%m-%d %H:%M:%.S' cat "${VPN_CONFIG}" && exit 1 @@ -179,7 +179,7 @@ if [[ "${VPN_ENABLED}" == "yes" ]]; then if [[ "${VPN_PROV}" == "pia" ]]; then - export VPN_REMOTE_PORT=$(cat "${VPN_CONFIG}" | grep -P -o '(?<=^Endpoint\s=\s).*' | grep -P -o '[\d]+$' || true) + export VPN_REMOTE_PORT=$(cat "${VPN_CONFIG}" | grep -P -o '(?<=^Endpoint(\s+)?=(\s+)?).*' | grep -P -o '[\d]+$' || true) if [[ -z "${VPN_REMOTE_PORT}" ]]; then echo "[warn] VPN configuration file ${VPN_CONFIG} does not contain port on 'Endpoint' line, defaulting to '1337'" | ts '%Y-%m-%d %H:%M:%.S' export VPN_REMOTE_PORT="1337" @@ -187,7 +187,7 @@ if [[ "${VPN_ENABLED}" == "yes" ]]; then else - export VPN_REMOTE_PORT=$(cat "${VPN_CONFIG}" | grep -P -o '(?<=^Endpoint\s=\s).*' | grep -P -o '[\d]+$' || true) + export VPN_REMOTE_PORT=$(cat "${VPN_CONFIG}" | grep -P -o '(?<=^Endpoint(\s+)?=(\s+)?).*' | grep -P -o '[\d]+$' || true) if [[ -z "${VPN_REMOTE_PORT}" ]]; then echo "[crit] VPN configuration file ${VPN_CONFIG} does not contain port on 'Endpoint' line, showing contents of file before exit..." | ts '%Y-%m-%d %H:%M:%.S' cat "${VPN_CONFIG}" && exit 1