}
+#------------------------------------------------------------------------------
+mangle_repos() {
+
+ local serial=$( ${SM_BIN} list --consumed --no-progress-messages | \
+ grep -i '^Serial:' | \
+ sed -e 's/^Serial:[ ]*//i' -e 's/[ ]*$//' )
+
+ if [[ -z "${serial}" ]] ; then
+ error "Did not found the serial of the RHEL subscription."
+ return 0
+ fi
+ debug "Found serial of the RHEL subscription: '${CYAN}${serial}${NORMAL}'."
+
+ local -a cmd=()
+ local repo_file=
+ local do_mangle=
+
+ for repo_file in /etc/yum.repos.d/*.repo ; do
+ if [[ ! -f "${repo_file}" ]] ; then
+ continue
+ fi
+ debug "Trying to mangle '${CYAN}${repo_file}${NORMAL}' ..."
+ do_mangle=
+ if grep -P -q '^sslclient(key|cert)\s*=\s*/etc/pki/entitlement/' "${repo_file}"; then
+ do_mangle="y"
+ fi
+ if [[ "${do_mangle}" != "y" ]] ; then
+ continue
+ fi
+ info "Mangling repo file '${CYAN}${repo_file}${NORMAL}' ..."
+ cmd=( 'sed' '-i' )
+ cmd+=( "-e" "'s|^sslclientkey[ ]*=[ ]*/etc/pki/entitlement/.*|sslclientkey=/etc/pki/entitlement/${serial}-key.pem|'" )
+ cmd+=( "-e" "'s|^sslclientcert[ ]*=[ ]*/etc/pki/entitlement/.*|sslclientkey=/etc/pki/entitlement/${serial}.pem|'" )
+ cmd+=( "'${repo_file}'" )
+
+ exec_cmd "${cmd[@]}"
+ done
+
+}
+
################################################################################
##
## Main
set_locale "en_US.utf8"
check_for_root
register_rhel
- # mangle_repos
+ mangle_repos
}