From 5b31e68f73ef82513fc1239174b186b344e073c0 Mon Sep 17 00:00:00 2001 From: Joe Harrison <53116754+sudo-kraken@users.noreply.github.com> Date: Mon, 9 Sep 2024 22:57:11 +0100 Subject: [PATCH] Create notify_pushover.sh --- notify_pushover.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 notify_pushover.sh diff --git a/notify_pushover.sh b/notify_pushover.sh new file mode 100644 index 0000000..805e7ec --- /dev/null +++ b/notify_pushover.sh @@ -0,0 +1,32 @@ +### DISCLAIMER: This is a third party addition to dockcheck - best effort testing. +# +# Copy/rename this file to notify.sh to enable the notification snippet. +# Required receiving services must already be set up. +# Requires jq installed and in PATH. +# Modify to fit your setup - set Url and Token. + +send_notification() { + Updates=("$@") + UpdToString=$( printf "%s\n" "${Updates[@]}" ) + FromHost=$(hostname) + + # platform specific notification code would go here + printf "\nSending pushover notification\n" + + MessageTitle="$FromHost - updates available." + # Setting the MessageBody variable here. + MessageBody="Containers on $FromHost with updates available: $UpdToString" + + # Modify to fit your setup: + PushoverUrl="https://api.pushover.net/1/messages.json" + PushoverUserKey="Your Pushover User Key Here" + PushoverToken="Your Pushover API Token Here" + + # Sending the notification via Pushover + curl -sS -o /dev/null --show-error --fail -X POST \ + -F "token=$PushoverToken" \ + -F "user=$PushoverUserKey" \ + -F "title=$MessageTitle" \ + -F "message=$MessageBody" \ + $PushoverUrl +}