summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2019-01-06 02:45:13 +0100
committerSuren A. Chilingaryan <csa@suren.me>2019-01-06 02:45:13 +0100
commit4de0f896eed66d1bc63e82dd0c23ea338fbf310a (patch)
tree86b2ae2fef732b06cff037637ef363b53016c407
parent9e063e255c026733e3cf057a38034bd7ab2f1cb1 (diff)
downloadconky-4de0f896eed66d1bc63e82dd0c23ea338fbf310a.tar.gz
conky-4de0f896eed66d1bc63e82dd0c23ea338fbf310a.tar.bz2
conky-4de0f896eed66d1bc63e82dd0c23ea338fbf310a.tar.xz
conky-4de0f896eed66d1bc63e82dd0c23ea338fbf310a.zip
Fix bash errors in case if 'scripts' target is not available in tested ADEI version
-rwxr-xr-xservice/check_adei.sh12
1 files changed, 7 insertions, 5 deletions
diff --git a/service/check_adei.sh b/service/check_adei.sh
index 4edad93..5ef1ebf 100755
--- a/service/check_adei.sh
+++ b/service/check_adei.sh
@@ -76,11 +76,13 @@ size=$(query "$url/info.php?target=size&encoding=text")
if [ $healthy -ne 0 ]; then
scripts=$(query "$url/info.php?target=scripts")
waiting=$(echo $scripts | xmllint --format - | grep "Value" | sed -e "s/^\(.*mtime=\"\([^\"]*\)\".*\)$/\\2\\1/" | awk -v date="$(date +%s)" '{duration=date - $1} duration > 3600 { print duration }' | sort -rn)
- num_waiting=$(echo $waiting | tr ' ' '\n' | wc -l)
- long_waiting=$(echo $waiting | cut -d ' ' -f 1)
- if [ $num_waiting -gt 0 ]; then
- healthy=2
- echo "$num_waiting pending scripts, longest for $(format_time $long_waiting)"
+ if [ -n "$waiting" ]; then
+ num_waiting=$(echo $waiting | tr ' ' '\n' | wc -l)
+ long_waiting=$(echo $waiting | cut -d ' ' -f 1)
+ if [ $num_waiting -gt 0 ]; then
+ healthy=2
+ echo "$num_waiting pending scripts, longest for $(format_time $long_waiting)"
+ fi
fi
fi