helm/bin/pushover
2017-12-06 01:39:10 -05:00

58 lines
1 KiB
Bash
Executable file

#!/usr/bin/env bash
#
# Sends a pushover notification.
#
# -t [TITLE]
# -m [MESSAGE]
# -p [PRIORITY_LEVEL]
# -u [URL]
# -U [URL_TITLE]
# -d [DEVICE]
#
set -e
unset CDPATH
secret_file=~/.secrets/pushover
if [[ ! -f $secret_file ]]; then
>&2 echo "No pushover config file found"
exit 1
fi
title=${2:+$1}
message=${2:-$1}
# priority=
url=
url_title=
device=
while getopts t:m:p:u:d: opt; do
case $opt in
t) title="$OPTARG" ;;
m) message="$OPTARG" ;;
# p) priority="$OPTARG" ;;
u) url="$OPTARG" ;;
U) url_title="$OPTARG" ;;
d) device="$OPTARG" ;;
*) >&2 echo "Invalid option $OPTARG"
exit 1
;;
esac
done
shift $((OPTIND-1))
#USER=...
#TOKEN=...
eval "$(gpg --decrypt $secret_file)"
curl -s \
--form-string "token=$TOKEN" \
--form-string "user=$USER" \
--form-string "title=$title" \
--form-string "message=$message" \
--form-string "url=$url" \
--form-string "url_title=$url_title" \
--form-string "device=$device" \
https://api.pushover.net/1/messages.json