#!/usr/bin/env bash # # ... # # 使用方法: # URL="https://git.1-h.cc/Scripts/Linux/raw/branch/main/debian/upgrade.sh"; curl -fsSL "$URL" | bash # 设置非交互式环境变量 export DEBIAN_FRONTEND=noninteractive apt -qq update # 安装自动更新 apt install -y unattended-upgrades # 启用自动更新 dpkg-reconfigure -plow unattended-upgrades # 配置自动更新并在凌晨2点自动重启 cat < /dev/null; then if needrestart -b | grep -q "NEEDRESTART-KSTA: 1"; then NEEDS_REBOOT=1 REASONS="${REASONS}\nneedrestart 工具表明需要内核重启" fi fi # 输出结果 if [ $NEEDS_REBOOT -eq 1 ]; then echo -e "系统需要重启\n原因:\n${REASONS}" exit 1 else echo "系统不需要重启" exit 0 fi