Update quick install script for RHEL 9

This commit is contained in:
Greg Lin 2022-08-09 17:51:13 -05:00
commit 53bc157354

View file

@ -79,11 +79,11 @@ detect_os () {
then then
distro="Amazon" distro="Amazon"
fi fi
if [[ $(cat /etc/os-release | grep -e "^CPE_NAME\=*" | cut -f 2 -d '=') =~ cpe:/o:almalinux:almalinux:8::baseos ]] if [[ $(cat /etc/os-release | grep -e "^CPE_NAME\=*" | cut -f 2 -d '=') =~ cpe:/o:almalinux:almalinux: ]]
then then
distro="Alma" distro="Alma"
fi fi
if [[ $(cat /etc/os-release | grep -e "^CPE_NAME\=*" | cut -f 2 -d '=') =~ cpe:/o:rocky:rocky:8.5:GA ]] if [[ $(cat /etc/os-release | grep -e "^CPE_NAME\=*" | cut -f 2 -d '=') =~ cpe:/o:rocky:rocky: ]]
then then
distro="Rocky" distro="Rocky"
fi fi
@ -97,17 +97,13 @@ detect_os () {
# Returns the OS version # Returns the OS version
detect_os_version () { detect_os_version () {
os=$1 os=$1
if [[ "${os}" == "RedHat" ]]; then if [[ "${os}" =~ ^(RedHat|Alma|Rocky)$ ]]; then
if [[ $(cat /etc/os-release | grep -e "^VERSION_ID\=*" | cut -f 2 -d '=') =~ ^(\"8.|28) ]]; then # Get the major version. /etc/redhat-release is used if /etc/os-release isn't available,
echo "8" # e.g., on CentOS/RHEL 6.
elif [[ $(cat /etc/os-release | grep -e "^VERSION_ID\=*" | cut -f 2 -d '=') =~ ^(\"7.) ]]; then if [[ -f /etc/os-release ]]; then
echo "7" cat /etc/os-release | grep VERSION_ID= | sed -E 's/VERSION_ID="([0-9.]*)"/\1/' | cut -d '.' -f 1
elif [[ -f /etc/redhat-release ]]; then elif [[ -f /etc/redhat-release ]]; then
if [[ $(cat /etc/redhat-release | grep "6.") ]]; then cat /etc/redhat-release | sed -E 's/[^0-9]+([0-9.]+)[^0-9]*/\1/' | cut -d '.' -f 1
echo 6
fi
elif [[ -f /etc/os-release ]]; then
cat /etc/os-release | grep -e "^VERSION_ID\=*" | cut -f 2 -d '=' | sed -e 's/"//g'
fi fi
fi fi
if [[ "${os}" == "Ubuntu" ]] || [[ "${os}" == "Debian" ]]; then if [[ "${os}" == "Ubuntu" ]] || [[ "${os}" == "Debian" ]]; then
@ -120,10 +116,6 @@ detect_os_version () {
if [[ "${os}" == "Amazon" ]]; then if [[ "${os}" == "Amazon" ]]; then
echo "7" echo "7"
fi fi
# reuse rhel8 binaries for alma and rocky
if [[ "${os}" =~ ^(Alma|Rocky) ]]; then
echo "8"
fi
} }
# Returns the installer type # Returns the installer type
@ -186,7 +178,11 @@ download_url () {
case $os in case $os in
"RedHat" | "CentOS" | "Amazon" | "Alma" | "Rocky") "RedHat" | "CentOS" | "Amazon" | "Alma" | "Rocky")
echo "${CDN_URL}/centos-${ver}/pkgs/${name}" if [ "${ver}" -ge 9 ]; then
echo "${CDN_URL}/rhel-${ver}/pkgs/${name}"
else
echo "${CDN_URL}/centos-${ver}/pkgs/${name}"
fi
;; ;;
"Ubuntu") "Ubuntu")
echo "${CDN_URL}/ubuntu-${ver}/pkgs/${name}" echo "${CDN_URL}/ubuntu-${ver}/pkgs/${name}"
@ -328,7 +324,7 @@ install_pre () {
case $os in case $os in
"RedHat" | "CentOS" | "Alma" | "Rocky") "RedHat" | "CentOS" | "Alma" | "Rocky")
install_epel "${ver}" install_epel "${os}" "${ver}"
;; ;;
"Amazon") "Amazon")
install_epel_amzn install_epel_amzn
@ -352,7 +348,8 @@ install_epel_amzn () {
# Installs EPEL for RHEL/CentOS/Alma/Rocky # Installs EPEL for RHEL/CentOS/Alma/Rocky
install_epel () { install_epel () {
ver=$1 os=$1
ver=$2
yes= yes=
if [[ "${RUN_UNATTENDED}" -ne "0" ]]; then if [[ "${RUN_UNATTENDED}" -ne "0" ]]; then
yes="-y" yes="-y"
@ -366,6 +363,16 @@ install_epel () {
;; ;;
"8") "8")
;; ;;
"9")
if [[ "${os}" == "RedHat" ]]; then
${SUDO} subscription-manager repos --enable "codeready-builder-for-rhel-9-$(arch)-rpms"
${SUDO} dnf install ${yes} https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
else
${SUDO} dnf install ${yes} dnf-plugins-core
${SUDO} dnf config-manager --set-enabled crb
${SUDO} dnf install ${yes} epel-release
fi
;;
esac esac
} }