Skip to content

Instantly share code, notes, and snippets.

@polds
Forked from jehiah/notify.sh
Last active August 29, 2015 13:55
Show Gist options
  • Save polds/8707567 to your computer and use it in GitHub Desktop.
Save polds/8707567 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# *************************************************
# chkconfig: 2345 99 99
# description: send pushover notification on system boot.
# *************************************************
# Installing:
# 1) save as /etc/rc.d/init.d/notify
# 2) set the token and user in TOKEN and USER
# 3) chmod a+w /etc/rc.d/init.d/notify
# 4) /sbin/chkconfig --level 2345 notify on
PATH=/bin:/usr/sbin:/usr/bin
SERVER=`hostname`
DATE=`date -u`
case $1 in
start)
PUBLIC_IP=`curl --connect-timeout 5 -s icanhazip.com`
PUBLIC_IPV6=`curl -6 --connect-timeout 5 -s icanhazip.com`
TOKEN=yourtoken
USER=youruser
curl -s \
-F "token=$TOKEN" \
-F "user=$USER" \
-F "message=$SERVER has restarted - $DATE. If this this is news to you, please investigate. ($PUBLIC_IP $PUBLIC_IPV6)" \
https://api.pushover.net/1/messages.json
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment