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

reverse return code in ph.hasParamoption

parent 42b157db
No related branches found
No related tags found
1 merge request!157reverse return code in ph.hasParamoption
...@@ -20,11 +20,12 @@ ...@@ -20,11 +20,12 @@
# 2021-06-24 v0.2 <axel.hahn@iml.unibe.ch> check if query cache is enabled as a shared function # 2021-06-24 v0.2 <axel.hahn@iml.unibe.ch> check if query cache is enabled as a shared function
# 2023-06-06 v0.3 <axel.hahn@unibe.ch> some shell fixes # 2023-06-06 v0.3 <axel.hahn@unibe.ch> some shell fixes
# 2023-07-28 v1.0 <axel.hahn@unibe.ch> update help page; fix [client]: command not found # 2023-07-28 v1.0 <axel.hahn@unibe.ch> update help page; fix [client]: command not found
# 2023-08-30 v1.1 <axel.hahn@unibe.ch> reverse return code in ph.hasParamoption to unix like return codes: 0=true; <>0 = false
# ====================================================================== # ======================================================================
. $( dirname $0 )/inc_pluginfunctions . $( dirname $0 )/inc_pluginfunctions
export self_APPVERSION=1.0 export self_APPVERSION=1.1
# --- set HOME # --- set HOME
HOME=/etc/icingaclient HOME=/etc/icingaclient
...@@ -194,12 +195,12 @@ function _verify_cache(){ ...@@ -194,12 +195,12 @@ function _verify_cache(){
# MAIN # MAIN
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
bOptInstall=$( ph.hasParamoption "i" "$@") ph.hasParamoption "i" "$@"; bOptInstall=$?
bOptUninstall=$( ph.hasParamoption "u" "$@") ph.hasParamoption "u" "$@"; bOptUninstall=$?
bOptHelp=$( ph.hasParamoption "h" "$@") ph.hasParamoption "h" "$@"; bOptHelp=$?
if [ $bOptHelp -eq 1 -o $# -lt 1 ]; then if [ $bOptHelp -eq 0 -o $# -lt 1 ]; then
showHelp echo "showHelp"
exit 0 exit 0
fi fi
...@@ -207,7 +208,7 @@ fi ...@@ -207,7 +208,7 @@ fi
ph.require mysql ph.require mysql
# --- install # --- install
if [ $bOptInstall -eq 1 -a "$( whoami )" = "root" ]; then if [ $bOptInstall -eq 0 -a "$( whoami )" = "root" ]; then
if [ -f $cfgfile ]; then if [ -f $cfgfile ]; then
ph.status "SKIP installation. config file already exists: $cfgfile." ph.status "SKIP installation. config file already exists: $cfgfile."
ph.exit ph.exit
...@@ -223,7 +224,7 @@ if [ $bOptInstall -eq 1 -a "$( whoami )" = "root" ]; then ...@@ -223,7 +224,7 @@ if [ $bOptInstall -eq 1 -a "$( whoami )" = "root" ]; then
fi fi
# --- uninstall # --- uninstall
if [ $bOptUninstall -eq 1 -a "$( whoami )" = "root" ]; then if [ $bOptUninstall -eq 0 -a "$( whoami )" = "root" ]; then
HOME=/root HOME=/root
_uninstall _uninstall
......
...@@ -14,17 +14,18 @@ ...@@ -14,17 +14,18 @@
# https://www.postgresql.org/docs/current/monitoring-stats.html # https://www.postgresql.org/docs/current/monitoring-stats.html
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# 2023-06-07 v0.2 <axel.hahn@unibe.ch> # 2023-06-07 v0.2 <axel.hahn@unibe.ch>
# 2023-06-08 v0.3 <axel.hahn@unibe.ch> show unknown if database connection fails # 2023-06-08 v0.3 <axel.hahn@unibe.ch> show unknown if database connection fails
# 2023-06-08 v0.4 <axel.hahn@unibe.ch> get summary for cronflicts and problems # 2023-06-08 v0.4 <axel.hahn@unibe.ch> get summary for cronflicts and problems
# 2023-06-09 v0.5 <axel.hahn@unibe.ch> deltaunit can be set as parameter # 2023-06-09 v0.5 <axel.hahn@unibe.ch> deltaunit can be set as parameter
# 2023-06-13 v0.6 <axel.hahn@unibe.ch> no output on activity; update replication check # 2023-06-13 v0.6 <axel.hahn@unibe.ch> no output on activity; update replication check
# 2023-06-16 v0.7 <axel.hahn@unibe.ch> update help text # 2023-06-16 v0.7 <axel.hahn@unibe.ch> update help text
# 2023-08-30 v0.8 <axel.hahn@unibe.ch> reverse return code in ph.hasParamoption to unix like return codes: 0=true; <>0 = false
# ====================================================================== # ======================================================================
. $(dirname $0)/inc_pluginfunctions . $(dirname $0)/inc_pluginfunctions
self_APPNAME=$( basename $0 | tr [:lower:] [:upper:] ) self_APPNAME=$( basename $0 | tr [:lower:] [:upper:] )
self_APPVERSION=0.7 self_APPVERSION=0.8
# --- other vars... # --- other vars...
cfgfile=/etc/icingaclient/.psql.conf cfgfile=/etc/icingaclient/.psql.conf
...@@ -176,11 +177,11 @@ function renderCounters(){ ...@@ -176,11 +177,11 @@ function renderCounters(){
# MAIN # MAIN
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
bOptInstall=$( ph.hasParamoption "i" "$@") ph.hasParamoption "i" "$@"; bOptInstall=$?
bOptUninstall=$( ph.hasParamoption "u" "$@") ph.hasParamoption "u" "$@"; bOptUninstall=$?
bOptHelp=$( ph.hasParamoption "h" "$@") ph.hasParamoption "h" "$@"; bOptHelp=$?
if [ $bOptHelp -eq 1 -o $# -lt 1 ]; then if [ $bOptHelp -eq 0 -o $# -lt 1 ]; then
_usage _usage
exit 0 exit 0
fi fi
...@@ -189,7 +190,7 @@ fi ...@@ -189,7 +190,7 @@ fi
# ph.require mysql # ph.require mysql
# --- install # --- install
if [ $bOptInstall -eq 1 -a "$( whoami )" = "root" ]; then if [ $bOptInstall -eq 0 -a "$( whoami )" = "root" ]; then
if [ -f $cfgfile ]; then if [ -f $cfgfile ]; then
ph.status "SKIP installation. config file already exists: $cfgfile." ph.status "SKIP installation. config file already exists: $cfgfile."
ph.exit ph.exit
...@@ -203,7 +204,7 @@ if [ $bOptInstall -eq 1 -a "$( whoami )" = "root" ]; then ...@@ -203,7 +204,7 @@ if [ $bOptInstall -eq 1 -a "$( whoami )" = "root" ]; then
fi fi
# --- uninstall # --- uninstall
if [ $bOptUninstall -eq 1 -a "$( whoami )" = "root" ]; then if [ $bOptUninstall -eq 0 -a "$( whoami )" = "root" ]; then
_uninstall _uninstall
rm -f $cfgfile rm -f $cfgfile
......
...@@ -186,7 +186,7 @@ This will set variable iWarnLimit based on CLI parameter -w [value] ... if it do ...@@ -186,7 +186,7 @@ This will set variable iWarnLimit based on CLI parameter -w [value] ... if it do
### ph.hasParamoption ### ph.hasParamoption
check if a letter was used as command line option and return as 0 (=no) or 1 (=yes) check if a letter was used as command line option and return as 0 (=true) or 1 (=false)
Syntax: Syntax:
...@@ -201,10 +201,12 @@ Parameters: ...@@ -201,10 +201,12 @@ Parameters:
Example: Example:
Show a help if command line param ``-h`` was given - or no parameter.
```bash ```bash
bOptHelp=`ph.hasParamoption "h" "$@"` ph.hasParamoption "h" "$@" ; bOptHelp=$?
if [ $bOptHelp -eq 1 -o $# -lt 1 ]; then if [ $bOptHelp -eq 0 -o $# -lt 1 ]; then
_usage _usage
exit 0 exit 0
fi fi
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
# 2023-05-17 v1.10 <axel.hahn@unibe.ch> ph.getOS searches in os-release first # 2023-05-17 v1.10 <axel.hahn@unibe.ch> ph.getOS searches in os-release first
# 2023-06-22 v1.11 <axel.hahn@unibe.ch> fix ph.toUnit with float values; shell fixes # 2023-06-22 v1.11 <axel.hahn@unibe.ch> fix ph.toUnit with float values; shell fixes
# 2023-08-24 v1.12 <axel.hahn@unibe.ch> toUnit got 3rd param for count of digits after "." # 2023-08-24 v1.12 <axel.hahn@unibe.ch> toUnit got 3rd param for count of digits after "."
# 2023-08-30 v1.13 <axel.hahn@unibe.ch> reverse return code in ph.hasParamoption to unix like return codes: 0=true; <>0 = false
# ====================================================================== # ======================================================================
...@@ -169,13 +170,13 @@ function ph.hasParamoption(){ ...@@ -169,13 +170,13 @@ function ph.hasParamoption(){
# echo "DEBUG: testing $_sParam in ${_opt} ..." # echo "DEBUG: testing $_sParam in ${_opt} ..."
case "${_opt}" in case "${_opt}" in
"$_sParam") "$_sParam")
echo "1" # echo "0"
return 1 return 0
;; ;;
esac esac
done done
echo "0" # echo "1"
return 0 return 1
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment