Files
2026-03-18 03:29:25 +08:00

60 lines
1.3 KiB
Bash

#!/usr/bin/env bash
set -e
echo "================================="
echo " Liara Rocky Linux Mirror Setup"
echo "================================="
source /etc/os-release
if [[ "$ID" != "rocky" ]]; then
echo "This script only supports Rocky Linux."
echo "Detected OS: $ID"
exit 1
fi
REPO="/etc/yum.repos.d/rocky.repo"
echo
echo "[1/3] Backing up existing repository..."
if [[ -f "$REPO" ]]; then
cp "$REPO" "$REPO.bak"
fi
echo
echo "[2/3] Writing Liara mirror configuration..."
cat > "$REPO" <<'EOF'
[baseos]
name=Rocky Linux $releasever - BaseOS
baseurl=https://linux-mirror.liara.ir/repository/rocky/$contentdir/$releasever/BaseOS/$basearch/os/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-9
metadata_expire=6h
[appstream]
name=Rocky Linux $releasever - AppStream
baseurl=https://linux-mirror.liara.ir/repository/rocky/$contentdir/$releasever/AppStream/$basearch/os/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-9
metadata_expire=6h
[crb]
name=Rocky Linux $releasever - CRB
baseurl=https://linux-mirror.liara.ir/repository/rocky/$contentdir/$releasever/CRB/$basearch/os/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-9
metadata_expire=6h
EOF
echo
echo "[3/3] Refreshing package cache..."
dnf makecache
echo
echo "Rocky mirror configured successfully."