Created
March 21, 2013 11:00
-
-
Save korovamilk/5212233 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
# IP address change logger and notifier | |
# v.201303211157 | |
# http://korovamilky.tumblr.com | |
LOGGER="${HOME}/ip_change.log" | |
TMP_NOTIFY="/tmp/ip_notify.log" | |
HOST=$(hostname) | |
ADMIN_MAIL="[email protected]" #### #### #### <- CHANGE THIS #### | |
IP=$(curl -s icanhazip.com) | |
TIMESTAMP=$(date "+%Y%m%d %H:%M") | |
touch $TMP_NOTIFY | |
if [ ! -f $LOGGER ]; | |
then | |
touch $LOGGER | |
echo " host: $HOST" > $LOGGER | |
fi | |
echo " host: $HOST" | tee -a $TMP_NOTIFY | |
echo " discovered ip: $IP" | tee -a $LOGGER $TMP_NOTIFY | |
echo " timestamp: $TIMESTAMP" | tee -a $LOGGER $TMP_NOTIFY | |
echo | tee -a $LOGGER $TMP_NOTIFY | |
mutt -s "$HOST - ip change detected" $ADMIN_MAIL < $TMP_NOTIFY | |
rm -f $TMP_NOTIFY | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment