From 21ee1aa54c8daf93fd4f299067ee8b9d7b738881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roger=20P=C3=A0mies?= Date: Wed, 27 Apr 2022 00:02:50 +0200 Subject: [PATCH] first commit. gotifypush script --- README.md | 7 +++++++ gotifypush.sh | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 README.md create mode 100644 gotifypush.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..c7fd4e5 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# Bash Scripts collection + +## gotifypush.sh + +Send markdown notifications to gotify channel throught curl + +`Usage: ./gotifypush.sh <message> <priority> <token> <clickurl>` diff --git a/gotifypush.sh b/gotifypush.sh new file mode 100644 index 0000000..888ab22 --- /dev/null +++ b/gotifypush.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +#Use ./gotifypush <title> <message> <priority> <token> <clickurl> + +#uncomment when use script from cron +PATH=$PATH:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin + +# Gotify notification parameters +TITLE=$1 +MESSAGE=$2 +PRIORITY=$3 +URL="https://push.example.com/message?token=$4" +#if url passed by parameter, set to extras +if [ -n "$5" ] +then + EXTRAS="{\"client::display\": {\"contentType\": \"text/markdown\"}, \"client::notification\": {\"click\": { \"url\": \"$5\"}}}" +else + EXTRAS="{\"client::display\": {\"contentType\": \"text/markdown\"}}" +fi + +# better curl usage https://github.com/gotify/server/issues/68 +#curl --silent --output /dev/null --show-error --fail -X .... #silent curl execution, no output, only html code if error +curl -X POST "${URL}" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"message\": \"${MESSAGE}\", \"priority\": ${PRIORITY}, \"title\": \"${TITLE}\", \"extras\": ${EXTRAS} }"