#!/bin/sh #こんな感じです。 #エラー処理は考えてません。 parm_1=$1 access_count=0 total_count=0 new_ip=`/sbin/ifconfig eth1|awk '/inet/{print $1}'|cut -d":" -f2` last_ip=$new_ip exe_func() { if [ "$parm_1" = --debug ];then echo "Debug mode running...,parm_1 is $parm_1" echo "Sleep 2 hours,access_count is $access_count" sleep 1s else sleep 2h fi } echo "start ddns.sh on `date`." >/root/ddns.log while [ 1 ];do echo "`date`,access_count is $access_count.IP $new_ip" >>/root/ddns.log new_ip=`/sbin/ifconfig eth1|awk '/inet/{print $1}'|cut -d":" -f2` if [ $last_ip = $new_ip ];then exe_func access_count=$(($access_count+1)) if [ $(($access_count/13)) != 0 ];then #下の*******は、パスワードです。 wget -O - 'http://ddo.jp/dnsupdate.php?dn=karing&pw=*******' >/root/ddns.html access_count=0 total_count=$(($total_count+1)) echo "Restart ddns.sh on `date`,total_count is $total_count.IP $new_ip" >/root/ddns.log fi else echo "Updated the eth1 IP on `date`,new IP is $new_IP." >>/root/ddns.log #下の*******は、パスワードです。 wget -O - 'http://ddo.jp/dnsupdate.php?dn=karing&pw=*******' > /root/ddns.html last_ip=$new_ip exe_func access_count=$(($access_count+1)) fi done