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

move autodetection for os and mysql to plugin scripts

parent 0f7f56f7
No related branches found
No related tags found
No related merge requests found
......@@ -60,6 +60,7 @@ bDebug=false
myKey=
myVersion=
myEolEnd=
typeset -i myDaysLeft=
......@@ -70,40 +71,21 @@ typeset -i myDaysLeft=
# auto detetct an os or a version based on cli output
# used on param detect*
# global string myKey name of product
# global string myKey name of product
# global string myVersion its version
function autodetect(){
myVersion=
case $myKey in
'os')
# ----- detect operating system and major version
# see inc_pluginfunctions
myKey=`ph.getOS`
myVersion=`ph.getOSMajor`
test "$myKey" = "centos" && grep -i stream /etc/centos-release >/dev/null 2>&1 && myVersion="${myVersion}-stream"
;;
'mysqlany')
local _tmpfile=/tmp/detect_mysql_$$
mysql --version >$_tmpfile 2>&1
if [ $? -ne 0 ]; then
rm -f $_tmpfile
ph.abort "UNKNOWN: mysql was not found. A Mysql version cannot be detected."
fi
# default: mysql
myKey=mysql
# scan for forks:
# todo: add ... percona ... memdb ... whatever
grep "MariaDB" $_tmpfile >/dev/null && myKey=mariadb
rm -f $_tmpfile
;;
*)
# echo ERROR: detection for [$1] is not implemented
esac
# --- step 1: autodetection to find a key for os or software derivat
detectorPlugin="$0-versiondetect/autodetect-$myKey"
if [ -x "$detectorPlugin" ]; then
local mydata=$(. "$detectorPlugin")
myKey=$( echo $mydata | rev | cut -f 2 -d "|" | rev )
myVersion=$( echo $mydata | rev | cut -f 1 -d "|" | rev )
fi
# --- stop 2: find version number
detectorPlugin="$0-versiondetect/detect-$myKey"
if [ -x "$detectorPlugin" ]; then
myVersion=`. "$detectorPlugin"`
......@@ -232,6 +214,7 @@ fi
myKey=$1
myVersion=$2
test $myVersion = "detect" && autodetect $myKey
eol=$( findEolDate "$myKey" "$myVersion" )
if [ -z "$eol" ]; then
......
# ----------------------------------------------------------------------------
#
# EOL - End of life detection - Warn before reaching end of life
#
# AUTODETECT MYSQL OR A FORK OF IT
#
# ----------------------------------------------------------------------------
# 2021-11-02 v1.0 <axel.hahn@iml.unibe.ch>
# ----------------------------------------------------------------------------
_tmpfile=/tmp/detect_mysql_$$
mysql --version >$_tmpfile 2>&1
if [ $? -ne 0 ]; then
rm -f $_tmpfile
ph.abort "UNKNOWN: mysql was not found. A Mysql version cannot be detected."
fi
# ----------------------------------------------------------------------------
# default: mysql
myKey=mysql
# scan for forks:
# todo: add ... percona ... memdb ... whatever
grep "MariaDB" $_tmpfile >/dev/null && myKey=mariadb
rm -f $_tmpfile
# ----------------------------------------------------------------------------
echo "|$myKey|$myVersion"
# ----------------------------------------------------------------------------
#
# EOL - End of life detection - Warn before reaching end of life
#
# AUTODETECT LINUX OS
#
# ----------------------------------------------------------------------------
# 2021-11-02 v1.0 <axel.hahn@iml.unibe.ch>
# ----------------------------------------------------------------------------
myKey=`ph.getOS`
myVersion=`ph.getOSMajor`
case "$mykey" in
centos)
# detect centos stream
grep -i stream /etc/centos-release >/dev/null 2>&1 && myVersion="${myVersion}-stream"
;;
*)
echo no special handling
esac
# ----------------------------------------------------------------------------
echo "|$myKey|$myVersion"
......@@ -12,4 +12,4 @@
# mysql --version
# mysql Ver 15.1 Distrib 5.5.64-MariaDB, for Linux (x86_64) using readline 5.1
mysql --version | grep MariaDB | awk '{ print $5 }' | cut -f 1,2 -d '.'
\ No newline at end of file
mysql --version | grep MariaDB | awk '{ print $5 }' | cut -f 1,2 -d '.'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment