]> arthur.barton.de Git - netdata.git/commitdiff
use which or command -v to search for commands in the system path
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Fri, 28 Oct 2016 21:47:14 +0000 (00:47 +0300)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Fri, 28 Oct 2016 21:47:14 +0000 (00:47 +0300)
charts.d/mysql.chart.sh
charts.d/postfix.chart.sh
netdata-installer.sh
plugins.d/fping.plugin
plugins.d/loopsleepms.sh.inc
plugins.d/tc-qos-helper.sh

index 86feac997c8ac260d3f8ebc9bf23c5fd7d11e4ba..1363d01f420c1a2ed19f4aabd0a319209030199f 100755 (executable)
@@ -55,7 +55,7 @@ mysql_check() {
                shift
        fi
 
-       [ -z "${mysql_cmd}" ] && mysql_cmd="$(which mysql)"
+       [ -z "${mysql_cmd}" ] && mysql_cmd="$(which mysql 2>/dev/null || command -v mysql 2>/dev/null)"
 
        if [ ${#mysql_opts[@]} -eq 0 ]
                then
index 8106414a1f6da024482f348782bb97e2e5ec0abf..85604fcbe2f6e2fdd30c4c16b26d253f745495c7 100755 (executable)
@@ -23,7 +23,7 @@ postfix_check() {
        # try to find the postqueue executable
        if [ -z "$postfix_postqueue" -o ! -x "$postfix_postqueue" ]
        then
-               postfix_postqueue="`which postqueue 2>/dev/null`"
+               postfix_postqueue="$(which postqueue 2>/dev/null || command -v postqueue 2>/dev/null)"
        fi
 
        if [ -z "$postfix_postqueue" -o ! -x  "$postfix_postqueue" ]
index 930243c4c4d734f14d166092b64461345fad5a66..51c558b6cfc7efdb9b7393084b90e65388257eb6 100755 (executable)
@@ -561,7 +561,7 @@ if [ ${UID} -eq 0 ]
     if [ $? -ne 0 ]
         then
         echo >&2 "Adding netdata user account ..."
-        run useradd -r -g netdata -c netdata -s $(which nologin || echo '/bin/false') -d / netdata
+        run useradd -r -g netdata -c netdata -s $(which nologin 2>/dev/null || command -v nologin 2>/dev/null || echo '/bin/false') -d / netdata
     fi
 
     getent group docker > /dev/null
index 32e1b711444f34584e9a3380ad6f8b4862cbe244..784bf2993e05ebad60b2b96d4860e67f1142f2a5 100755 (executable)
@@ -80,7 +80,7 @@ NETDATA_CONFIG_DIR="${NETDATA_CONFIG_DIR-/etc/netdata}"
 
 # the fping binary to use
 # we need one that can output netdata friendly info
-fping="$(which fping || command -v fping)"
+fping="$(which fping 2>/dev/null || command -v fping 2>/dev/null )"
 
 # a space separated list of hosts to fping
 hosts=""
index 6de93043c93a5e6823bbfc2aced0fcb69ec0224d..4f2e02351d9565035ae06d4bf9e2a1798831f624 100644 (file)
@@ -1,6 +1,6 @@
 # no need for shebang - this file is included from other scripts
 
-LOOPSLEEP_DATE="$(which date)"
+LOOPSLEEP_DATE="$(which date 2>/dev/null || command -v date 2>/dev/null)"
 if [ -z "$LOOPSLEEP_DATE" ]
     then
     echo >&2 "$0: ERROR: Cannot find the command 'date' in the system path."
index ffe995f7d316616e1fc963d97078e9afad26f1b7..7e1e92cf33a27c1cb7bea133970d2cdca238a4d4 100755 (executable)
@@ -58,7 +58,7 @@ plugins_dir="${NETDATA_PLUGINS_DIR}"
 [ -z "$plugins_dir" ] && plugins_dir="$( dirname $PROGRAM_FILE )"
 
 config_dir=${NETDATA_CONFIG_DIR-/etc/netdata}
-tc="$(which tc 2>/dev/null)"
+tc="$(which tc 2>/dev/null || command -v tc 2>/dev/null)"
 fireqos_run_dir="/var/run/fireqos"
 qos_get_class_names_every=120
 qos_exit_every=3600