#!/bin/bash
# Config
Username="username"
Password="password"
Hostname="sub.domain.com"
daemon=3600 # check every 3600 seconds (one hour)
syslog=yes # log update msgs to syslog
pidfile=/var/run/loopiaddclient.pid # record PID in file.
# Do not edit bellow this line
if [ -f "${pidfile}" ]; then
# The file exists so read the PID
# to see if it is still running
MYPID=`head -n 1 $pidfile`
if [ -n "`ps -p ${MYPID} | grep ${MYPID}`" ]; then
echo `basename $0` is already running [$MYPID].
exit
fi
fi
# Echo current PID into lock file
echo $$ > $pidfile
echo "Launching Loopia DNS Updater"
IPaddr="0"
while a=a
do
IPaddrNy=`curl -s dns.loopia.se/checkip/checkip.php | sed 's/^.*: \([^<]*\).*$/\1/'`
if [ $IPaddr != $IPaddrNy ]
then
IPStatus="$(curl -s --user "$Username:$Password" "https://dns.loopia.se/XDynDNSServer/XDynDNS.php?hostname=$Hostname&myip="`curl -s dns.loopia.se/checkip/checkip.php | sed 's/^.*: \([^<]*\).*$/\1/'`)"
if [ $syslog = "yes" ]
then
case "$IPStatus" in
"good" )
echo "IP adress for $Hostname is updated to $IPaddrNy"
;;
"nochg" )
echo "No change needed for $Hostname, will check again in $daemon seconds."
;;
* )
echo "Unknown server response: $syslog"
;;
esac
fi
IPaddr=$IPaddrNy
fi
sleep $daemon
done
#!/bin/bash
# Config
Username="username"
Password="password"
Hostname="sub.domain.com"
daemon=3600 # check every 3600 seconds (one hour)
syslog=yes # log update msgs to syslog
pidfile=/var/run/loopiaddclient.pid # record PID in file.
# Do not edit bellow this line
if [ -f "${pidfile}" ]; then
# The file exists so read the PID
# to see if it is still running
MYPID=`head -n 1 $pidfile`
if [ -n "`ps -p ${MYPID} | grep ${MYPID}`" ]; then
echo `basename $0` is already running [$MYPID].
exit
fi
fi
# Echo current PID into lock file
echo $$ > $pidfile
echo "Launching Loopia DNS Updater"
IPaddr="0"
while a=a
do
IPaddrNy=`curl -s dns.loopia.se/checkip/checkip.php | sed 's/^.*: \([^<]*\).*$/\1/'`
if [ $IPaddr != $IPaddrNy ]
then
IPStatus="$(curl -s --user "$Username:$Password" "https://dns.loopia.se/XDynDNSServer/XDynDNS.php?hostname=$Hostname&myip="`curl -s dns.loopia.se/checkip/checkip.php | sed 's/^.*: \([^<]*\).*$/\1/'`)"
if [ $syslog = "yes" ]
then
case "$IPStatus" in
"good" )
echo "IP adress for $Hostname is updated to $IPaddrNy"
;;
"nochg" )
echo "No change needed for $Hostname, will check again in $daemon seconds."
;;
* )
echo "Unknown server response: $syslog"
;;
esac
fi
IPaddr=$IPaddrNy
fi
sleep $daemon
done
Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/VjphZOC_djA/10431