#!/bin/sh HOSTNAME=router-wan-sa-1 NAMESERVER=128.177.28.71 TMP_DIR=/tmp/refresh_ip if [ ! -d $TMP_DIR ] then mkdir $TMP_DIR fi cd $TMP_DIR IP=`ifconfig ppp0 | grep -o "inet addr:\(.*\) P-t-P" | sed -e "s/inet addr://" | sed -e "s/ P-t-P//" | sed -e "s/ //g"` echo ip=$IP #echo "`date` $IP">last_call.txt #echo "x${IP}x" LAST_IP=`cat last_ip.txt` #echo "last-ip = _${LAST_IP}_ , current ip = _${IP}_" if [ "${LAST_IP}" == "${IP}" ] then echo "`date` : no ip change ${IP}">last_call.txt exit 0 else echo "`date` : IP CHANGE has happened - old ${LAST_IP} new ${IP} !">last_call.txt fi echo $IP>last_ip.txt (cat < tmp.zone echo "ip sigma-com.net = $IP" FEEDBACK="0" reload_nameserver() { echo "reloading name server" scp -o -y -i /etc/dropbear/${HOSTNAME}.key tmp.zone root@${NAMESERVER}:/var/named/sigma-com.net.zone FEEDBACK=`ssh -y -i /etc/dropbear/${HOSTNAME}.key root@${NAMESERVER} service named restart | grep -c "\[.*OK.*\]"` # 2 => 2 x [ OK ] } while [ "$FEEDBACK" != "2" ] do reload_nameserver echo "feedback=_${FEEDBACK}_" if [ "$FEEDBACK" != "2" ] then echo "error sleep 10sec" sleep 10 fi done echo "ip change has finished">>last_call.txt