
#!/bin/sh
# File	: chk_ip-adress-and-domain.sh
# By	:  MaartenDeBoer.nl, 161231
# Subject	: Script to get IP-address from chageip-com and check domainname
# Based on : http://www.changeip.com/accounts/dl.php?type=d&id=2
#set -x
#(0.2)	: Mod DNSIP
PGM="`basename $0|cut -d\. -f1`"
VER="0.2"
TMP="/tmp/${PGM}.$$"
DOMAINNAME="www.agrarix.eu"
MAILTO="maarten@agrarix.nl"

wget -q -U "${PGM} ${VER}" -O ${TMP} ip.changeip.com
OWNIP="`cat ${TMP}|grep -v IP|grep [1..0]`"
DNSIP="`dig +short ${DOMAINNAME}|grep [0-9]|head -1`"

if [ "${OWNIP}" != "${DNSIP}" ]; then
  echo "OWNIP(${OWNIP}) <> DNSIP(${DNSIP}) of ${DOMAINNAME}"
  echo "Own IP-address (${OWNIP}) NOT equal as DNS IP-address (${DNSIP}) for domain ${DOMAINNAME}"|mailx -s "[${PGM} v${VER}]" ${MAILTO}
else
  echo "OWNIP(${OWNIP}) = DNSIP(${DNSIP}) of ${DOMAINNAME}"
fi

rm ${TMP}
exit 0

