From c642b068508c027cc2d594a47620f53f7967e7bf Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@iml.unibe.ch> Date: Mon, 23 Jan 2023 11:18:05 +0100 Subject: [PATCH] some shellfixes; remove grep warnings --- inc_functions.sh | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/inc_functions.sh b/inc_functions.sh index cfd4195..e61265e 100644 --- a/inc_functions.sh +++ b/inc_functions.sh @@ -38,7 +38,7 @@ # params string(s) message to log # function _log(){ - echo "`date` | $*" >> ${logfile} + echo "$(date) | $*" >> "${logfile}" } # echo and logging output @@ -84,14 +84,14 @@ exit 1 fi - if [ ! -d ${dir_checks} ]; then + if [ ! -d "${dir_checks}" ]; then echo "ERROR: config dir for checks dir_checks does not exist: $dir_checks" exit 1 fi - for myconfig in `ls -1 ${dir_checks}/*` + for myconfig in $(ls -1 ${dir_checks}/*) do - echo ${myconfig} + echo "${myconfig}" done } @@ -101,7 +101,7 @@ # checkInterval # param string full path of a config file function _parseCheckConfig(){ - local _myconfig=$1 + local _myconfig="$1" # EXAMPLE a config contains ... # checkname=check_cronstatus @@ -110,11 +110,11 @@ # icon=/images/icon.png # max_check_attempts=3 - checkName=`cat $_myconfig | grep ^checkname= | cut -f 2 -d "=" | sed 's# #_#g'` - checkCommand=`cat $_myconfig | grep ^command= | cut -f 2 -d "="` - checkInterval=`cat $_myconfig | grep ^interval= | cut -f 2 -d "="` - checkIcon=`cat $_myconfig | grep ^icon= | cut -f 2 -d "="` - checkMaxAttempts=`cat $_myconfig | grep ^max_check_attempts= | cut -f 2 -d "="` + checkName=$(cat "$_myconfig" | grep ^checkname= | cut -f 2 -d "=" | sed 's# #_#g') + checkCommand=$(cat "$_myconfig" | grep ^command= | cut -f 2 -d "=") + checkInterval=$(cat "$_myconfig" | grep ^interval= | cut -f 2 -d "=") + checkIcon=$(cat "$_myconfig" | grep ^icon= | cut -f 2 -d "=") + checkMaxAttempts=$(cat "$_myconfig" | grep ^max_check_attempts= | cut -f 2 -d "=") } # ====================================================================== @@ -162,28 +162,28 @@ function _ipf(){ # --- types 'loopback') - _regexInclude='\ scope\ host\ ' + _regexInclude=' scope host ' ;; 'physical') - _regexExclude="(\ scope\ host\ |\ peer\ |\:vip)" + _regexExclude="( scope host | peer |:vip)" ;; 'virtual') - _regexInclude="\:vip" + _regexInclude=":vip" ;; 'net') - _regexInclude='\ scope\ global\ ' + _regexInclude=' scope global ' ;; 'peer') - _regexInclude='\ peer\ .*\ scope\ global\ ' + _regexInclude=' peer .* scope global ' ;; # --- private/ public ips 'private') - _regexInclude="\ ${_privateranges}.*" + _regexInclude=" ${_privateranges}.*" ;; 'public') - _regexInclude="\ scope\ global\ " - _regexExclude="\ ${_privateranges}\.*" + _regexInclude=" scope global " + _regexExclude=" ${_privateranges}\.*" ;; # --- output filter @@ -253,7 +253,7 @@ function _getIpPrivate(){ fi _echo "$( http.getResponseHeader )" - _echo $( http.getResponse ) + _echo "$( http.getResponse )" } @@ -278,7 +278,7 @@ function _getIpPrivate(){ http.makeRequest GET "${_url}" "" - if [ ! -z "`http.isok`" ]; then + if [ ! -z "$(http.isok)" ]; then _wd "OK, Object $_url exists - updating cache file $_outfile" http.responseExport "${_outfile}" else -- GitLab