diff --git a/scripts/detect-ip-change b/scripts/detect-ip-change new file mode 100644 index 0000000..51a0ed6 --- /dev/null +++ b/scripts/detect-ip-change @@ -0,0 +1,15 @@ +#!/bin/bash +# Send an email when the public ipv4 address changes + +if [[ -a /tmp/ipv4_address ]]; then + CURRENT_IP=$(/usr/bin/dig +short myip.opendns.com @resolver1.opendns.com) + PREVIOUS_IP=$(cat /tmp/ipv4_address) + + if [[ $CURRENT_IP != $PREVIOUS_IP ]]; then + echo "IP address changed from $PREVIOUS_IP to $CURRENT_IP" | /usr/bin/mail -s 'IP address changed' sonnyba871@gmail.com + echo $CURRENT_IP > /tmp/ipv4_address + echo "Mail sent" + fi +else + echo "$(/home/sonny/dotfiles/scripts/pubip)" > /tmp/ipv4_address +fi diff --git a/scripts/pubip b/scripts/pubip deleted file mode 100755 index 7039c6f..0000000 --- a/scripts/pubip +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -## Get public IP - -wget http://ipinfo.io/ip -qO -