#!/bin/bash

my_date=$(date +%Y%m%d%H%M%S)


echo "------------- $my_date ------------"

registered_ip=$(ping -c 1 demo.dyndns.org | grep PING | awk -F "(" '{print $2}' | awk -F ")" '{print $1}')
echo "Registered IP: $registered_ip"

current_ip=$(wget --output-document - http://checkip.dyndns.com/ 2>/dev/null | awk '{ print $6}' | awk -F "<" '{print $1}')

echo "Current IP: $current_ip"

if [ "$current_ip" != "$registered_ip" ]
    then
        #echo "Need ddclient";
	/usr/sbin/ddclient -daemon=0 -syslog -quiet -force
    #else
	#echo "All OK"
fi
echo "------------- $my_date ------------"
echo ""
