#!/bin/bash # 检测系统类型 if [ -f /etc/os-release ]; then source /etc/os-release distro=$ID else echo "无法识别系统类型" exit 1 fi # 根据发行版执行更新 case $distro in alpine) echo "更新 Alpine 系统" sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories apk update && apk upgrade ;; ubuntu) echo "更新 Ubuntu 系统" sed -i 's@//.*archive.ubuntu.com@//mirrors.ustc.edu.cn@g' /etc/apt/sources.list apt-get update && apt-get upgrade -y ;; debian) echo "更新 Debian 系统" sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list apt-get update && apt-get upgrade -y ;; arch) echo "更新 Arch 系统" pacman -Syu --noconfirm ;; *) echo "不支持的发行版: $distro" exit 1 ;; esac