Gotify via CURL instead of CLI for better flexibility

(Gotify CLI only works if the CLI is installed on the machine,
whereas POST request via CURL to Gotify server should always work).
master
Taha Ahmed 2 years ago
parent 296cc79bb9
commit 44ff1cfdc1

@ -449,10 +449,19 @@ cetcest=$(date +%Z)
endtime=$(date +%s)
runtime=$(( $endtime - $starttime ))
# send push message via Gotify CLI
# send push message to Gotify server
# if runtime is longer than X minutes (suitable limit perhaps 3 min)
if (( $runtime > 180 )); then
gotify push --quiet --title "$dir_wd" --priority 5 "chertex.sh $@ \nCompleted in $runtime s"
if (( $runtime > 70 )); then
# POST request to Gotify server works without needing Gotify CLI on this box
# NOTE, multi-line bash command fails if interrupted by comment lines!
# Hide CURL response (-o /dev/null) and progress bar (--silent)
# https://gotify.net/docs/pushmsg
curl -X POST "https://gotify.chepec.se/message?token=A8nO3zYJ-R1wG__" \
-F "message=chertex.sh $@. Completed in $runtime s" \
-F "title=$dir_wd" -F "priority=5" \
-o /dev/null --silent
# https://stackoverflow.com/questions/3872427/how-to-send-line-break-with-curl
# I could not make multi-line message (to Gotify) work here, however I tried. Giving up for now.
msg "Push notification sent to Gotify"
fi

Loading…
Cancel
Save