#!/bin/bash

# Script to change Debian 12 repositories to mirror.sg.gs
# Tested on Debian 12 (Bookworm)

MIRROR="http://mirror.sg.gs/debian"
SECURITY="http://mirror.sg.gs/debian-security"
RELEASE="bookworm"

# Backup current sources.list
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

# Replace sources.list with new mirror
sudo tee /etc/apt/sources.list > /dev/null <<EOF
deb $MIRROR $RELEASE main contrib non-free non-free-firmware
deb $MIRROR $RELEASE-updates main contrib non-free non-free-firmware
deb $SECURITY $RELEASE-security main contrib non-free non-free-firmware
EOF
rm -rf /etc/apt/sources.list.d/debian*
rm -rf /etc/apt/mirrors/*

# Update APT cache
sudo apt update

echo "✅ Debian 12 repositories have been updated to mirror.sg.gs"
