forked from Interanet/server-bootstrap
initial commit
This commit is contained in:
62
scripts/mirrors/os/liara/debian.sh
Normal file
62
scripts/mirrors/os/liara/debian.sh
Normal file
@@ -0,0 +1,62 @@
|
||||
#!/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 "================================="
|
||||
Reference in New Issue
Block a user