From 2d6c039e7dc7b78f1ad1cb74e9026e6df06c2eca Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Thu, 27 Jul 2023 16:59:39 +0200
Subject: [PATCH] update _self in help

---
 check_apache_requests  |  2 +-
 check_ceph_diskfree    |  2 +-
 check_ceph_io          |  2 +-
 check_ceph_osd         |  2 +-
 check_ceph_status      |  2 +-
 check_clientbackup     |  2 +-
 check_cpu              |  2 +-
 check_cronstatus       |  2 +-
 check_disk-io          |  2 +-
 check_dns_responsetime |  2 +-
 check_eol              | 60 ++++++++++++++++++++++++------------------
 check_fs_errors        |  2 +-
 check_fs_writable      |  2 +-
 13 files changed, 46 insertions(+), 38 deletions(-)

diff --git a/check_apache_requests b/check_apache_requests
index 481704a..335ee6f 100755
--- a/check_apache_requests
+++ b/check_apache_requests
@@ -41,7 +41,7 @@ paramsWget="-T 5 -t 1 --no-check-certificate"
 # ----------------------------------------------------------------------
 
 function showHelp(){
-    local _self=$(basename $0)
+    local _self; _self=$(basename $0)
     cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_ceph_diskfree b/check_ceph_diskfree
index 5f5253a..9d0459c 100755
--- a/check_ceph_diskfree
+++ b/check_ceph_diskfree
@@ -31,7 +31,7 @@ typeset -i iCritical=0
 self_APPVERSION=1.5
 
 function showHelp(){
-    local _self=$(basename $0)
+    local _self; _self=$(basename $0)
     cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_ceph_io b/check_ceph_io
index cf1701f..dce7617 100755
--- a/check_ceph_io
+++ b/check_ceph_io
@@ -26,7 +26,7 @@
 self_APPVERSION=1.4
 
 function showHelp(){
-    local _self=$(basename $0)
+    local _self; _self=$(basename $0)
     cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_ceph_osd b/check_ceph_osd
index d5c4522..f2f0a67 100755
--- a/check_ceph_osd
+++ b/check_ceph_osd
@@ -41,7 +41,7 @@ iColUpDown=5
 # ----------------------------------------------------------------------
 
 function showHelp(){
-    local _self=$(basename $0)
+    local _self; _self=$(basename $0)
     cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_ceph_status b/check_ceph_status
index 3e8b6bd..2a2959f 100755
--- a/check_ceph_status
+++ b/check_ceph_status
@@ -43,7 +43,7 @@ line="__________________________________________________________________________
 # ----------------------------------------------------------------------
 
 function showHelp(){
-    _self=$(basename $0)
+    local _self; _self=$(basename $0)
 cat <<EOF
 ______________________________________________________________________
 
diff --git a/check_clientbackup b/check_clientbackup
index a3aad97..be1f56d 100755
--- a/check_clientbackup
+++ b/check_clientbackup
@@ -31,7 +31,7 @@ sInstalldir=/opt/imlbackup/client/
 # ----------------------------------------------------------------------
 
 function showHelp(){
-    local _self=$(basename $0)
+    local _self; _self=$(basename $0)
     cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_cpu b/check_cpu
index 3e160ce..034bb71 100755
--- a/check_cpu
+++ b/check_cpu
@@ -35,7 +35,7 @@ self_APPVERSION=1.14
 # ----------------------------------------------------------------------
 
 function showHelp(){
-    local _self=$(basename $0)
+    local _self; _self=$(basename $0)
     cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_cronstatus b/check_cronstatus
index ffc4b1d..0fd56b5 100755
--- a/check_cronstatus
+++ b/check_cronstatus
@@ -37,7 +37,7 @@ statusScript=/opt/cronwrapper/cronstatus.sh
 # ----------------------------------------------------------------------
 
 function showHelp(){
-    local _self=$(basename $0)
+    local _self; _self=$(basename $0)
     cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_disk-io b/check_disk-io
index 4dcdc25..8b8fece 100755
--- a/check_disk-io
+++ b/check_disk-io
@@ -45,7 +45,7 @@ function getDisks(){
 
 # show help
 function showHelp(){
-    local _self=$(basename $0)
+    local _self; _self=$(basename $0)
     cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_dns_responsetime b/check_dns_responsetime
index 88d07d9..d468953 100755
--- a/check_dns_responsetime
+++ b/check_dns_responsetime
@@ -37,7 +37,7 @@ typeset -i iNotReachable=0
 
 # show help
 function showHelp(){
-    local _self=$(basename $0)
+    local _self; _self=$(basename $0)
     cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_eol b/check_eol
index 37e7328..c471ed5 100755
--- a/check_eol
+++ b/check_eol
@@ -43,18 +43,19 @@
 #
 # ----------------------------------------------------------------------
 # 2020-02-21  v1.0  <axel.hahn@iml.unibe.ch>
-# 2020-03-05  v1.1  <axel.hahn@iml.unibe.ch> switch to ph.* helper functions
-# 2021-03-26  v1.2  <axel.hahn@iml.unibe.ch> test major version if minor version was not detected
-# 2021-11-02  v1.3  <axel.hahn@iml.unibe.ch> detect centos stream
-# 2022-02-28  v1.4  <axel.hahn@iml.unibe.ch> remove negative performance data
-# 2022-08-29  v1.5  <axel.hahn@iml.unibe.ch> fix help; shell syntax updates 
-# 2023-01-30  v1.6  <axel.hahn@unibe.ch>     add max value in performance data
+# 2020-03-05  v1.1  <axel.hahn@iml.unibe.ch>  switch to ph.* helper functions
+# 2021-03-26  v1.2  <axel.hahn@iml.unibe.ch>  test major version if minor version was not detected
+# 2021-11-02  v1.3  <axel.hahn@iml.unibe.ch>  detect centos stream
+# 2022-02-28  v1.4  <axel.hahn@iml.unibe.ch>  remove negative performance data
+# 2022-08-29  v1.5  <axel.hahn@iml.unibe.ch>  fix help; shell syntax updates 
+# 2023-01-30  v1.6  <axel.hahn@unibe.ch>      add max value in performance data
+# 2023-07-27  v1.7  <axel.hahn@unibe.ch>      update help page
 # ======================================================================
 
 . "$( dirname $0 )/inc_pluginfunctions"
 eolcfg="${0}-data/*.cfg"
 
-_version="1.5"
+self_APPVERSION=1.7
 
 # --- limits
 typeset -i iDaysWarn=365
@@ -110,8 +111,8 @@ function getDaysLeft(){
     local mydate=$1
     echo $mydate | grep "[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]" >/dev/null
     if [ $? -eq 0 ]; then
-        typeset -i local tsend=$(date --date="$mydate" +%s)
-        typeset -i local daysLeft=($tsend - $(date +%s))/60/60/24
+        typeset -i tsend;     tsend=$(date --date="$mydate" +%s)
+        typeset -i daysLeft;  daysLeft=($tsend - $(date +%s))/60/60/24
         echo $daysLeft
     fi
 }
@@ -138,22 +139,10 @@ function findEolDate(){
 
 }
 
-# ----------------------------------------------------------------------
-# MAIN
-# ----------------------------------------------------------------------
-
-# --- no param? show help
-
-if [ $# -lt 2 ]; then
-    _self=$( basename $0 )
-    cat <<EOH
-______________________________________________________________________
-
-CHECK EOL :: v${_version}
-
-(c) Institute for Medical Education - University of Bern
-Licence: GNU GPL 3
-______________________________________________________________________
+function showHelp(){
+    local _self; _self=$(basename $0)
+    cat <<EOF
+$( ph.showImlHelpHeader )
 
 Check and of support of an OS or a product.
 The dates are defined in the files check_eol-*.cfg
@@ -183,8 +172,27 @@ EXAMPLES
   $_self os detect
   $_self php detect
 
-EOH
+EOF
+}
+
+# ----------------------------------------------------------------------
+# MAIN
+# ----------------------------------------------------------------------
 
+# --- no param? show help
+
+# --- check param -h
+case "$1" in
+    "--help"|"-h")
+        showHelp
+        exit 0
+        ;;
+    *)
+esac
+
+if [ $# -lt 2 ]; then
+    echo "ERROR: Not enough parameters."
+    showHelp
     ph.abort
 fi
 
diff --git a/check_fs_errors b/check_fs_errors
index 426c186..9638553 100755
--- a/check_fs_errors
+++ b/check_fs_errors
@@ -24,7 +24,7 @@ self_APPVERSION=1.2
 # ----------------------------------------------------------------------
 
 function showHelp(){
-    local _self=$(basename $0)
+    local _self; _self=$(basename $0)
     cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_fs_writable b/check_fs_writable
index 9470f60..a5578f6 100755
--- a/check_fs_writable
+++ b/check_fs_writable
@@ -24,7 +24,7 @@ out=""
 # ----------------------------------------------------------------------
 
 function showHelp(){
-    _self=$(basename $0)
+    local _self; _self=$(basename $0)
 cat <<EOF
 $( ph.showImlHelpHeader )
 
-- 
GitLab