From 01b1534238e4f503f29e2ef7ea1f6e4b45257962 Mon Sep 17 00:00:00 2001 From: spiritlhl <103393591+spiritLHLS@users.noreply.github.com> Date: Sun, 28 May 2023 17:34:36 +0800 Subject: [PATCH] Update install_pve.sh --- scripts/install_pve.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/scripts/install_pve.sh b/scripts/install_pve.sh index 85e96b0..e0de0a5 100644 --- a/scripts/install_pve.sh +++ b/scripts/install_pve.sh @@ -109,8 +109,23 @@ fi } rebuild_cloud_init +# 检测IPV4 +check_ipv4(){ + API_NET=("ip.sb" "ipget.net" "ip.ping0.cc" "https://ip4.seeip.org" "https://api.my-ip.io/ip" "https://ipv4.icanhazip.com" "api.ipify.org") + for p in "${API_NET[@]}"; do + response=$(curl -s4m6 "$p") + sleep 1 + if [ $? -eq 0 ] && ! echo "$response" | grep -q "error"; then + IP_API="$p" + ip=$(curl -s4m6 "$IP_API") + break + fi + done + export ip +} +check_ipv4 + # /etc/hosts文件修改 -ip=$(curl -s ipv4.ip.sb) hostname=$(hostname) if [ "${hostname}" != "pve" ]; then chattr -i /etc/hosts