Created
September 15, 2015 14:39
-
-
Save jeffskinnerbox/13cd61e4d99feb0dcbca to your computer and use it in GitHub Desktop.
This utility does a push notification to the service Pushover - https://pushover.net/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This utility does a push notification to the service Pushover - https://pushover.net/ | |
APPTOKEN="aegfmQiK9Krrigwmir4fgnoodw8w" | |
USERKEY="ufwidfifFYQHyggjdpdgeGfehdfpg" | |
# Parse command line options | |
USAGE="Usage: `basename $0` [-h] -t title -m message" | |
while getopts ht:m: OPT; do | |
case "$OPT" in | |
h) | |
echo $USAGE | |
exit 0 | |
;; | |
t) | |
TITLE=$OPTARG | |
;; | |
m) | |
MESSAGE=$OPTARG | |
;; | |
\?) | |
# getopts issues an error message | |
echo $USAGE >&2 | |
exit 1 | |
;; | |
esac | |
done | |
# Send message to Pushover to create notification | |
curl --silent \ | |
-F "token=$APPTOKEN" \ | |
-F "user=$USERKEY" \ | |
-F "message=$MESSAGE" \ | |
-F "device=desktop" \ | |
-F "title=$TITLE" \ | |
-F "sound=spacealarm" \ | |
https://api.pushover.net/1/messages.json | grep '"status":1' > /dev/null | |
# Check the exit code to identify an error | |
if [ $? -eq 0 ]; | |
then | |
exit 0 | |
else | |
echo "apprise failed" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment