use which or command -v to search for commands in the system path
Costa Tsaousis (ktsaou) committed
Oct 29, 2016 at 00:47 UTC
04e90b1930fc324b2d767e6cac03edc8be045c27
6 files changed
+6
-6
charts.d/mysql.chart.sh
+1
-1
@@ -55,7 +55,7 @@ mysql_check() {
55
shift
56
fi
57
58
- [ -z "${mysql_cmd}" ] && mysql_cmd="$(which mysql)"
58
+ [ -z "${mysql_cmd}" ] && mysql_cmd="$(which mysql 2>/dev/null || command -v mysql 2>/dev/null)"
59
60
if [ ${#mysql_opts[@]} -eq 0 ]
61
then
charts.d/postfix.chart.sh
+1
-1
@@ -23,7 +23,7 @@ postfix_check() {
23
# try to find the postqueue executable
24
if [ -z "$postfix_postqueue" -o ! -x "$postfix_postqueue" ]
25
then
26
- postfix_postqueue="`which postqueue 2>/dev/null`"
26
+ postfix_postqueue="$(which postqueue 2>/dev/null || command -v postqueue 2>/dev/null)"
27
fi
28
29
if [ -z "$postfix_postqueue" -o ! -x "$postfix_postqueue" ]
netdata-installer.sh
+1
-1
@@ -561,7 +561,7 @@ if [ ${UID} -eq 0 ]
561
if [ $? -ne 0 ]
562
then
563
echo >&2 "Adding netdata user account ..."
564
- run useradd -r -g netdata -c netdata -s $(which nologin || echo '/bin/false') -d / netdata
564
+ run useradd -r -g netdata -c netdata -s $(which nologin 2>/dev/null || command -v nologin 2>/dev/null || echo '/bin/false') -d / netdata
565
fi
566
567
getent group docker > /dev/null
plugins.d/fping.plugin
+1
-1
@@ -80,7 +80,7 @@ NETDATA_CONFIG_DIR="${NETDATA_CONFIG_DIR-/etc/netdata}"
80
81
# the fping binary to use
82
# we need one that can output netdata friendly info
83
-fping="$(which fping || command -v fping)"
83
+fping="$(which fping 2>/dev/null || command -v fping 2>/dev/null )"
84
85
# a space separated list of hosts to fping
86
hosts=""
plugins.d/loopsleepms.sh.inc
+1
-1
@@ -1,6 +1,6 @@
1
# no need for shebang - this file is included from other scripts
2
3
-LOOPSLEEP_DATE="$(which date)"
3
+LOOPSLEEP_DATE="$(which date 2>/dev/null || command -v date 2>/dev/null)"
4
if [ -z "$LOOPSLEEP_DATE" ]
5
then
6
echo >&2 "$0: ERROR: Cannot find the command 'date' in the system path."
plugins.d/tc-qos-helper.sh
+1
-1
@@ -58,7 +58,7 @@ plugins_dir="${NETDATA_PLUGINS_DIR}"
58
[ -z "$plugins_dir" ] && plugins_dir="$( dirname $PROGRAM_FILE )"
59
60
config_dir=${NETDATA_CONFIG_DIR-/etc/netdata}
61
-tc="$(which tc 2>/dev/null)"
61
+tc="$(which tc 2>/dev/null || command -v tc 2>/dev/null)"
62
fireqos_run_dir="/var/run/fireqos"
63
qos_get_class_names_every=120
64
qos_exit_every=3600