From 0d1cc0efa7ef52b50898b6ea4e8b93b5d2d97b76 Mon Sep 17 00:00:00 2001 From: spiritlhl <103393591+spiritLHLS@users.noreply.github.com> Date: Sat, 26 Aug 2023 14:57:56 +0000 Subject: [PATCH] 2023.08.26 --- README.md | 1 + scripts/check_kernal.sh | 18 +++++++++++++++++- scripts/install_pve.sh | 22 +++++++++++++++++----- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 8d3fc18..e1f2c5a 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ 2023.08.26 - 修复开设NAT网关时,vmbr0如果不存在就去补全时的漏洞,尝试支持第一第二步安装PVE不使用本仓库脚本的PVE创建NAT网关 +- 给IPV6的识别增加ping检测,如果ping不通当作IPV6不通,避免有的商家设置的IPV6本身就有问题根本用不了还配置,导致安装出问题 [更新日志](CHANGELOG.md) diff --git a/scripts/check_kernal.sh b/scripts/check_kernal.sh index ed97efc..de88801 100644 --- a/scripts/check_kernal.sh +++ b/scripts/check_kernal.sh @@ -1,7 +1,7 @@ #!/bin/bash # from # https://github.com/spiritLHLS/pve -# 2023.08.18 +# 2023.08.26 # 用颜色输出信息 _red() { echo -e "\033[31m\033[01m$@\033[0m"; } @@ -157,6 +157,22 @@ if command -v lshw >/dev/null 2>&1; then if [ -z "$ipv6_address" ] || [ -z "$ipv6_prefixlen" ] || [ -z "$ipv6_gateway" ]; then : else + while true; do + if ping -c 1 -6 -W 3 $ipv6_address >/dev/null 2>&1; then + echo "IPv6 address is reachable." + else + echo "IPv6 address is not reachable. Setting to empty." + echo "" > /usr/local/bin/pve_check_ipv6 + fi + if ping -c 1 -6 -W 3 $ipv6_gateway >/dev/null 2>&1; then + echo "IPv6 gateway is reachable." + else + echo "IPv6 gateway is not reachable. Setting to empty." + echo "" > /usr/local/bin/pve_ipv6_gateway + fi + done + ipv6_address=$(cat /usr/local/bin/pve_check_ipv6) + ipv6_gateway=$(cat /usr/local/bin/pve_ipv6_gateway) _green "The following IPV6 information is detected for this machine:" _green "检测到本机的IPV6信息如下:" _green "ipv6_address: ${ipv6_address}" diff --git a/scripts/install_pve.sh b/scripts/install_pve.sh index 4f1c3d4..9e25daf 100644 --- a/scripts/install_pve.sh +++ b/scripts/install_pve.sh @@ -1,7 +1,7 @@ #!/bin/bash # from # https://github.com/spiritLHLS/pve -# 2023.08.23 +# 2023.08.26 ########## 预设部分输出和部分中间变量 @@ -802,15 +802,27 @@ if [ ! -f /usr/local/bin/pve_ipv6_prefixlen ] || [ ! -s /usr/local/bin/pve_ipv6_ fi if [ ! -f /usr/local/bin/pve_ipv6_gateway ] || [ ! -s /usr/local/bin/pve_ipv6_gateway ] || [ "$(sed -e '/^[[:space:]]*$/d' /usr/local/bin/pve_ipv6_gateway)" = "" ]; then ipv6_gateway=$(ip -6 route show | awk '/default via/{print $3}' | head -n1) - # ip -6 route show | awk '/default via/{print $3}' | head -n1 - # if is_private_ipv6 "$ipv6_gateway"; then # 由于是内网IPV6地址,不设置V6地址 - # ipv6_gateway="" echo "$ipv6_gateway" >/usr/local/bin/pve_ipv6_gateway - # fi fi ipv6_address=$(cat /usr/local/bin/pve_check_ipv6) ipv6_prefixlen=$(cat /usr/local/bin/pve_ipv6_prefixlen) ipv6_gateway=$(cat /usr/local/bin/pve_ipv6_gateway) +while true; do + if ping -c 1 -6 -W 3 $ipv6_address >/dev/null 2>&1; then + echo "IPv6 address is reachable." + else + echo "IPv6 address is not reachable. Setting to empty." + echo "" > /usr/local/bin/pve_check_ipv6 + fi + if ping -c 1 -6 -W 3 $ipv6_gateway >/dev/null 2>&1; then + echo "IPv6 gateway is reachable." + else + echo "IPv6 gateway is not reachable. Setting to empty." + echo "" > /usr/local/bin/pve_ipv6_gateway + fi +done +ipv6_address=$(cat /usr/local/bin/pve_check_ipv6) +ipv6_gateway=$(cat /usr/local/bin/pve_ipv6_gateway) # 检查50-cloud-init是否存在特定配置 if [ -f "/etc/network/interfaces.d/50-cloud-init" ]; then