From a8275838d5331db854141a2772c57d347dc45f80 Mon Sep 17 00:00:00 2001 From: Chris Kim Date: Thu, 29 Oct 2020 07:13:59 -0700 Subject: [PATCH] Add additional conditional logic to install.sh to prevent errors on Fedora or systems when run as non-root Signed-off-by: Chris Kim --- install.sh | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index 54cabaa9c7..54b1474d53 100755 --- a/install.sh +++ b/install.sh @@ -469,11 +469,21 @@ install_selinux_rpm() { if [ -r /etc/redhat-release ] || [ -r /etc/centos-release ] || [ -r /etc/oracle-release ]; then dist_version="$(. /etc/os-release && echo "$VERSION_ID")" maj_ver=$(echo "$dist_version" | sed -E -e "s/^([0-9]+)\.?[0-9]*$/\1/") - if [ -r /etc/redhat-release ] && [ "${maj_ver}" = "7" ]; then - yum -y install yum-utils - yum-config-manager --enable rhel-7-server-extras-rpms + if [ -r /etc/redhat-release ]; then + case ${maj_ver} in + 7) + $SUDO yum -y install yum-utils + $SUDO yum-config-manager --enable rhel-7-server-extras-rpms + ;; + 8) + : + ;; + *) + return + ;; + esac fi - cat <<-EOF >"/etc/yum.repos.d/rancher-k3s-common-${INSTALL_K3S_CHANNEL}.repo" + $SUDO tee /etc/yum.repos.d/rancher-k3s-common-${INSTALL_K3S_CHANNEL}.repo >/dev/null << EOF [rancher-k3s-common-${INSTALL_K3S_CHANNEL}] name=Rancher K3s Common (${INSTALL_K3S_CHANNEL}) baseurl=https://${1}/k3s/${INSTALL_K3S_CHANNEL}/common/centos/${maj_ver}/noarch @@ -481,7 +491,7 @@ enabled=1 gpgcheck=1 gpgkey=https://${1}/public.key EOF - yum -y install "k3s-selinux" + $SUDO yum -y install "k3s-selinux" fi return }