Last active
August 29, 2015 14:01
-
-
Save Doooooo0o/18830c184799e8727c89 to your computer and use it in GitHub Desktop.
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 | |
# This script require to have html2text on your computer | |
# [email protected] | |
############################################################### | |
vars(){ | |
ipfile="/home/ip" | |
ip=$(curl -s monip.org|html2text |grep -i "ip :"|awk '{ print $3 }') | |
login="mondomaine.eu-mamachine" | |
pass="monsuperpass" | |
domain="mondomaine.eu" | |
url="http://$login:[email protected]/nic/update?system=dyndns&hostname=$domain&myip=$ip" | |
from="[email protected]" | |
mail="[email protected]" | |
genfile | |
} | |
genfile(){ | |
if [ -f $ipfile ]; then | |
iplog=$(cat /home/ip) | |
else | |
touch /home/ip && echo $ip > $ipfile | |
iplog=$(cat /home/ip) | |
fi | |
compare | |
} | |
letscurl(){ | |
curl -s $url | |
} | |
mailto(){ | |
body="<head> <link rel='stylesheet' href='//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css'> <script src='//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js'></script> </head> <h1>Changement d'IP</h1><br/><p><pre><b>$ip</b> est la nouvelle IP</pre></p>" | |
echo $body | mail \ | |
-a "From: $from" \ | |
-a "MIME-Version: 1.0" \ | |
-a "Content-Type: text/html" \ | |
-s "Changement d'IP pour : $ip" \ | |
letscurl | |
} | |
compare(){ | |
if [ $ip != $iplog ]; then | |
mailto | |
echo $ip > $ipfile && exit 0 || exit 1 | |
else | |
return 0 | |
fi | |
} | |
vars |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment