#!/bin/sh if [ -z "$PUSHOVER_USER" ] || [ -z "$PUSHOVER_TOKEN" ]; then echo "Warning: Pushover user and token are not set" >&2 && logger -t notify.sh "pushover credentials cannot be found" exit 1 fi if [ "$#" -lt 2 ]; then echo "Usage: notify.sh <message>" >&2 exit 1 fi title="$1" shift message="$*" output=$(/usr/bin/curl -s \ --form-string "token=$PUSHOVER_TOKEN" \ --form-string "user=$PUSHOVER_USER" \ --form-string "title=$title" \ --form-string "message=$message" \ https://api.pushover.net/1/messages.json 2>&1) code=$? if [ "$code" -ne 0 ]; then logger -t notify.sh "curl failed (exit $code): $output" elif echo "$output" | grep -q '"status":0' then logger -t notify.sh "pushover rejected message: $output" fi