优化 upgrade.sh 脚本,调整配置输出格式并简化命令执行流程

This commit is contained in:
mini2024
2025-03-22 16:51:16 +08:00
parent 5fb92ad712
commit 56b9b917cd

25
debian/upgrade.sh vendored
View File

@ -13,14 +13,14 @@ export NEEDRESTART_MODE=a
apt install -y unattended-upgrades apt install -y unattended-upgrades
# 配置自动更新并在凌晨2点自动重启 # 配置自动更新并在凌晨2点自动重启
cat << EOF | tee /etc/apt/apt.conf.d/50unattended-upgrades cat <<EOF | tee /etc/apt/apt.conf.d/50unattended-upgrades
Unattended-Upgrade::Automatic-Reboot "true"; Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-WithUsers "true"; Unattended-Upgrade::Automatic-Reboot-WithUsers "true";
Unattended-Upgrade::Automatic-Reboot-Time "02:00"; Unattended-Upgrade::Automatic-Reboot-Time "02:00";
EOF EOF
# 配置 needrestart 为非交互式 # 配置 needrestart 为非交互式
cat << EOF | tee /etc/needrestart/conf.d/50noninteractive.conf cat <<EOF | tee /etc/needrestart/conf.d/50noninteractive.conf
\$nrconf{restart} = 'a'; \$nrconf{restart} = 'a';
\$nrconf{kernelhints} = -1; \$nrconf{kernelhints} = -1;
EOF EOF
@ -28,16 +28,15 @@ EOF
# 启用自动更新 # 启用自动更新
dpkg-reconfigure -plow unattended-upgrades dpkg-reconfigure -plow unattended-upgrades
apt -qq update && apt -qq update
apt -qq upgrade -y && apt -qq upgrade -y
apt -qq full-upgrade -y && apt -qq full-upgrade -y
apt -qq autoremove && apt -qq autoremove
apt -qq autoclean && apt -qq autoclean
apt clean && apt clean
systemctl --failed && systemctl --failed
apt -qq install needrestart -y && apt -qq install needrestart -y
needrestart -r a needrestart -r a
################################################################################ ################################################################################
# needrestart --help # needrestart --help
@ -85,4 +84,4 @@ apt -qq update &&
# -w check for obsolete CPU microcode # -w check for obsolete CPU microcode
# --help show this help # --help show this help
# --version show version information # --version show version information