forked from mag37/dockcheck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotify_pushbullet.sh
27 lines (21 loc) · 1.03 KB
/
notify_pushbullet.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
### 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 pushbullet notification\n"
MessageTitle="$FromHost - updates available."
# Setting the MessageBody variable here.
MessageBody="Containers on $FromHost with updates available: $UpdToString"
# Modify to fit your setup:
PushUrl="https://api.pushbullet.com/v2/pushes"
PushToken="Your Pushbullet token here"
# Requires jq to process json data
jq -n --arg title "$MessageTitle" --arg body "$MessageBody" '{body: $body, title: $title, type: "note"}' | curl -sS -o /dev/null --show-error --fail -X POST -H "Access-Token: $PushToken" -H "Content-type: application/json" $PushUrl -d @-
}