From 9fdc122a71c39128cf745c4c25d003e7e8f61179 Mon Sep 17 00:00:00 2001 From: Ilya Apasov Date: Tue, 28 Dec 2021 10:00:05 +0200 Subject: [PATCH] fix: check if selected port is already in use fixes #68 --- wireguard-install.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wireguard-install.sh b/wireguard-install.sh index e8ba13c..b5d23ee 100644 --- a/wireguard-install.sh +++ b/wireguard-install.sh @@ -240,6 +240,10 @@ if [[ ! -e /etc/wireguard/wg0.conf ]]; then echo "$port: invalid port." read -p "Port [51820]: " port done + until [[ -z "$port" || -z $(lsof -i :"$port") ]]; do + echo "Port $port is already in use. Please select another." + read -p "Port [51820]: " port + done [[ -z "$port" ]] && port="51820" echo echo "Enter a name for the first client:"