diff --git a/CHANGELOG.md b/CHANGELOG.md index 7508021..a01657f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # 更新日志 +2023.08.29 + +- 判断IPV6是否未dhcp类型,如果是则检测是否已分配IPV6地址,如果未分配则删除对应配置避免冲突 + 2023.08.27 - 将删除物理网关的操作移动到创建vmbr0之前,而不是原来的创建vmbr1之前 diff --git a/README.md b/README.md index d05d210..91ebfb8 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,12 @@ ## 更新 -2023.08.29 +2023.09.01 -- 判断IPV6是否未dhcp类型,如果是则检测是否已分配IPV6地址,如果未分配则删除对应配置避免冲突 +- 前置的环境检测增加是否是debian系统的检测,优化部分检测逻辑 +- 主体安装的脚本前移二次环境检测,避免已修改了部分内容还去检测是否能安装,此时再判断已经迟了 +- 优化IPV4地址检测,增加对 RFC 6598 地址的判断 +- 前置的环境检测优化内存的检测,如果Swap不为0则包含Swap [更新日志](CHANGELOG.md) diff --git a/scripts/check_kernal.sh b/scripts/check_kernal.sh index 0dd4ae6..52871df 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.26 +# 2023.09.01 # 用颜色输出信息 _red() { echo -e "\033[31m\033[01m$@\033[0m"; } @@ -21,6 +21,15 @@ fi if [ ! -d /usr/local/bin ]; then mkdir -p /usr/local/bin fi +command -v apt-get &>/dev/null +apt_get_status=$? +command -v apt &>/dev/null +apt_status=$? +if [ $apt_get_status -ne 0 ] || [ $apt_status -ne 0 ]; then + _yellow "The host environment does not have the apt package manager command, please check the system" + _yellow "宿主机的环境无apt包管理器命令,请检查系统" +fi +apt-get install lsb-release -y check_config() { _green "The machine configuration should meet the minimum requirements of at least 2 cores 2G RAM 20G hard drive" @@ -48,11 +57,15 @@ check_config() { # 检查内存大小 total_mem=$(free -m | awk '/^Mem:/{print $2}') + swap_info=$(free -m | awk '/^Swap:/{print $2}') + if [ "$swap_info" -ne 0 ]; then + total_mem=$((total_mem + swap_info)) + fi if [ "$total_mem" -lt 2048 ]; then _red "The machine configuration does not meet the minimum requirements: at least 2G RAM" - _red "The local memory configuration cannot install PVE (SWAP is not calculated, if the virtual memory of SWAP plus the actual memory of the local machine is greater than 2G please ignore this prompt)" + _red "The local memory configuration cannot install PVE" _red "本机配置不满足最低要求:至少2G内存" - _red "本机内存配置无法安装PVE (未计算SWAP,如若SWAP的虚拟内存加上本机实际内存大于2G请忽略本提示)" + _red "本机内存配置无法安装PVE" fi } @@ -116,6 +129,19 @@ check_ipv6() { echo $IPV6 >/usr/local/bin/pve_check_ipv6 } +# 检测系统是否支持 +version=$(lsb_release -cs) +case $version in +stretch | buster | bullseye | bookworm) + _green "The recognized system is $version" + _green "识别到的系统为 $version" + ;; +*) + _yellow "Error: Recognized as an unsupported version of Debian, but you can force an installation attempt or use the custom partitioning method to install the PVE" + _yellow "Error: 识别为不支持的Debian版本,但你可以强行安装尝试或使用自定义分区的方法安装PVE" + ;; +esac + # 检测IPV6网络配置 if ! command -v lshw >/dev/null 2>&1; then apt-get install lshw -y @@ -164,13 +190,13 @@ if command -v lshw >/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 + 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 + echo "" >/usr/local/bin/pve_ipv6_gateway fi ipv6_address=$(cat /usr/local/bin/pve_check_ipv6) ipv6_gateway=$(cat /usr/local/bin/pve_ipv6_gateway) diff --git a/scripts/install_pve.sh b/scripts/install_pve.sh index a2f5481..8753119 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.29 +# 2023.09.01 ########## 预设部分输出和部分中间变量 @@ -22,9 +22,9 @@ else echo "Locale set to $utf8_locale" fi temp_file_apt_fix="/tmp/apt_fix.txt" -command -v pct &> /dev/null +command -v pct &>/dev/null pct_status=$? -command -v qm &> /dev/null +command -v qm &>/dev/null qm_status=$? if [ $pct_status -eq 0 ] && [ $qm_status -eq 0 ]; then _green "Proxmox VE is already installed and does not need to be reinstalled." @@ -489,12 +489,13 @@ is_private_ipv4() { fi IFS='.' read -r -a ip_parts <<<"$ip_address" # 检查IP地址是否符合内网IP地址的范围 - # 去除 回环,REC 1918,多播 地址 + # 去除 回环,RFC 1918,多播,RFC 6598 地址 if [[ ${ip_parts[0]} -eq 10 ]] || [[ ${ip_parts[0]} -eq 172 && ${ip_parts[1]} -ge 16 && ${ip_parts[1]} -le 31 ]] || [[ ${ip_parts[0]} -eq 192 && ${ip_parts[1]} -eq 168 ]] || [[ ${ip_parts[0]} -eq 127 ]] || [[ ${ip_parts[0]} -eq 0 ]] || + [[ ${ip_parts[0]} -eq 100 && ${ip_parts[1]} -ge 64 && ${ip_parts[1]} -le 127 ]] || [[ ${ip_parts[0]} -ge 224 ]]; then return 0 # 是内网IP地址 else @@ -751,9 +752,29 @@ install_package ipcalc install_package dmidecode install_package dnsutils install_package ethtool +apt-get install gnupg -y +apt-get install iputils-ping -y +apt-get install iproute2 -y +apt-get install lsb-release -y ethtool_path=$(which ethtool) check_haveged +# 预检查 +if [ ! -f /etc/debian_version ] || [ $(grep MemTotal /proc/meminfo | awk '{print $2}') -lt 2000000 ] || [ $(grep -c ^processor /proc/cpuinfo) -lt 2 ] || [ $( + ping -c 3 google.com >/dev/null 2>&1 + echo $? +) -ne 0 ]; then + _red "Error: This system does not meet the minimum requirements for Proxmox VE installation." + _yellow "Do you want to continue the installation? (Enter to not continue the installation by default) (y/[n])" + reading "是否要继续安装?(回车则默认不继续安装) (y/[n]) " confirm + echo "" + if [ "$confirm" != "y" ]; then + exit 1 + fi +else + _green "The system meets the minimum requirements for Proxmox VE installation." +fi + # 检测系统信息 _yellow "Detecting system information, will probably stay on the page for up to 1~2 minutes" _yellow "正在检测系统信息,大概会停留在该页面最多1~2分钟" @@ -814,14 +835,14 @@ 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 + 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 + echo "" >/usr/local/bin/pve_ipv6_gateway fi ipv6_address=$(cat /usr/local/bin/pve_check_ipv6) ipv6_gateway=$(cat /usr/local/bin/pve_ipv6_gateway) @@ -973,25 +994,7 @@ if [ "${hostname}" != "pve" ]; then chattr +i /etc/hosts fi -# 再次预检查 -apt-get install gnupg -y -if [ ! -f /etc/debian_version ] || [ $(grep MemTotal /proc/meminfo | awk '{print $2}') -lt 2000000 ] || [ $(grep -c ^processor /proc/cpuinfo) -lt 2 ] || [ $( - ping -c 3 google.com >/dev/null 2>&1 - echo $? -) -ne 0 ]; then - _red "Error: This system does not meet the minimum requirements for Proxmox VE installation." - _yellow "Do you want to continue the installation? (Enter to not continue the installation by default) (y/[n])" - reading "是否要继续安装?(回车则默认不继续安装) (y/[n]) " confirm - echo "" - if [ "$confirm" != "y" ]; then - exit 1 - fi -else - _green "The system meets the minimum requirements for Proxmox VE installation." -fi - # 新增pve源 -apt-get install lsb-release -y version=$(lsb_release -cs) # 如果是CN的IP则修改apt源先 if [[ "${CN}" == true ]]; then