diff --git a/migrate2rocky/README.md b/migrate2rocky/README.md index f8d47a5..beee1c4 100644 --- a/migrate2rocky/README.md +++ b/migrate2rocky/README.md @@ -16,7 +16,7 @@ Running this script will convert an existing CentOS 8 system to Rocky Linux 8. #### Use Mirror URLs of Rocky Linux ```bash -export ROCKY_LINUX_ENV_MIRROR_URL="https://mirrors.example.org/rocky" +export ROCKY_ENV_MIRROR_URL="https://mirrors.example.org/rocky" ./migrate2rocky.sh -r ``` diff --git a/migrate2rocky/migrate2rocky.sh b/migrate2rocky/migrate2rocky.sh index d68e5c0..39b7a04 100644 --- a/migrate2rocky/migrate2rocky.sh +++ b/migrate2rocky/migrate2rocky.sh @@ -115,10 +115,10 @@ SUPPORTED_PLATFORM="platform:el$SUPPORTED_MAJOR" ARCH=$(arch) # 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}"}" +ROCKY_DEFAULT_URL="https://dl.rockylinux.org/pub/rocky" +ROCKY_MIRROR_URL="${ROCKY_ENV_MIRROR_URL:-"${ROCKY_DEFAULT_URL}"}" -gpg_key_url="${ROCKY_LINUX_MIRROR_URL}/RPM-GPG-KEY-rockyofficial" +gpg_key_url="${ROCKY_MIRROR_URL}/RPM-GPG-KEY-rockyofficial" gpg_key_sha512="88fe66cf0a68648c2371120d56eb509835266d9efdf7c8b9ac8fc101bdf1f0e0197030d3ea65f4b5be89dc9d1ef08581adb068815c88d7b1dc40aa1c32990f6a" sm_ca_dir=/etc/rhsm/ca @@ -127,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]="${ROCKY_LINUX_MIRROR_URL}/${SUPPORTED_MAJOR}/BaseOS/$ARCH/os/" - [rockyappstream]="${ROCKY_LINUX_MIRROR_URL}/${SUPPORTED_MAJOR}/AppStream/$ARCH/os/" + [rockybaseos]="${ROCKY_MIRROR_URL}/${SUPPORTED_MAJOR}/BaseOS/$ARCH/os/" + [rockyappstream]="${ROCKY_MIRROR_URL}/${SUPPORTED_MAJOR}/AppStream/$ARCH/os/" ) # The repos package for CentOS stream requires special handling. @@ -850,11 +850,13 @@ EOF fi # Replace mirror - if [ -n "$ROCKY_LINUX_ENV_MIRROR_URL" ]; then + if [[ $ROCKY_ENV_MIRROR_URL ]]; then + local -a repo_files + readarray -t repo_files < <(rpm -ql rocky-repos | grep '\.repo$') 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 + -e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl='"$ROCKY_MIRROR_URL"'|g' \ + -i.migrate2rocky \ + "${repo_files[@]}" fi # Distrosync