2023.09.16

This commit is contained in:
spiritlhl 2023-09-16 03:47:56 +00:00
parent de9cf39a8e
commit 6957127783
6 changed files with 81 additions and 21 deletions

View file

@ -1,5 +1,9 @@
# 更新日志
2023.09.15
- 迁移了KVM镜像中Centos8-Stream的所在地址
2023.09.07
- 修复默认的物理接口如果带altname时自动检测部分别名是否可附加如果不可附加自动删除

View file

@ -13,9 +13,10 @@
## 更新
2023.09.15
2023.09.16
- 迁移了KVM镜像中Centos8-Stream的所在地址
- 修复了可能存在的ndp的sysctl设置问题
- 修复可能存在的网关的路由缓存问题,增加自动修复的守护进程
[更新日志](CHANGELOG.md)

View file

@ -0,0 +1,12 @@
[Unit]
Description=Clear interface route cache on next reboot
After=network.target
[Service]
Type=oneshot
ExecStart=/usr/local/bin/clear_interface_route_cache.sh
ExecStartPost=/sbin/reboot
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,17 @@
#!/bin/bash
# from
# https://github.com/spiritLHLS/pve
# 2023.09.16
# 清理路由缓存
sleep 5
systemctl stop networking.service
ip addr flush dev eth0
systemctl start networking.service
# 删除Systemd服务
systemctl disable clear_interface_route_cache.service
rm /etc/systemd/system/clear_interface_route_cache.service
# 删除自身
rm $0

View file

@ -1,7 +1,7 @@
#!/bin/bash
# from
# https://github.com/spiritLHLS/pve
# 2023.08.26
# 2023.09.16
########## 预设部分输出和部分中间变量
@ -106,6 +106,17 @@ check_interface() {
exit 1
}
update_sysctl() {
sysctl_config="$1"
if grep -q "^$sysctl_config" /etc/sysctl.conf; then
if grep -q "^#$sysctl_config" /etc/sysctl.conf; then
sed -i "s/^#$sysctl_config/$sysctl_config/" /etc/sysctl.conf
fi
else
echo "$sysctl_config" >> /etc/sysctl.conf
fi
}
########## 查询信息
if ! command -v lshw >/dev/null 2>&1; then
@ -123,6 +134,9 @@ check_cdn_file
# 检测架构
get_system_arch
# sysctl路径查询
sysctl_path=$(which sysctl)
# 检测IPV6相关的信息
if [ -f /usr/local/bin/pve_check_ipv6 ]; then
ipv6_address=$(cat /usr/local/bin/pve_check_ipv6)
@ -324,6 +338,11 @@ EOF
line_number=6
sed -i "${line_number}s|.*|${new_exec_start}|" "$file_path"
fi
update_sysctl "net.ipv6.conf.all.forwarding=1"
update_sysctl "net.ipv6.conf.all.proxy_ndp=1"
update_sysctl "net.ipv6.conf.default.proxy_ndp=1"
update_sysctl "net.ipv6.conf.vmbr0.proxy_ndp=1"
update_sysctl "net.ipv6.conf.vmbr1.proxy_ndp=1"
fi
fi
chattr +i /etc/network/interfaces
@ -332,15 +351,7 @@ rm -rf /usr/local/bin/iface_auto.txt
# 加载iptables并设置回源且允许NAT端口转发
apt-get install -y iptables iptables-persistent
iptables -t nat -A POSTROUTING -j MASQUERADE
sysctl net.ipv4.ip_forward=1
sysctl_path=$(which sysctl)
if grep -q "^net.ipv4.ip_forward=1" /etc/sysctl.conf; then
if grep -q "^#net.ipv4.ip_forward=1" /etc/sysctl.conf; then
sed -i 's/^#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/' /etc/sysctl.conf
fi
else
echo "net.ipv4.ip_forward=1" >>/etc/sysctl.conf
fi
update_sysctl "net.ipv4.ip_forward=1"
${sysctl_path} -p
# 重启配置

View file

@ -1,7 +1,7 @@
#!/bin/bash
# from
# https://github.com/spiritLHLS/pve
# 2023.09.07
# 2023.09.16
########## 预设部分输出和部分中间变量
@ -668,6 +668,14 @@ check_interface() {
# 更改网络优先级为IPV4优先
sed -i 's/.*precedence ::ffff:0:0\/96.*/precedence ::ffff:0:0\/96 100/g' /etc/gai.conf
# ChinaIP检测
check_china
# cdn检测
cdn_urls=("https://cdn.spiritlhl.workers.dev/" "https://cdn3.spiritlhl.net/" "https://cdn1.spiritlhl.net/" "https://ghproxy.com/" "https://cdn2.spiritlhl.net/")
check_cdn_file
systemctl restart networking
if [ $? -ne 0 ]; then
# altname=$(ip addr show eth0 | grep altname | awk '{print $NF}')
@ -679,14 +687,21 @@ if [ $? -ne 0 ]; then
chattr +i /etc/network/interfaces
fi
fi
systemctl restart networking
# ChinaIP检测
check_china
# cdn检测
cdn_urls=("https://cdn.spiritlhl.workers.dev/" "https://cdn3.spiritlhl.net/" "https://cdn1.spiritlhl.net/" "https://ghproxy.com/" "https://cdn2.spiritlhl.net/")
check_cdn_file
systemctl restart networking
if [ $? -ne 0 ]; then
if [ ! -f "/usr/local/bin/clear_interface_route_cache.sh" ]; then
wget ${cdn_success_url}https://raw.githubusercontent.com/spiritLHLS/pve/main/extra_scripts/clear_interface_route_cache.sh -O /usr/local/bin/clear_interface_route_cache.sh
wget ${cdn_success_url}https://raw.githubusercontent.com/spiritLHLS/pve/main/extra_scripts/clear_interface_route_cache.service -O /etc/systemd/system/clear_interface_route_cache.service
chmod +x /usr/local/bin/clear_interface_route_cache.sh
chmod +x /etc/systemd/system/clear_interface_route_cache.service
systemctl daemon-reload
systemctl enable clear_interface_route_cache.service
systemctl start clear_interface_route_cache.service
_green "An anomaly was detected with the routing conflict, perform a reboot to reboot the machine to start the repaired daemon and try the installation again."
_green "检测到路由冲突存在异常,请执行 reboot 重启机器以启动修复的守护进程,再次尝试安装"
exit 1
fi
fi
# 前置环境安装与配置
if [ "$(id -u)" != "0" ]; then