21361: Expand distro detection in Salt installer
authorBrett Smith <brett.smith@curii.com>
Mon, 29 Jan 2024 03:10:11 +0000 (22:10 -0500)
committerBrett Smith <brett.smith@curii.com>
Wed, 31 Jan 2024 22:22:25 +0000 (17:22 -0500)
The immediate motivation for this is to detect Alma/Rocky/RHEL 8.
The way we do it is by reading both the ID and ID_LIKE values from
/etc/os-release. All these have "rhel" in either ID or
ID_LIKE. Similiarly, Ubuntu has ID_LIKE=debian. We're already reading
this file anyway; now we just use more of it.

Arvados-DCO-1.1-Signed-off-by: Brett Smith <brett.smith@curii.com>

tools/salt-install/provision.sh

index eb09dddf2c9fd69101f3e73f39945208b6a21e69..bb95b2702aca0771cb2faaed9d44f5792c80f99d 100755 (executable)
@@ -364,24 +364,25 @@ if [ "${DUMP_CONFIG}" = "yes" ]; then
 else
   # Install a few dependency packages
   # First, let's figure out the OS we're working on
-  OS_ID=$(grep ^ID= /etc/os-release |cut -f 2 -d=  |cut -f 2 -d \")
-  echo "Detected distro: ${OS_ID}"
-
-  case ${OS_ID} in
-    "centos")
-      echo "WARNING! Disabling SELinux, see https://dev.arvados.org/issues/18019"
-      sed -i 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/sysconfig/selinux
-      setenforce permissive
-      yum install -y  curl git jq
-      ;;
-    "debian"|"ubuntu")
-      # Wait 2 minutes for any apt locks to clear
-      # This option is supported from apt 1.9.1 and ignored in older apt versions.
-      # Cf. https://blog.sinjakli.co.uk/2021/10/25/waiting-for-apt-locks-without-the-hacky-bash-scripts/
-      DEBIAN_FRONTEND=noninteractive apt -o DPkg::Lock::Timeout=120 update
-      DEBIAN_FRONTEND=noninteractive apt install -y curl git jq
-      ;;
-  esac
+  OS_IDS="$(. /etc/os-release && echo "${ID:-} ${ID_LIKE:-}")"
+  echo "Detected distro families: $OS_IDS"
+
+  for OS_ID in $OS_IDS; do
+    case "$OS_ID" in
+      rhel)
+        echo "WARNING! Disabling SELinux, see https://dev.arvados.org/issues/18019"
+        sed -i 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/sysconfig/selinux
+        setenforce permissive
+        yum install -y  curl git jq
+        break
+        ;;
+      debian)
+        DEBIAN_FRONTEND=noninteractive apt -o DPkg::Lock::Timeout=120 update
+        DEBIAN_FRONTEND=noninteractive apt install -y curl git jq
+        break
+        ;;
+    esac
+  done
 
   if which salt-call; then
     echo "Salt already installed"