Update wireguard-install.sh

Changed ipv4 and ipv6 dedection methot (To get public ip)
This commit is contained in:
KAAN DIKEC 2023-05-17 12:20:11 +03:00 committed by GitHub
parent 39caf2fcf6
commit 1dabe873fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -110,10 +110,10 @@ function installQuestions() {
echo ""
# Detect public IPv4 or IPv6 address and pre-fill for the user
SERVER_PUB_IP=$(ip -4 addr | sed -ne 's|^.* inet \([^/]*\)/.* scope global.*$|\1|p' | awk '{print $1}' | head -1)
SERVER_PUB_IP=$(curl -4 https://ifconfig.co)
if [[ -z ${SERVER_PUB_IP} ]]; then
# Detect public IPv6 address
SERVER_PUB_IP=$(ip -6 addr | sed -ne 's|^.* inet6 \([^/]*\)/.* scope global.*$|\1|p' | head -1)
SERVER_PUB_IP=$(curl -6 https://ifconfig.co)
fi
read -rp "IPv4 or IPv6 public address: " -e -i "${SERVER_PUB_IP}" SERVER_PUB_IP