Update install_pve.sh

This commit is contained in:
spiritlhl 2023-08-26 23:47:17 +08:00 committed by GitHub
parent 68928147e8
commit 93cc4bbecc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1218,6 +1218,24 @@ if [ "$system_arch" = "x86" ]; then
fi
fi
# 确保DNS有效
if [ ! -s "/etc/resolv.conf" ]; then
cp /etc/resolv.conf /etc/resolv.conf.bak
if [[ "${CN}" == true ]]; then
if [ -z "$ipv6_address" ] || [ -z "$ipv6_prefixlen" ] || [ -z "$ipv6_gateway" ]; then
echo -e "nameserver 8.8.8.8\nnameserver 223.5.5.5\n" >/etc/resolv.conf
else
echo -e "nameserver 8.8.8.8\nnameserver 223.5.5.5\nnameserver 2001:4860:4860::8888\nnameserver 2001:4860:4860::8844" >/etc/resolv.conf
fi
else
if [ -z "$ipv6_address" ] || [ -z "$ipv6_prefixlen" ] || [ -z "$ipv6_gateway" ]; then
echo -e "nameserver 8.8.8.8\nnameserver 8.8.4.4\n" >/etc/resolv.conf
else
echo -e "nameserver 8.8.8.8\nnameserver 8.8.4.4\nnameserver 2001:4860:4860::8888\nnameserver 2001:4860:4860::8844" >/etc/resolv.conf
fi
fi
fi
# 安装必备模块并替换apt源中的无效订阅
cp /etc/apt/sources.list.d/pve-enterprise.list /etc/apt/sources.list.d/pve-enterprise.list.bak
# echo "deb http://download.proxmox.com/debian/pve $(lsb_release -sc) pve-no-subscription" > /etc/apt/sources.list.d/pve-enterprise.list
@ -1248,24 +1266,6 @@ rebuild_cloud_init
# install_package isc-dhcp-server
chattr +i /etc/network/interfaces
# 确保DNS有效
if [ ! -s "/etc/resolv.conf" ]; then
cp /etc/resolv.conf /etc/resolv.conf.bak
if [[ "${CN}" == true ]]; then
if [ -z "$ipv6_address" ] || [ -z "$ipv6_prefixlen" ] || [ -z "$ipv6_gateway" ]; then
echo -e "nameserver 8.8.8.8\nnameserver 223.5.5.5\n" >/etc/resolv.conf
else
echo -e "nameserver 8.8.8.8\nnameserver 223.5.5.5\nnameserver 2001:4860:4860::8888\nnameserver 2001:4860:4860::8844" >/etc/resolv.conf
fi
else
if [ -z "$ipv6_address" ] || [ -z "$ipv6_prefixlen" ] || [ -z "$ipv6_gateway" ]; then
echo -e "nameserver 8.8.8.8\nnameserver 8.8.4.4\n" >/etc/resolv.conf
else
echo -e "nameserver 8.8.8.8\nnameserver 8.8.4.4\nnameserver 2001:4860:4860::8888\nnameserver 2001:4860:4860::8844" >/etc/resolv.conf
fi
fi
fi
# 清除防火墙
install_package ufw
ufw disable