-
-
Save marshallmick007/9025968 to your computer and use it in GitHub Desktop.
Ubuntu server boot notification script
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 | |
# | |
# ************************************************* | |
# chkconfig: 2345 99 99 | |
# description: notify email address on system boot. | |
# | |
# https://gist.github.com/marshallmick007/9025968 | |
# ************************************************* | |
# Installing: | |
# 1) save as /etc/init.d/notify | |
# 2) set the desired email address in "MAILADD" variable | |
# 3) chmod a+w /etc/rc.d/notify | |
# 4) sudo update-rc.d notify defaults | |
### BEGIN INIT INFO | |
# Provides: notify | |
# Required-Start: $all | |
# Required-Stop: $network | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: starts notify | |
# Description: Sends an email when the server boots up | |
### END INIT INFO | |
PATH=/bin:/usr/sbin:/usr/bin | |
SERVER=`hostname` | |
case $1 in | |
start) | |
PUBLIC_IP=`curl --connect-timeout 5 -s icanhazip.com` | |
PUBLIC_IPV6=`curl -6 --connect-timeout 5 -s icanhazip.com` | |
MAILADD=your@email.example | |
mail -s " Boot of $SERVER" $MAILADD <<EOF | |
From: $0 | |
To: $MAILADD | |
$SERVER has booted up. | |
public ip $PUBLIC_IP $PUBLIC_IPV6 | |
If this is news to you, please investigate. | |
`date -u` | |
EOF | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment