From 5e554c920def84e8e0d0b9dc29ca0b4109fc48ae Mon Sep 17 00:00:00 2001 From: BDR Date: Sun, 28 Mar 2021 22:14:08 +0200 Subject: [PATCH] Show incidents only if the file exists --- tinystatus | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tinystatus b/tinystatus index 4a30731..4907ffc 100755 --- a/tinystatus +++ b/tinystatus @@ -2,8 +2,10 @@ title=tinystatus timeout=10 -tmp="${tmpdir:-/tmp/tinystatus}" +tmp='/tmp/tinystatus' useragent="User-Agent: Mozilla/5.0 (X11; Linux x86_64; Debian) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36" +checkfile="${1:-checks.list}" +incidentsfile="${2:-incidents.list}" command_exists(){ if ! command -v "${1}" >/dev/null 2>&1; then @@ -104,9 +106,15 @@ done cat << EOF

Last check: $(date +"%Y/%m/%d %H:%M:%S")

-

Incidents

EOF -sed 's|^\(.*\)$|

\1

|' "${2:-incidents.list}" 2>/dev/null || echo "

No incident reported yet ;)

" +if [ -f "${incidentsfile}" ]; then + echo '

Incidents

' + if [ -s "${incidentsfile}" ]; then + sed 's|^\(.*\)$|

\1

|' "${incidentsfile}" + else + echo '

No incident reported yet ;)

' + fi +fi cat <