Created
November 16, 2013 17:45
-
-
Save chromy/7503132 to your computer and use it in GitHub Desktop.
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 | |
APPLICATION_TOKEN=a3MxpesaEnciPeqqsYBrzZatpwrDQ9 | |
USER_TOKEN=$PUSHOVER_USER_TOKEN | |
URL=https://api.pushover.net/1/messages.json | |
function push_alert() { | |
curl -s \ | |
-F "token=$APPLICATION_TOKEN" \ | |
-F "user=$USER_TOKEN" \ | |
-F "message=$1" \ | |
$URL | |
} | |
function main() { | |
if [[ $# -eq 0 ]] ; then | |
echo "Usage: $0 [command]" | |
exit 0 | |
fi | |
# Run command in sub shell. | |
(${@:1}) | |
code=$? | |
if [ $code -ne 0 ]; then | |
push_alert "Command ${@:1} failed with status $code." | |
fi | |
} | |
main $@ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment