63 lines
1.6 KiB
Bash
63 lines
1.6 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
echo "================================="
|
|
echo " Liara Debian Mirror Setup"
|
|
echo "================================="
|
|
|
|
# Check OS
|
|
if [[ ! -f /etc/os-release ]]; then
|
|
echo "Cannot detect OS. /etc/os-release not found."
|
|
exit 1
|
|
fi
|
|
|
|
source /etc/os-release
|
|
|
|
if [[ "$ID" != "debian" ]]; then
|
|
echo "This script is only for Debian."
|
|
echo "Detected OS: $ID"
|
|
exit 1
|
|
fi
|
|
|
|
CODENAME="$VERSION_CODENAME"
|
|
|
|
if [[ -z "$CODENAME" ]]; then
|
|
echo "Could not detect Debian codename."
|
|
exit 1
|
|
fi
|
|
|
|
echo "Detected Debian codename: $CODENAME"
|
|
|
|
echo
|
|
echo "[1/4] Backing up current APT sources..."
|
|
cp /etc/apt/sources.list /etc/apt/sources.list.bak
|
|
|
|
echo
|
|
echo "[2/4] Writing Liara mirrors to /etc/apt/sources.list..."
|
|
|
|
cat > /etc/apt/sources.list <<EOF
|
|
deb https://linux-mirror.liara.ir/repository/debian $CODENAME main non-free-firmware
|
|
deb-src https://linux-mirror.liara.ir/repository/debian $CODENAME main non-free-firmware
|
|
|
|
deb https://linux-mirror.liara.ir/repository/debian-security ${CODENAME}-security main non-free-firmware
|
|
deb-src https://linux-mirror.liara.ir/repository/debian-security ${CODENAME}-security main non-free-firmware
|
|
|
|
deb https://linux-mirror.liara.ir/repository/debian ${CODENAME}-updates main non-free-firmware
|
|
deb-src https://linux-mirror.liara.ir/repository/debian ${CODENAME}-updates main non-free-firmware
|
|
EOF
|
|
|
|
echo
|
|
echo "[3/4] Mirror configuration written."
|
|
|
|
echo
|
|
echo "[4/4] Updating package lists..."
|
|
apt update
|
|
|
|
echo
|
|
echo "================================="
|
|
echo "Liara mirror setup completed"
|
|
echo "Backup saved at:"
|
|
echo "/etc/apt/sources.list.bak"
|
|
echo "================================="
|