#!/usr/bin/env bash set -e echo "=================================" echo " Liara Ubuntu Mirror Setup" echo "=================================" if [[ ! -f /etc/os-release ]]; then echo "Cannot detect operating system." exit 1 fi source /etc/os-release if [[ "$ID" != "ubuntu" ]]; then echo "This script only supports Ubuntu." echo "Detected OS: $ID" exit 1 fi CODENAME="$VERSION_CODENAME" if [[ -z "$CODENAME" ]]; then echo "Could not detect Ubuntu codename." exit 1 fi echo "Detected Ubuntu version codename: $CODENAME" SOURCE_FILE="/etc/apt/sources.list.d/ubuntu.sources" if [[ ! -f "$SOURCE_FILE" ]]; then echo "Expected file not found: $SOURCE_FILE" exit 1 fi echo echo "[1/4] Backing up existing sources..." cp "$SOURCE_FILE" "${SOURCE_FILE}.bak" echo echo "[2/4] Writing Liara mirror configuration..." cat > "$SOURCE_FILE" <