From bf3f13dceb8c99cd05010c696aadd0d602afa8c7 Mon Sep 17 00:00:00 2001 From: BDR Date: Mon, 29 Mar 2021 22:34:49 +0200 Subject: [PATCH] Quote every variables --- checks.list | 4 ++-- tinystatus | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/checks.list b/checks.list index 7375b0b..afa77ab 100644 --- a/checks.list +++ b/checks.list @@ -1,6 +1,6 @@ http | 200 | Google website | https://google.com -http4 | 200 | Google website (IPv4) | https://google.com -http6 | 200 | Google website (IPv6) | https://google.com +http4 | 200 | Google Website (IPv4) | https://google.com +http6 | 200 | Google Website (IPv6) | https://google.com http | 404 | Google 404 | https://google.com/dummy ping | 0 | Google ping | 8.8.8.8 port | 0 | Google dns | 8.8.8.8 53 diff --git a/tinystatus b/tinystatus index 838370b..8bec07e 100755 --- a/tinystatus +++ b/tinystatus @@ -31,15 +31,15 @@ check(){ ping*) ping -W${IPv} "${timeout}" -c 1 "${host}" >/dev/null 2>&1 statuscode=$? - [ ${statuscode} -ne ${expectedcode} ] && echo 'Host unreachable' > "${tmp}/ko/${name}.error";; + [ "${statuscode}" -ne "${expectedcode}" ] && echo 'Host unreachable' > "${tmp}/ko/${name}.error";; port*) error="$(nc -w${IPv} "${timeout}" -zv ${host} 2>&1)" statuscode=$? - [ ${statuscode} -ne ${expectedcode} ] && echo "${error}" > "${tmp}/ko/${name}.error";; + [ "${statuscode}" -ne "${expectedcode}" ] && echo "${error}" > "${tmp}/ko/${name}.error";; esac # verity status and write files - if [ ${statuscode} -eq ${expectedcode} ]; then + if [ "${statuscode}" -eq "${expectedcode}" ]; then echo "Status code: ${statuscode}" > "${tmp}/ok/${name}.status" else echo "Status code: ${statuscode}" > "${tmp}/ko/${name}.status" @@ -55,7 +55,7 @@ command_exists 'curl' command_exists 'nc' mkdir -p "${tmp}/ok" "${tmp}/ko" || exit 1 -while IFS='\n' read -r line; do +while IFS="$(printf '\n')" read -r line; do ctype="$(get_element 1 "${line}")" code="$(get_element 2 "${line}")" name="$(get_element 3 "${line}")" @@ -83,8 +83,8 @@ li { list-style: none; margin-bottom: 2px; padding: 5px; border-bottom: 1px soli

Global status

EOF -outagenb=$(find ${tmp}/ko -mindepth 1 | grep -c 'status$') -if [ ${outagenb} -ne 0 ]; then +outagenb="$(find "${tmp}/ko" -mindepth 1 | grep -c 'status$')" +if [ "${outagenb}" -ne 0 ]; then echo "" else echo "" @@ -93,13 +93,13 @@ cat << EOF

Services