From d2f9c60da6da5d2bb4c6833e8011462531f79973 Mon Sep 17 00:00:00 2001 From: Toni <32644679+dethmasque@users.noreply.github.com> Date: Tue, 11 Jan 2022 17:06:24 -0500 Subject: [PATCH 1/3] add amazon to detectable OSs, install epel --- install.sh | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index 571c4da..668c180 100755 --- a/install.sh +++ b/install.sh @@ -75,6 +75,10 @@ detect_os () { then distro="LEAP15" fi + if [[ $(cat /etc/os-release | grep -e "^CPE_NAME\=*" | cut -f 2 -d '=') =~ cpe:2.3:o:amazon:amazon_linux:2 ]] + then + distro="Amazon" + fi if [[ $(cat /etc/os-release | grep -e "^ID\=*" | cut -f 2 -d '=') == "debian" ]]; then distro="Debian" fi @@ -103,13 +107,17 @@ detect_os_version () { if [[ "${os}" == "SLES15" ]] || [[ "${os}" == "LEAP15" ]]; then cat /etc/os-release | grep -e "^VERSION_ID\=*" | cut -f 2 -d '=' | sed -e 's/[".]//g' fi + # reuse rhel7 binaries for amazon + if [[ "${os}" == "Amazon" ]]; then + echo "7" + fi } # Returns the installer type detect_installer_type () { os=$1 case $os in - "RedHat" | "CentOS" | "LEAP12" | "LEAP15" | "SLES12" | "SLES15") + "RedHat" | "CentOS" | "LEAP12" | "LEAP15" | "SLES12" | "SLES15" | "Amazon") echo "rpm" ;; "Ubuntu" | "Debian") @@ -139,7 +147,7 @@ download_name () { os=$1 version=$2 case $os in - "RedHat" | "CentOS") + "RedHat" | "CentOS" | "Amazon") echo "R-${version}-1-1.x86_64.rpm" ;; "Ubuntu" | "Debian") @@ -164,7 +172,7 @@ download_url () { else case $os in - "RedHat" | "CentOS") + "RedHat" | "CentOS" | "Amazon") echo "${CDN_URL}/centos-${ver}/pkgs/${name}" ;; "Ubuntu") @@ -276,7 +284,7 @@ install_rpm () { yes="-y" fi case $os in - "RedHat" | "CentOS") + "RedHat" | "CentOS" | "Amazon") if ! has_sudo "yum"; then echo "Must have sudo privileges to run yum" exit 1 @@ -308,6 +316,9 @@ install_pre () { "RedHat" | "CentOS") install_epel "${ver}" ;; + "Amazon") + install_epel_amzn + ;; "SLES12") install_python_backports ;; @@ -316,6 +327,15 @@ install_pre () { esac } +# Installs EPEL for Amazon Linux 2 +install_epel_amzn () { + yes= + if [[ "${RUN_UNATTENDED}" -ne "0" ]]; then + yes="-y" + fi + ${SUDO} amazon-linux-extras install epel ${yes} +} + # Installs EPEL for RHEL/CentOS install_epel () { ver=$1 From b4c07a82838ae1f3bf44b8ae2cad19fc836ef105 Mon Sep 17 00:00:00 2001 From: Toni <32644679+dethmasque@users.noreply.github.com> Date: Tue, 11 Jan 2022 17:29:10 -0500 Subject: [PATCH 2/3] add alma and rocky linux --- install.sh | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index 668c180..594494f 100755 --- a/install.sh +++ b/install.sh @@ -79,9 +79,18 @@ detect_os () { then distro="Amazon" fi + if [[ $(cat /etc/os-release | grep -e "^CPE_NAME\=*" | cut -f 2 -d '=') =~ cpe:/o:almalinux:almalinux:8::baseos ]] + then + distro="Alma" + fi + if [[ $(cat /etc/os-release | grep -e "^CPE_NAME\=*" | cut -f 2 -d '=') =~ cpe:/o:rocky:rocky:8.5:GA ]] + then + distro="Rocky" + fi if [[ $(cat /etc/os-release | grep -e "^ID\=*" | cut -f 2 -d '=') == "debian" ]]; then distro="Debian" fi + echo "${distro}" } @@ -111,13 +120,17 @@ detect_os_version () { if [[ "${os}" == "Amazon" ]]; then echo "7" fi + # reuse rhel8 binaries for alma and rocky + if [[ "${os}" =~ ^(Alma|Rocky) ]]; then + echo "8" + fi } # Returns the installer type detect_installer_type () { os=$1 case $os in - "RedHat" | "CentOS" | "LEAP12" | "LEAP15" | "SLES12" | "SLES15" | "Amazon") + "RedHat" | "CentOS" | "LEAP12" | "LEAP15" | "SLES12" | "SLES15" | "Amazon" | "Alma" | "Rocky") echo "rpm" ;; "Ubuntu" | "Debian") @@ -147,7 +160,7 @@ download_name () { os=$1 version=$2 case $os in - "RedHat" | "CentOS" | "Amazon") + "RedHat" | "CentOS" | "Amazon" | "Alma" | "Rocky") echo "R-${version}-1-1.x86_64.rpm" ;; "Ubuntu" | "Debian") @@ -172,7 +185,7 @@ download_url () { else case $os in - "RedHat" | "CentOS" | "Amazon") + "RedHat" | "CentOS" | "Amazon" | "Alma" | "Rocky") echo "${CDN_URL}/centos-${ver}/pkgs/${name}" ;; "Ubuntu") @@ -313,7 +326,7 @@ install_pre () { ver=$2 case $os in - "RedHat" | "CentOS") + "RedHat" | "CentOS" | "Alma" | "Rocky") install_epel "${ver}" ;; "Amazon") @@ -336,7 +349,7 @@ install_epel_amzn () { ${SUDO} amazon-linux-extras install epel ${yes} } -# Installs EPEL for RHEL/CentOS +# Installs EPEL for RHEL/CentOS/Alma/Rocky install_epel () { ver=$1 yes= From da42f97e279c6fa0a3eb978de534dcbccb3213b4 Mon Sep 17 00:00:00 2001 From: Toni <32644679+dethmasque@users.noreply.github.com> Date: Tue, 11 Jan 2022 17:38:08 -0500 Subject: [PATCH 3/3] missed an alma and rocky in install_rpm --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 594494f..3ba156d 100755 --- a/install.sh +++ b/install.sh @@ -297,7 +297,7 @@ install_rpm () { yes="-y" fi case $os in - "RedHat" | "CentOS" | "Amazon") + "RedHat" | "CentOS" | "Amazon" | "Alma" | "Rocky") if ! has_sudo "yum"; then echo "Must have sudo privileges to run yum" exit 1