diff --git a/README.md b/README.md index 2842e6c..8a241ca 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,16 @@ CentOS Linux 8. It does not support CentOS Stream. 1. Either clone this repository or download the [`centos2ol.sh`](./centos2ol.sh) script. 1. Run `sudo bash centos2ol.sh` to switch your CentOS instance to Oracle Linux. +### Usage options +* `-r` Reinstalls all CentOS RPMs with Oracle Linux RPMs + + If a system is swiched to Oracle Linux and there is no newer Oracle Linux version + of a package already installed then the CentOS version remains. + This option proceeds to reinstall any CentOS RPM with an identical version from + Oracle Linunx. This is not necessary for support and has no impact to a systems functionality + but is offered so a user can remove CentOS GPG keys from the truststore. + A list of all non-Oracle RPMs will be displayed after the reinstall process. + ## Limitations 1. The script currently needs to be able communicate with the CentOS and Oracle diff --git a/centos2ol.sh b/centos2ol.sh old mode 100644 new mode 100755 index e1b06f8..0d97476 --- a/centos2ol.sh +++ b/centos2ol.sh @@ -38,6 +38,9 @@ usage() { echo "OPTIONS" echo "-h" echo " Display this help and exit" + echo "-r" + echo " Reinstall all CentOS RPMs with Oracle Linux RPMs" + echo " Note: This is not necessary for support" exit 1 } >&2 @@ -72,9 +75,12 @@ Your repositories have been restored to your previous configuration." ## Start of script -while getopts "h" option; do +reinstall_all_rpms=false + +while getopts "h:r" option; do case "$option" in h) usage ;; + r) reinstall_all_rpms=true ;; *) usage ;; esac done @@ -486,6 +492,26 @@ case "$os_version" in ;; esac +if "${reinstall_all_rpms}"; then + echo "Testing for remaining CentOS RPMs" + # If CentOS and Oracle Linux have identically versioned RPMs then those RPMs are left unchanged. + # This should have no technical impact but for completeness, reinstall these RPMs + # so there is no accidental cross pollination. + mapfile -t list_of_centos_rpms < <(rpm -qa --qf "%{NAME}-%{VERSION}-%{RELEASE} %{VENDOR}\n" | grep CentOS | awk '{print $1}') + if [[ -n "${list_of_centos_rpms[*]}" ]]; then + echo "Reinstalling RPMs: ${list_of_centos_rpms[*]}" + yum --assumeyes --disablerepo "*" --enablerepo "ol*" reinstall "${list_of_centos_rpms[@]}" + fi + # See if non-Oracle RPMs are present and print them + mapfile -t non_oracle_rpms < <(rpm -qa --qf "%{NAME}-%{VERSION}-%{RELEASE}|%{VENDOR}|%{PACKAGER}\n" |grep -v Oracle) + if [[ -n "${non_oracle_rpms[*]}" ]]; then + echo "The following non-Oracle RPMs are installed on the system:" + printf '\t%s\n' "${non_oracle_rpms[@]}" + echo "This may be expected of your environment and does not necessarily indicate a problem." + echo "If a large number of CentOS RPMs are included and you're unsure why please open an issue on ${github_url}" + fi +fi + echo "Sync successful. Switching default kernel to the UEK." arch=$(uname -m)