#!/bin/sh # ver 0.9.3 Apr 14, 2008, hernad@bring.out.ba 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"` LAST_IP=`cat last_ip.txt` mv last_call.txt old_call.txt 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 (cat < tmp.zone echo "ip sigma-com.net = $IP" FEEDBACK="0" reload_nameserver() { echo "restarting 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 $IP>last_ip.txt echo "ip change has finished">>last_call.txt exit 0 else echo "error sleep 10sec" echo "error10 ">>last_call.txt sleep 10 fi done echo "ip change unsucessfull (after while) ?!?">>last_call.txt