forked from Interanet/server-bootstrap
initial commit
This commit is contained in:
71
scripts/mirrors/os/liara/ubuntu.sh
Normal file
71
scripts/mirrors/os/liara/ubuntu.sh
Normal file
@@ -0,0 +1,71 @@
|
||||
#!/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" <<EOF
|
||||
Types: deb
|
||||
URIs: https://linux-mirror.liara.ir/repository/ubuntu
|
||||
Suites: ${CODENAME} ${CODENAME}-updates ${CODENAME}-backports
|
||||
Components: main restricted universe multiverse
|
||||
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
|
||||
|
||||
Types: deb
|
||||
URIs: https://linux-mirror.liara.ir/repository/ubuntu-security
|
||||
Suites: ${CODENAME}-security
|
||||
Components: main restricted universe multiverse
|
||||
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
|
||||
EOF
|
||||
|
||||
echo
|
||||
echo "[3/4] Mirror configuration written."
|
||||
|
||||
echo
|
||||
echo "[4/4] Updating package index..."
|
||||
apt update
|
||||
|
||||
echo
|
||||
echo "================================="
|
||||
echo "Liara Ubuntu mirror configured"
|
||||
echo "Backup saved at:"
|
||||
echo "${SOURCE_FILE}.bak"
|
||||
echo "================================="
|
||||
Reference in New Issue
Block a user