From 2e17ef68cefd8613f2cd575a40cc55f4c072bd21 Mon Sep 17 00:00:00 2001 From: hwdsl2 Date: Tue, 27 Jul 2021 00:59:15 -0500 Subject: [PATCH] Update OS detection --- extras/ikev2setup.sh | 26 ++++++++++++-------------- extras/vpnupgrade_centos.sh | 6 +++--- vpnsetup_centos.sh | 8 ++++---- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/extras/ikev2setup.sh b/extras/ikev2setup.sh index 239aa72..9553f2e 100755 --- a/extras/ikev2setup.sh +++ b/extras/ikev2setup.sh @@ -36,21 +36,19 @@ check_run_as_root() { } check_os_type() { + os_type=centos os_arch=$(uname -m | tr -dc 'A-Za-z0-9_-') rh_file="/etc/redhat-release" - if grep -qs -e "release 7" -e "release 8" "$rh_file"; then - os_type=centos - if grep -qs "Red Hat" "$rh_file"; then - os_type=rhel - fi - if grep -qs "release 7" "$rh_file"; then - os_ver=7 - elif grep -qs "release 8" "$rh_file"; then - os_ver=8 - if grep -qi stream "$rh_file"; then - os_ver=8s - fi - fi + if grep -qs "Red Hat" "$rh_file"; then + os_type=rhel + fi + if grep -qs "release 7" "$rh_file"; then + os_ver=7 + elif grep -qs "release 8" "$rh_file"; then + os_ver=8 + grep -qi stream "$rh_file" && os_ver=8s + grep -qi rocky "$rh_file" && os_type=rocky + grep -qi alma "$rh_file" && os_type=alma elif grep -qs "Amazon Linux release 2" /etc/system-release; then os_type=amzn os_ver=2 @@ -85,7 +83,7 @@ check_os_type() { get_update_url() { update_url=vpnupgrade - if [ "$os_type" = "centos" ] || [ "$os_type" = "rhel" ]; then + if [ "$os_type" = "centos" ] || [ "$os_type" = "rhel" ] || [ "$os_type" = "rocky" ] || [ "$os_type" = "alma" ]; then update_url=vpnupgrade-centos elif [ "$os_type" = "amzn" ]; then update_url=vpnupgrade-amzn diff --git a/extras/vpnupgrade_centos.sh b/extras/vpnupgrade_centos.sh index 80dc740..dc0b79a 100755 --- a/extras/vpnupgrade_centos.sh +++ b/extras/vpnupgrade_centos.sh @@ -36,9 +36,9 @@ if grep -qs "release 7" "$rh_file"; then os_ver=7 elif grep -qs "release 8" "$rh_file"; then os_ver=8 - if grep -qi stream "$rh_file"; then - os_ver=8s - fi + grep -qi stream "$rh_file" && os_ver=8s + grep -qi rocky "$rh_file" && os_type=rocky + grep -qi alma "$rh_file" && os_type=alma else echo "Error: This script only supports CentOS/RHEL 7 and 8." >&2 echo "For Ubuntu/Debian, use https://git.io/vpnupgrade" >&2 diff --git a/vpnsetup_centos.sh b/vpnsetup_centos.sh index 9109b9e..6cedecd 100755 --- a/vpnsetup_centos.sh +++ b/vpnsetup_centos.sh @@ -59,9 +59,9 @@ if grep -qs "release 7" "$rh_file"; then os_ver=7 elif grep -qs "release 8" "$rh_file"; then os_ver=8 - if grep -qi stream "$rh_file"; then - os_ver=8s - fi + grep -qi stream "$rh_file" && os_ver=8s + grep -qi rocky "$rh_file" && os_type=rocky + grep -qi alma "$rh_file" && os_type=alma else echo "Error: This script only supports CentOS/RHEL 7 and 8." >&2 echo "For Ubuntu/Debian, use https://git.io/vpnsetup" >&2 @@ -150,7 +150,7 @@ bigecho "Adding the EPEL repository..." epel_url="https://dl.fedoraproject.org/pub/epel/epel-release-latest-$(rpm -E '%{rhel}').noarch.rpm" ( set -x - yum -y -q install epel-release >/dev/null || yum -y -q install "$epel_url" >/dev/null + yum -y -q install epel-release >/dev/null 2>&1 || yum -y -q install "$epel_url" >/dev/null ) || exiterr2 bigecho "Installing packages required for the VPN..."