From 6ed1ef21998eed8f42f92ed88bd3b3fedc24fc2d Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@iml.unibe.ch>
Date: Wed, 31 Aug 2022 09:47:49 +0200
Subject: [PATCH] status line depends on os major version

---
 check_packages2install-pkgmanager/yum.sh | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/check_packages2install-pkgmanager/yum.sh b/check_packages2install-pkgmanager/yum.sh
index 4ce9e8d..8121c60 100644
--- a/check_packages2install-pkgmanager/yum.sh
+++ b/check_packages2install-pkgmanager/yum.sh
@@ -11,6 +11,7 @@
 # 2022-06-03  v1.0  ah  first version
 # 2022-06-07  v1.1  ah  add sudo for yum --bugfix check-update
 #                       rename functions
+# 2022-08-31  v1.2  ah  status line depends on os major version
 # ===============================================================
 
 
@@ -38,8 +39,16 @@ function yum.getPackageList(){
 # ---------------------------------------------------------------
 # get custom status
 function yum.getStatusLine(){
-  if ! sudo /usr/bin/yum --bugfix check-update 2>&1 | grep security; then
-    echo "No security updates needed and no updates available"
+  typeset -i local _osversion
+  _osversion=$(grep -o "\ [0-9]*\." /etc/redhat-release | cut -f 1 -d '.')
+  if [ $_osversion -ge 8 ]; then
+    if ! sudo /usr/bin/yum --security check-update | grep "available"; then
+      echo "No security updates needed and no updates available"
+    fi
+  else
+    if ! sudo /usr/bin/yum --bugfix check-update 2>&1 | grep security; then
+      echo "No security updates needed and no updates available"
+    fi
   fi
 }
 
-- 
GitLab