#!/bin/sh
if [ "$ACTION" = "ifup" ] && [ "$INTERFACE" = "wan" ]; then
	ddns=
	token=
	ip=`ifconfig pppoe-wan | grep 'addr:' | cut -d: -f2 | awk '{ print $1}'`
	ddnsip=`nslookup $ddns | awk '/Address/{a=$3}END{print a}'`
	logfile=/var/log/macoers_ddns.log
	if [ "${ip}" != "${ddnsip}" ]; then
		curl -ks https://ddnsupdate.macoers.com/update/$token
		touch $logfile && echo $(date): The new IP address is $ip >> $logfile
	fi
fi
