#!/bin/bash
# 1. 备份原始 Debian 源
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

# 2. 替换为清华 Debian 11 (bullseye) 源
cat <<EOF | sudo tee /etc/apt/sources.list
deb https://mirrors.tuna.tsinghua.edu.cn/debian bullseye main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian bullseye-updates main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free
EOF

# 3. 添加 Proxmox 官方免费源（no-subscription）
echo "deb http://download.proxmox.com/debian/pve bullseye pve-no-subscription" | sudo tee /etc/apt/sources.list.d/pve-no-subscription.list

# 4. 禁用企业订阅源（可选）
sudo sed -i 's/^deb/# deb/' /etc/apt/sources.list.d/pve-enterprise.list 2>/dev/null || true

# 5. 更新软件包索引
sudo apt update
