just adding some email notifications
#!/bin/bash
# dns-o-matic.sh DNS-O-MATIC by James at Rhino, TomS, Ward Mundy & hjm, brunski
# "crontab -e" and then insert the appropriate line.
# Insert in crontab to run every 5 minutes:
# */5 * * * * /usr/bin/dns-o-matic.sh >/dev/null 2>&1
# Remember to place the program in /usr/bin
# Make it executable "chmod 755 /usr/bin/dns-o-matic.sh"
USERNAME="dns_o-matic_username"
PASSWORD="dns_o-matic_password"
localnet="192.168.1.0"
EMAIL=your-email-address
# Bring up the webpage that shows your IP address
# Select out your IP Address
ip=$(curl -s
http://www.whatismyip.com/automation/n09230945.asp)
# Or ip=$(curl -s
http://myip.dnsomatic.com)
# Print your IP Address
echo $ip
# Update dns-o-matic
# Don't forget to create an account at dnsomatic.com and select the appropriate service e.g. dyndns
# Use the same line as in the original script above:
if [ -e /tmp/$ip ] ; then
echo No IP Update Required ;
# echo -e "`date`:$ip" No update >> /tmp/.DNSOMATIC-LOG
else
echo IP Update Required ;
# Log the IP Address (dot filename will not be deleted on reboot)
echo -e "`date`:$ip" >> /tmp/.DNSOMATIC-LOG
chmod 666 /tmp/.DNSOMATIC-LOG
# Write to DNS-O-Matic and send an email
echo 'IP address for' `hostname -f` 'is:' $ip 'on ' `date` | mail -s 'New IP' $EMAIL
result=$(curl -s https://${USERNAME}:${PASSWORD}@updates.dnsomatic.com/nic/update?hostname=all.dnsomatic.com&myip=$ip&wildcar d=NOCHG&mx=NOCHG&backmx=NOCHG)
touch /tmp/$ip ;
echo "nat=yes" > /etc/asterisk/sip_nat.conf
echo "externip=$ip" >> /etc/asterisk/sip_nat.conf
echo "localnet=$localnet/255.255.255.0" >> /etc/asterisk/sip_nat.conf
asterisk -rx "dialplan reload" ;
fi
#send email notifying of job execution
echo 'Cron Job: dns-o-matic executed for' `hostname` 'on ' `date` 'ip: ' $ip | mail -s 'dns-o-matic cron job' $EMAIL