Skip to content
Snippets Groups Projects
Commit a9f7f74a authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

eol: fix help; shell syntax updates

parent dab2cee1
No related branches found
No related tags found
1 merge request!33Update EOL help and docs
......@@ -47,12 +47,13 @@
# 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
# ======================================================================
. `dirname $0`/inc_pluginfunctions
. "$( dirname $0 )/inc_pluginfunctions"
eolcfg="${0}-data/*.cfg"
_version="1.3"
_version="1.5"
# --- limits
typeset -i iDaysWarn=365
......@@ -89,7 +90,7 @@ function autodetect(){
# --- stop 2: find version number
detectorPlugin="$0-versiondetect/detect-$myKey"
if [ -x "$detectorPlugin" ]; then
myVersion=`. "$detectorPlugin"`
myVersion=$(. "$detectorPlugin")
fi
if [ -z "$myVersion" ]; then
ph.abort "UNKNOWN: [$myKey] was not detected properly. It is unknown or output for version cannot be parsed."
......@@ -108,8 +109,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 local tsend=$(date --date="$mydate" +%s)
typeset -i local daysLeft=($tsend - $(date +%s))/60/60/24
echo $daysLeft
fi
}
......@@ -125,7 +126,7 @@ function findEolDate(){
local bContinue=0
while [ $bContinue = 0 ]; do
myVerKey=$( echo $myVerKey | rev | cut -f 2- -d "." | rev )
line=`grep "^$myKey:$myVerKey:" $eolcfg | sort -n | tail -1`
line=$(grep "^$myKey:$myVerKey:" $eolcfg | sort -n | tail -1)
test -z "$line" || bContinue=1
echo $myVerKey | grep "\." >/dev/null || bContinue=1
......@@ -143,6 +144,7 @@ function findEolDate(){
# --- no param? show help
if [ $# -lt 2 ]; then
_self=$( basename $0 )
cat <<EOH
______________________________________________________________________
......@@ -154,15 +156,15 @@ ______________________________________________________________________
Check and of support of an OS or a product.
The dates are defined in the files check_eol-*.cfg
For detailed information see `basename $0`.md
For detailed information see docs/20_Checks/check_eol.md
USAGE
$ `basename $0` [-c CRITICAL] [-w WARING] PRODUCT VERSION
$ $_self [-c CRITICAL] [-w WARING] PRODUCT VERSION
PARAMETERS
PRODUCT set a product; known product keys are listed below
`grep "^[a-zA-Z]" $eolcfg | cut -f 2 -d ":" | sort -un | sed "s#^# #g"`
$( grep "^[a-zA-Z]" $eolcfg | cut -f 2 -d ":" | sort -u | sed "s#^# #g" )
VERSION set a version.
Autodetection:
......@@ -175,10 +177,10 @@ OPTIONS
-w set warning limit; default $iDaysWarn
EXAMPLES
`basename $0` php 7.4
`basename $0` -w 100 -c 30 php 7.4
`basename $0` os detect
`basename $0` php detect
$_self php 8.1
$_self -w 100 -c 30 php 8.1
$_self os detect
$_self php detect
EOH
......@@ -228,18 +230,18 @@ if [ -z "$eol" ]; then
echo
grep "^$myKey:" $eolcfg | grep -v ":$myKey:[0-9]" | cut -f 3- -d ":"
echo
echo "Maybe an admin can add the version in `grep -l "^$myKey:" $eolcfg`"
echo "Maybe an admin can add the version in $(grep -l "^$myKey:" $eolcfg)"
echo "Existing/ known versions are:"
grep "^$myKey:[0-9]" $eolcfg | cut -f 3 -d ":" | sort -un
else
echo "The product key [$myKey] was not detected in any version."
fi
else
myEolVer=`echo $eol | cut -f 3 -d ":"`
myEolEnd=`echo $eol | cut -f 4 -d ":"`
myComment=`echo $eol | cut -f 5 -d ":"`
myEolVer=$(echo $eol | cut -f 3 -d ":")
myEolEnd=$(echo $eol | cut -f 4 -d ":")
myComment=$(echo $eol | cut -f 5 -d ":")
myDaysLeft=`getDaysLeft $myEolEnd`
myDaysLeft=$(getDaysLeft $myEolEnd)
# --- verify days left with limits
ph.setStatus "ok"
if [ $myDaysLeft -lt $iDaysWarn ]; then
......@@ -251,7 +253,7 @@ else
if [ $myDaysLeft -ge 0 ]; then
ph.status "[$myKey $myEolVer] ends on $myEolEnd ... $myDaysLeft days left $myComment"
else
echo "[$myKey $myEolVer] ended on $myEolEnd ... `echo $myDaysLeft | sed 's#\-##'` days EXPIRED ALREADY !!! $myComment"
echo "[$myKey $myEolVer] ended on $myEolEnd ... $(echo $myDaysLeft | sed 's#\-##') days EXPIRED ALREADY !!! $myComment"
fi
echo
grep "^$myKey:" $eolcfg | grep -v ":$myKey:[0-9]" | cut -f 3- -d ":"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment