From fd38c697d907b68086711ba162bfa3c3ee7cee23 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Mon, 20 Nov 2023 13:43:09 +0100 Subject: [PATCH] Refactoring snippets/tpl.190.repos_rhel9.sh to use local mirrors --- snippets/tpl.190.repos_rhel9.sh | 36 +++++++++++++++++---------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/snippets/tpl.190.repos_rhel9.sh b/snippets/tpl.190.repos_rhel9.sh index c11e813..dfb1e90 100644 --- a/snippets/tpl.190.repos_rhel9.sh +++ b/snippets/tpl.190.repos_rhel9.sh @@ -14,10 +14,10 @@ get_repos_rhel9() { log "Installing repositories for RHEL 9." - if [[ -z "${rhsm_registred}" ]] ; then - echo "Cannot generate RedHat repo, system is not registred at RedHat Subscription Management." - return - fi + # if [[ -z "${rhsm_registred}" ]] ; then + # echo "Cannot generate RedHat repo, system is not registred at RedHat Subscription Management." + # return + # fi echo echo "Deactivating management of repositories by subscription-manager ..." @@ -27,35 +27,37 @@ get_repos_rhel9() { grep ^manage_repos /etc/rhsm/rhsm.conf echo - local serial=$( ${rhsm} list --no-progress-messages --consumed | grep -i '^Serial:' | awk '{print $2}' ) - if [[ -z "${serial}" ]] ; then - echo "Cannot generate RedHat repo, did not found subscription serial number." - return - fi + # local serial=$( ${rhsm} list --no-progress-messages --consumed | grep -i '^Serial:' | awk '{print $2}' ) + # if [[ -z "${serial}" ]] ; then + # echo "Cannot generate RedHat repo, did not found subscription serial number." + # return + # fi - log "Found subscription serial number: '${serial}'." + # log "Found subscription serial number: '${serial}'." local -a repos=( - 'rhel-9-for-x86_64-appstream-rpms' - 'rhel-9-for-x86_64-baseos-rpms' - 'rhv-4-tools-for-rhel-9-x86_64-rpms' + 'codeready-builder-for-rhel-9-x86_64-rpms' + 'rhel-9-for-x86_64-appstream-rpms' + 'rhel-9-for-x86_64-baseos-rpms' + 'rhv-4-tools-for-rhel-9-x86_64-rpms' ) local repo= local url= local tmp_file= for repo in "${repos[@]}" ; do + echo echo "Ensuring repo '${repo}.repo'..." url="${base_url}/${repo}.repo" tmp_file=$( mktemp ) curl -s -S -o "${tmp_file}" --connect-timeout 3 "${url}" || true if [[ -s "${tmp_file}" ]] ; then - sed -i -e "s|\${REPO_SERVER}|${redhat_repo_server}|g" \ - -e "s|\${PATH_PREFIX}|${redhat_repo_path_prefix}|g" \ - -e "s|\${RHSM_SERIAL}|${serial}|g" \ + sed -i -e "s|\${REPO_SERVER}\${PATH_PREFIX}|${rhel9_reposerver_url}|g" \ -e "s|\${RH_GPG_FILE}|${redhat_gpg_key}|" \ "${tmp_file}" - mv -v "${tmp_file}" "/etc/yum.repos.d/${repo}.repo" + cat "${tmp_file}" | \ + grep -v -P '^ssl(verify|cacert|clientkey|clientcert|verifystatus)' | \ + tee "/etc/yum.repos.d/${repo}.repo" fi rm -fv "${tmp_file}" done -- 2.39.5