#!/bin/bash
# APT 镜像源配置 - 清华大学
# 系统版本: Debian 10 (Buster)
# 由 镜像加速站 自动生成

echo "正在配置 APT 镜像源..."

# 备份原有源列表
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup.$(date +%Y%m%d) 2>/dev/null
echo "✓ 原有配置已备份"

# 写入新的镜像源配置
sudo tee /etc/apt/sources.list > /dev/null << 'EOF'
deb http://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
deb http://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
deb http://mirrors.tuna.tsinghua.edu.cn/debian/ buster/updates main contrib non-free
EOF

echo "✓ 镜像源配置已更新"

# 更新软件包列表
echo "正在更新软件包列表..."
sudo apt update

echo "\n✅ APT 镜像源已成功配置为 清华大学"
echo "如需恢复原有配置，执行: sudo mv /etc/apt/sources.list.backup.* /etc/apt/sources.list && sudo apt update"