shellcheck in contrib (#4160)
Paweł Krupa committed
Sep 12, 2018 at 23:47 UTC
c592cea960f46a37fabd63bce657eeed55c31840
2 files changed
+10
-7
contrib/nc-backend.sh
+7
-5
@@ -26,7 +26,7 @@ mync() {
26
listen_save_replay_forever() {
27
local file="${1}" port="${2}" real_backend_host="${3}" real_backend_port="${4}" ret delay=1 started ended
28
29
- while [ 1 ]
29
+ while true
30
do
31
log "Starting nc to listen on port ${port} and save metrics to ${file}"
32
@@ -36,7 +36,7 @@ listen_save_replay_forever() {
36
37
if [ -s "${file}" ]
38
then
39
- if [ ! -z "${real_backend_host}" -a ! -z "${real_backend_port}" ]
39
+ if [ ! -z "${real_backend_host}" ] && [ ! -z "${real_backend_port}" ]
40
then
41
log "Attempting to send the metrics to the real backend at ${real_backend_host}:${real_backend_port}"
42
@@ -78,6 +78,7 @@ if [ "${MODE}" = "start" ]
78
# only one can use the same file/port at a time
79
{
80
flock -n 9
81
+ # shellcheck disable=SC2181
82
if [ $? -ne 0 ]
83
then
84
log "Cannot get exclusive lock on file ${FILE}.lock - Am I running multiple times?"
@@ -87,7 +88,7 @@ if [ "${MODE}" = "start" ]
88
# save our PID to the lock file
89
echo "$$" >"${FILE}.lock"
90
90
- listen_save_replay_forever "${FILE}" ${MY_PORT} ${BACKEND_HOST} ${BACKEND_PORT}
91
+ listen_save_replay_forever "${FILE}" "${MY_PORT}" "${BACKEND_HOST}" "${BACKEND_PORT}"
92
ret=$?
93
94
log "listener exited."
@@ -104,11 +105,12 @@ elif [ "${MODE}" = "stop" ]
105
106
{
107
flock -n 9
108
+ # shellcheck disable=SC2181
109
if [ $? -ne 0 ]
110
then
109
- pid=$(<${FILE}.lock)
111
+ pid=$(<"${FILE}".lock)
112
log "Killing process ${pid}..."
111
- kill -TERM -${pid}
113
+ kill -TERM "-${pid}"
114
exit 0
115
fi
116
contrib/rhel/build-netdata-rpm.sh
+3
-2
@@ -3,7 +3,8 @@
3
# docker run -it --rm centos:6.9 /bin/sh
4
# yum -y install rpm-build redhat-rpm-config yum-utils autoconf automake curl gcc git libmnl-devel libuuid-devel make pkgconfig zlib-devel
5
6
-cd $(dirname $0)/../../ || exit 1
6
+cd "$(dirname "$0")/../../" || exit 1
7
+# shellcheck disable=SC1091
8
source "installer/functions.sh" || exit 1
9
10
set -e
@@ -27,7 +28,7 @@ then
28
fi
29
30
srpm=$(run rpmbuild -ts "${tgz}" | cut -d ' ' -f 2)
30
-if [ -z "${srpm}" -o ! -f "${srpm}" ]
31
+if [ -z "${srpm}" ] || [ ! -f "${srpm}" ]
32
then
33
echo >&2 "Cannot find the generated SRPM file '${srpm}'"
34
exit 1