@cryptotaxi247 / netdata-1 / commits / f722c9d56

shellcheck bash scripts starting on A; disable shebang checking in all (#4159)

scripts; set shell without shebang

Paweł Krupa committed Sep 13, 2018 at 00:25 UTC f722c9d567457920c6884ece8f7608ce1e77d270
20 files changed +49 -27
charts.d/ap.chart.sh
+4 -3
@@ -1,3 +1,4 @@
1 +# shellcheck shell=bash
2 # no need for shebang - this file is loaded from charts.d.plugin
3 # SPDX-License-Identifier: GPL-3.0+
4
@@ -16,8 +17,8 @@ declare -A ap_devs=()
17 # _check is called once, to find out if this chart should be enabled or not
18 ap_check() {
19 require_cmd iw || return 1
19 -
20 - local ev=$(run iw dev | awk '
20 + local ev
21 + ev=$(run iw dev | awk '
22 BEGIN {
23 i = "";
24 ssid = "";
@@ -102,7 +103,7 @@ ap_update() {
103 do
104 echo
105 echo "DEVICE ${dev}"
105 - iw ${dev} station dump
106 + iw "${dev}" station dump
107 done | awk "
108 function zero_data() {
109 dev = \"\";
charts.d/apache.chart.sh
+24 -23
@@ -1,3 +1,4 @@
1 +# shellcheck shell=bash
2 # no need for shebang - this file is loaded from charts.d.plugin
3 # SPDX-License-Identifier: GPL-3.0+
4
@@ -82,12 +83,11 @@ apache_detect() {
83 [ -z "${apache_key_idleworkers}" ] && error "missing 'IdleWorkers' from apache server: ${*}" && return 1
84 [ -z "${apache_key_scoreboard}" ] && error "missing 'Scoreboard' from apache server: ${*}" && return 1
85
85 - if [ ! -z "${apache_key_connstotal}" \
86 - -a ! -z "${apache_key_connsasyncwriting}" \
87 - -a ! -z "${apache_key_connsasynckeepalive}" \
88 - -a ! -z "${apache_key_connsasyncclosing}" \
89 - ]
90 - then
86 + if [ ! -z "${apache_key_connstotal}" ] && \
87 + [ ! -z "${apache_key_connsasyncwriting}" ] && \
88 + [ ! -z "${apache_key_connsasynckeepalive}" ] && \
89 + [ ! -z "${apache_key_connsasyncclosing}" ]
90 + then
91 apache_has_conns=1
92 else
93 apache_has_conns=0
@@ -98,16 +98,17 @@ apache_detect() {
98
99 apache_get() {
100 local oIFS="${IFS}" ret
101 + # shellcheck disable=2207
102 IFS=$':\n' apache_response=($(run curl -Ss ${apache_curl_opts} "${apache_url}"))
103 ret=$?
104 IFS="${oIFS}"
105
105 - [ $ret -ne 0 -o "${#apache_response[@]}" -eq 0 ] && return 1
106 + ([ $ret -ne 0 ] || [ "${#apache_response[@]}" -eq 0 ]) && return 1
107
108 # the last line on the apache output is "Scoreboard"
109 # we use this label to detect that the output has a new word count
109 - if [ ${apache_keys_detected} -eq 0 -o "${apache_response[${apache_key_scoreboard}]}" != "Scoreboard" ]
110 - then
110 + if [ ${apache_keys_detected} -eq 0 ] || [ "${apache_response[${apache_key_scoreboard}]}" != "Scoreboard" ]
111 + then
112 apache_detect "${apache_response[@]}" || return 1
113 apache_keys_detected=1
114 fi
@@ -127,21 +128,20 @@ apache_get() {
128 apache_busyworkers="${apache_response[${apache_key_busyworkers}]}"
129 apache_idleworkers="${apache_response[${apache_key_idleworkers}]}"
130
130 - if [ -z "${apache_accesses}" \
131 - -o -z "${apache_kbytes}" \
132 - -o -z "${apache_reqpersec}" \
133 - -o -z "${apache_bytespersec}" \
134 - -o -z "${apache_bytesperreq}" \
135 - -o -z "${apache_busyworkers}" \
136 - -o -z "${apache_idleworkers}" \
137 - ]
138 - then
131 + if [ -z "${apache_accesses}" ] || \
132 + [ -z "${apache_kbytes}" ] || \
133 + [ -z "${apache_reqpersec}" ] || \
134 + [ -z "${apache_bytespersec}" ] || \
135 + [ -z "${apache_bytesperreq}" ] || \
136 + [ -z "${apache_busyworkers}" ]
137 + [ -z "${apache_idleworkers}" ]
138 + then
139 error "empty values got from apache server: ${apache_response[*]}"
140 return 1
141 fi
142
143 if [ ${apache_has_conns} -eq 1 ]
144 - then
144 + then
145 apache_connstotal="${apache_response[${apache_key_connstotal}]}"
146 apache_connsasyncwriting="${apache_response[${apache_key_connsasyncwriting}]}"
147 apache_connsasynckeepalive="${apache_response[${apache_key_connsasynckeepalive}]}"
@@ -155,8 +155,10 @@ apache_get() {
155 apache_check() {
156
157 apache_get
158 + # shellcheck disable=2181
159 if [ $? -ne 0 ]
159 - then
160 + then
161 + # shellcheck disable=2154
162 error "cannot find stub_status on URL '${apache_url}'. Please set apache_url='http://apache.server:80/server-status?auto' in $confd/apache.conf"
163 return 1
164 fi
@@ -187,7 +189,7 @@ DIMENSION sent '' incremental 8 1
189 EOF
190
191 if [ ${apache_has_conns} -eq 1 ]
190 - then
192 + then
193 cat <<EOF2
194 CHART apache_local.connections '' "apache Connections" "connections" connections apache.connections line $((apache_priority + 2)) $apache_update_every
195 DIMENSION connections '' absolute 1 1
@@ -203,7 +205,6 @@ EOF2
205
206 # _update is called continuously, to collect the values
207 apache_update() {
206 - local reqs net
208 # the first argument to this function is the microseconds since last update
209 # pass this parameter to the BEGIN statement (see bellow).
210
@@ -237,7 +238,7 @@ END
238 VALUESEOF
239
240 if [ ${apache_has_conns} -eq 1 ]
240 - then
241 + then
242 cat <<VALUESEOF2
243 BEGIN apache_local.connections $1
244 SET connections = $((apache_connstotal))
charts.d/apcupsd.chart.sh
+4 -1
@@ -1,3 +1,4 @@
1 +# shellcheck shell=bash
2 # no need for shebang - this file is loaded from charts.d.plugin
3 # SPDX-License-Identifier: GPL-3.0+
4
@@ -43,11 +44,12 @@ apcupsd_check() {
44 for host in "${!apcupsd_sources[@]}"
45 do
46 run apcupsd_get "${apcupsd_sources[${host}]}" >/dev/null
47 + # shellcheck disable=2181
48 if [ $? -ne 0 ]
49 then
50 error "cannot get information for apcupsd server ${host} on ${apcupsd_sources[${host}]}."
51 failed=$((failed + 1))
50 - elif [ $(apcupsd_get "${apcupsd_sources[${host}]}" | awk '/^STATUS.*/{ print $3 }') != "ONLINE" ]
52 + elif [ "$(apcupsd_get "${apcupsd_sources[${host}]}" | awk '/^STATUS.*/{ print $3 }')" != "ONLINE" ]
53 then
54 error "APC UPS ${host} on ${apcupsd_sources[${host}]} is not online."
55 failed=$((failed + 1))
@@ -183,6 +185,7 @@ END {
185 print \"SET time = \" time;
186 print \"END\"
187 }"
188 + # shellcheck disable=SC2181
189 if [ $? -ne 0 ]
190 then
191 failed=$((failed + 1))
charts.d/cpu_apps.chart.sh
+1
@@ -1,3 +1,4 @@
1 +# shellcheck shell=bash
2 # no need for shebang - this file is loaded from charts.d.plugin
3 # SPDX-License-Identifier: GPL-3.0+
4
charts.d/cpufreq.chart.sh
+1
@@ -1,3 +1,4 @@
1 +# shellcheck shell=bash
2 # no need for shebang - this file is loaded from charts.d.plugin
3 # SPDX-License-Identifier: GPL-3.0+
4
charts.d/example.chart.sh
+1
@@ -1,3 +1,4 @@
1 +# shellcheck shell=bash
2 # no need for shebang - this file is loaded from charts.d.plugin
3 # SPDX-License-Identifier: GPL-3.0+
4
charts.d/exim.chart.sh
+1
@@ -1,3 +1,4 @@
1 +# shellcheck shell=bash
2 # no need for shebang - this file is loaded from charts.d.plugin
3 # SPDX-License-Identifier: GPL-3.0+
4
charts.d/hddtemp.chart.sh
+1
@@ -1,3 +1,4 @@
1 +# shellcheck shell=bash
2 # no need for shebang - this file is loaded from charts.d.plugin
3 # SPDX-License-Identifier: GPL-3.0+
4
charts.d/libreswan.chart.sh
+1
@@ -1,3 +1,4 @@
1 +# shellcheck shell=bash
2 # no need for shebang - this file is loaded from charts.d.plugin
3 # SPDX-License-Identifier: GPL-3.0+
4
charts.d/load_average.chart.sh
+1
@@ -1,3 +1,4 @@
1 +# shellcheck shell=bash
2 # no need for shebang - this file is loaded from charts.d.plugin
3 # SPDX-License-Identifier: GPL-3.0+
4
charts.d/mem_apps.chart.sh
+1
@@ -1,3 +1,4 @@
1 +# shellcheck shell=bash
2 # no need for shebang - this file is loaded from charts.d.plugin
3 # SPDX-License-Identifier: GPL-3.0+
4
charts.d/mysql.chart.sh
+1
@@ -1,3 +1,4 @@
1 +# shellcheck shell=bash
2 # no need for shebang - this file is loaded from charts.d.plugin
3 # SPDX-License-Identifier: GPL-3.0+
4
charts.d/nginx.chart.sh
+1
@@ -1,3 +1,4 @@
1 +# shellcheck shell=bash
2 # no need for shebang - this file is loaded from charts.d.plugin
3 # SPDX-License-Identifier: GPL-3.0+
4
charts.d/nut.chart.sh
+1
@@ -1,3 +1,4 @@
1 +# shellcheck shell=bash
2 # no need for shebang - this file is loaded from charts.d.plugin
3 # SPDX-License-Identifier: GPL-3.0+
4
charts.d/opensips.chart.sh
+1
@@ -1,3 +1,4 @@
1 +# shellcheck shell=bash
2 # no need for shebang - this file is loaded from charts.d.plugin
3 # SPDX-License-Identifier: GPL-3.0+
4
charts.d/phpfpm.chart.sh
+1
@@ -1,3 +1,4 @@
1 +# shellcheck shell=bash
2 # no need for shebang - this file is loaded from charts.d.plugin
3 # SPDX-License-Identifier: GPL-3.0+
4
charts.d/postfix.chart.sh
+1
@@ -1,3 +1,4 @@
1 +# shellcheck shell=bash
2 # no need for shebang - this file is loaded from charts.d.plugin
3 # SPDX-License-Identifier: GPL-3.0+
4
charts.d/sensors.chart.sh
+1
@@ -1,3 +1,4 @@
1 +# shellcheck shell=bash
2 # no need for shebang - this file is loaded from charts.d.plugin
3 # SPDX-License-Identifier: GPL-3.0+
4
charts.d/squid.chart.sh
+1
@@ -1,3 +1,4 @@
1 +# shellcheck shell=bash
2 # no need for shebang - this file is loaded from charts.d.plugin
3 # SPDX-License-Identifier: GPL-3.0+
4
charts.d/tomcat.chart.sh
+1
@@ -1,3 +1,4 @@
1 +# shellcheck shell=bash
2 # no need for shebang - this file is loaded from charts.d.plugin
3 # SPDX-License-Identifier: GPL-3.0+
4