mirror of
https://github.com/thelittlerocket/pve.git
synced 2024-11-15 11:38:00 +08:00
Update pve6_to_pve7.sh
This commit is contained in:
parent
2025cdb00c
commit
1b12594706
1 changed files with 47 additions and 19 deletions
|
@ -8,21 +8,14 @@ _green() { echo -e "\033[32m\033[01m$@\033[0m"; }
|
||||||
_yellow() { echo -e "\033[33m\033[01m$@\033[0m"; }
|
_yellow() { echo -e "\033[33m\033[01m$@\033[0m"; }
|
||||||
_blue() { echo -e "\033[36m\033[01m$@\033[0m"; }
|
_blue() { echo -e "\033[36m\033[01m$@\033[0m"; }
|
||||||
|
|
||||||
# 删除企业源
|
# 检查是否为 root 用户
|
||||||
rm -rf /etc/apt/sources.list.d/pve-enterprise.list
|
if [ "$(id -u)" != "0" ]; then
|
||||||
|
echo "请使用 root 用户执行脚本"
|
||||||
# 检测是否可升级
|
exit 1
|
||||||
output=$(pve6to7)
|
|
||||||
if echo "$output" | grep -q "FAILURES: 0" > /dev/null 2>&1; then
|
|
||||||
_green "支持升级PVE7"
|
|
||||||
else
|
|
||||||
echo "$output"
|
|
||||||
_red "不支持升级PVE7"
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 升级PVE7
|
# 删除企业源
|
||||||
apt update && apt dist-upgrade -y
|
rm -rf /etc/apt/sources.list.d/pve-enterprise.list
|
||||||
|
|
||||||
# 卸载无关内核
|
# 卸载无关内核
|
||||||
current_kernel=$(uname -r)
|
current_kernel=$(uname -r)
|
||||||
|
@ -31,17 +24,52 @@ installed_kernels=$(dpkg -l | grep -E 'linux-(image|headers)-[0-9]+' | grep -v "
|
||||||
if [ -z "$installed_kernels" ]; then
|
if [ -z "$installed_kernels" ]; then
|
||||||
_blue "无闲置的内核"
|
_blue "无闲置的内核"
|
||||||
else
|
else
|
||||||
_yellow "Uninstalling unused kernels..."
|
_yellow "卸载闲置内核..."
|
||||||
for kernel in $installed_kernels; do
|
for kernel in $installed_kernels; do
|
||||||
_yellow "Uninstalling kernel: $kernel"
|
_yellow "卸载内核: $kernel"
|
||||||
dpkg --purge --force-remove-essential $kernel
|
dpkg --purge --force-remove-essential $kernel
|
||||||
apt-get remove -y $kernel > /dev/null 2>&1
|
apt-get remove -y $kernel > /dev/null 2>&1
|
||||||
done
|
done
|
||||||
_green "闲置内核已卸载完毕"
|
_green "闲置内核已卸载完毕"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 升级内核
|
# 检查 PVE 版本是否为最新版本
|
||||||
update-grub
|
if ! [ "$(pveversion -v)" = "$(pveversion -r)" ]; then
|
||||||
|
_yellow "当前 PVE 版本不是最新版本,尝试升级到最新版本"
|
||||||
|
apt-get update && apt-get dist-upgrade -y
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
_red "升级 PVE 失败,请检查网络或源配置"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
_green "PVE 升级到最新版本成功"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# 打印信息
|
# 检查 PVE 是否可以升级
|
||||||
_green "请执行reboot启用新内核"
|
if ! pve6to7 --check | grep -q "FAILURES: 0"; then
|
||||||
|
_red "检测到 PVE 升级存在问题,请先解决问题后再执行升级"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 检查是否为 Debian 11
|
||||||
|
if ! [ "$(lsb_release -cs)" = "bullseye" ]; then
|
||||||
|
_yellow "当前不是 Debian 11,尝试升级到 Debian 11"
|
||||||
|
sed -i 's/buster/bullseye/g' /etc/apt/sources.list
|
||||||
|
apt-get update && apt-get dist-upgrade -y
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
_red "升级 Debian 11 失败,请检查网络或源配置"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
_green "Debian 升级到 11 成功"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 升级 PVE
|
||||||
|
_yellow "升级 PVE ..."
|
||||||
|
apt-get update && apt-get dist-upgrade -y
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
_red "升级 PVE 失败,请检查网络或源配置"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
_green "PVE 升级成功,请重启系统以应用更改"
|
||||||
|
fi
|
||||||
|
|
Loading…
Reference in a new issue