From 44ff1cfdc136f7b09ada221bce0bf3a956912ce8 Mon Sep 17 00:00:00 2001 From: "taha@asks2" Date: Mon, 19 Dec 2022 23:24:12 +0100 Subject: [PATCH] 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). --- chertex.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/chertex.sh b/chertex.sh index 6d0375e..349b6fb 100755 --- a/chertex.sh +++ b/chertex.sh @@ -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