41 lines
641 B
Bash
Executable file
41 lines
641 B
Bash
Executable file
#!/bin/bash
|
|
|
|
|
|
# Initiate variables
|
|
retry_count=0
|
|
max_retries=3
|
|
retry_delay=15
|
|
success=0
|
|
|
|
|
|
# Retry until success or retry count reaches max_retries
|
|
while [[ $retry_count -le $max_retries && $success -ne 1 ]]; do
|
|
update_list="$(checkupdates)"
|
|
case $? in
|
|
# Update(s) available
|
|
0)
|
|
success=1
|
|
output=$(echo "$update_list" | wc -l)
|
|
class="update-available"
|
|
;;
|
|
|
|
# No update available
|
|
2)
|
|
success=1
|
|
output=0
|
|
class="no-update"
|
|
;;
|
|
|
|
*)
|
|
sleep $retry_delay
|
|
retry_count+=1
|
|
output=""
|
|
class="error"
|
|
;;
|
|
esac
|
|
done
|
|
|
|
|
|
cat << EOF
|
|
{"text": "$output", "alt": "$class", "tooltip": "$output", "class": "$class"}
|
|
EOF
|