diff options
author | Paweł Krupa <pawel@krupa.net.pl> | 2018-09-12 23:47:56 +0200 |
---|---|---|
committer | Costa Tsaousis <costa@tsaousis.gr> | 2018-09-13 00:47:56 +0300 |
commit | c592cea960f46a37fabd63bce657eeed55c31840 (patch) | |
tree | 7ea9effd5f2581aa3e51cc7865dd83ac936c1e94 /contrib | |
parent | 0426209eadb5ea4a8ad473b811b0366b7c0d8c80 (diff) |
shellcheck in contrib (#4160)
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/nc-backend.sh | 12 | ||||
-rwxr-xr-x | contrib/rhel/build-netdata-rpm.sh | 5 |
2 files changed, 10 insertions, 7 deletions
diff --git a/contrib/nc-backend.sh b/contrib/nc-backend.sh index eb8f82919f..2277faaa2b 100755 --- a/contrib/nc-backend.sh +++ b/contrib/nc-backend.sh @@ -26,7 +26,7 @@ mync() { listen_save_replay_forever() { local file="${1}" port="${2}" real_backend_host="${3}" real_backend_port="${4}" ret delay=1 started ended - while [ 1 ] + while true do log "Starting nc to listen on port ${port} and save metrics to ${file}" @@ -36,7 +36,7 @@ listen_save_replay_forever() { if [ -s "${file}" ] then - if [ ! -z "${real_backend_host}" -a ! -z "${real_backend_port}" ] + if [ ! -z "${real_backend_host}" ] && [ ! -z "${real_backend_port}" ] then log "Attempting to send the metrics to the real backend at ${real_backend_host}:${real_backend_port}" @@ -78,6 +78,7 @@ if [ "${MODE}" = "start" ] # only one can use the same file/port at a time { flock -n 9 + # shellcheck disable=SC2181 if [ $? -ne 0 ] then log "Cannot get exclusive lock on file ${FILE}.lock - Am I running multiple times?" @@ -87,7 +88,7 @@ if [ "${MODE}" = "start" ] # save our PID to the lock file echo "$$" >"${FILE}.lock" - listen_save_replay_forever "${FILE}" ${MY_PORT} ${BACKEND_HOST} ${BACKEND_PORT} + listen_save_replay_forever "${FILE}" "${MY_PORT}" "${BACKEND_HOST}" "${BACKEND_PORT}" ret=$? log "listener exited." @@ -104,11 +105,12 @@ elif [ "${MODE}" = "stop" ] { flock -n 9 + # shellcheck disable=SC2181 if [ $? -ne 0 ] then - pid=$(<${FILE}.lock) + pid=$(<"${FILE}".lock) log "Killing process ${pid}..." - kill -TERM -${pid} + kill -TERM "-${pid}" exit 0 fi diff --git a/contrib/rhel/build-netdata-rpm.sh b/contrib/rhel/build-netdata-rpm.sh index efd5c42d64..927318fb12 100755 --- a/contrib/rhel/build-netdata-rpm.sh +++ b/contrib/rhel/build-netdata-rpm.sh @@ -3,7 +3,8 @@ # docker run -it --rm centos:6.9 /bin/sh # yum -y install rpm-build redhat-rpm-config yum-utils autoconf automake curl gcc git libmnl-devel libuuid-devel make pkgconfig zlib-devel -cd $(dirname $0)/../../ || exit 1 +cd "$(dirname "$0")/../../" || exit 1 +# shellcheck disable=SC1091 source "installer/functions.sh" || exit 1 set -e @@ -27,7 +28,7 @@ then fi srpm=$(run rpmbuild -ts "${tgz}" | cut -d ' ' -f 2) -if [ -z "${srpm}" -o ! -f "${srpm}" ] +if [ -z "${srpm}" ] || [ ! -f "${srpm}" ] then echo >&2 "Cannot find the generated SRPM file '${srpm}'" exit 1 |