forked from esn89/ipemailer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathipscript
More file actions
executable file
·27 lines (23 loc) · 831 Bytes
/
ipscript
File metadata and controls
executable file
·27 lines (23 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
publicip=$(dig +short myip.opendns.com @resolver1.opendns.com)
# Checks to see if there is a file which contains my current IP:
if [[ -e /tmp/currentip ]]
then
currentip=$(cat /tmp/currentip)
#Checks to see if my 'newly grabbed' public IP matches:
if [[ $publicip != $currentip ]]
then
#First, write it to /tmp/currentip
echo $publicip > /tmp/currentip
#Email me, to notify me of my new IP so I can use it.
mutt -s "Your new IP is: " youremail@gmail.com < /tmp/currentip
fi
# else we don't have such a file one, let's make one:
# This is for the case where your server restarts due to
# expected reasons or what not.
# More often than not, the /tmp folder may get cleared.
else
touch /tmp/currentip
echo $publicip > /tmp/currentip
mutt -s "Your new IP is: " youremail@gmail.com < /tmp/currentip
fi