diff --git a/migrate2rocky/migrate2rocky.sh b/migrate2rocky/migrate2rocky.sh index cdf3616..d68e5c0 100644 --- a/migrate2rocky/migrate2rocky.sh +++ b/migrate2rocky/migrate2rocky.sh @@ -114,7 +114,11 @@ SUPPORTED_MAJOR="8" SUPPORTED_PLATFORM="platform:el$SUPPORTED_MAJOR" ARCH=$(arch) -gpg_key_url="https://dl.rockylinux.org/pub/rocky/RPM-GPG-KEY-rockyofficial" +# Use Mirror URLs of Rocky Linux from environment if set. +ROCKY_LINUX_DEFAULT_URL="https://dl.rockylinux.org/pub/rocky" +ROCKY_LINUX_MIRROR_URL="${ROCKY_LINUX_ENV_MIRROR_URL:-"${ROCKY_LINUX_DEFAULT_URL}"}" + +gpg_key_url="${ROCKY_LINUX_MIRROR_URL}/RPM-GPG-KEY-rockyofficial" gpg_key_sha512="88fe66cf0a68648c2371120d56eb509835266d9efdf7c8b9ac8fc101bdf1f0e0197030d3ea65f4b5be89dc9d1ef08581adb068815c88d7b1dc40aa1c32990f6a" sm_ca_dir=/etc/rhsm/ca @@ -123,8 +127,8 @@ unset tmp_sm_ca_dir # all repos must be signed with the same key given in $gpg_key_url declare -A repo_urls repo_urls=( - [rockybaseos]="https://dl.rockylinux.org/pub/rocky/${SUPPORTED_MAJOR}/BaseOS/$ARCH/os/" - [rockyappstream]="https://dl.rockylinux.org/pub/rocky/${SUPPORTED_MAJOR}/AppStream/$ARCH/os/" + [rockybaseos]="${ROCKY_LINUX_MIRROR_URL}/${SUPPORTED_MAJOR}/BaseOS/$ARCH/os/" + [rockyappstream]="${ROCKY_LINUX_MIRROR_URL}/${SUPPORTED_MAJOR}/AppStream/$ARCH/os/" ) # The repos package for CentOS stream requires special handling. @@ -845,6 +849,14 @@ EOF done fi + # Replace mirror + if [ -n "$ROCKY_LINUX_ENV_MIRROR_URL" ]; then + sed -e 's|^mirrorlist=|#mirrorlist=|g' \ + -e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl='${ROCKY_LINUX_MIRROR_URL}'|g' \ + -i.bak \ + /etc/yum.repos.d/Rocky-*.repo + fi + # Distrosync infomsg $'Ensuring repos are enabled before the package swap\n' safednf -y --enableplugin=config-manager config-manager \