新增系统维护脚本,完善系统初始化和升级工具集
- 为 1.sh 添加系统配置、Docker 安装、SSH 密钥和别名配置功能 - 新增 alpine/upgrade.sh 用于 Alpine Linux 系统更新和维护 - 新增 debian/upgrade.sh 用于 Debian 系统更新和维护
This commit is contained in:
33
alpine/upgrade.sh
Normal file
33
alpine/upgrade.sh
Normal file
@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Alpine Linux 系统维护脚本
|
||||
# 功能:更新软件包、清理缓存、检查服务状态
|
||||
#
|
||||
# 使用方法:
|
||||
# URL="https://git.1-h.cc/Scripts/Linux/raw/branch/main/alpine.sh"; curl -fsSL "$URL" | bash || wget -q -O - "$URL" | bash
|
||||
|
||||
cat <<EOF > /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
|
Reference in New Issue
Block a user