#!/usr/bin/env bash # # Alpine Linux 系统维护脚本 # 功能:更新软件包、清理缓存、检查服务状态 # # 使用方法: # URL="https://git.1-h.cc/Scripts/Linux/raw/branch/main/alpine/upgrade.sh"; wget -q -O - "$URL" | bash cat < /etc/apk/repositories http://dl-cdn.alpinelinux.org/alpine/latest-stable/main http://dl-cdn.alpinelinux.org/alpine/latest-stable/community EOF # 更新软件包索引 apk update # 升级所有软件包 apk upgrade --available # 清理缓存 apk cache clean # 更彻底地清理 rm -rf /var/cache/apk/* # 检查是否有失败的服务(OpenRC等效命令) rc-status --crashed || echo "没有检测到失败的服务" # 重启系统 # reboot # 判断是否需要重启 # https://github.com/copilot/share/42124018-0980-80c5-8001-a60ae0644914 # https://www.cnblogs.com/gaoyuechen/p/11944150.html