Sunday, August 13 2006: chipd
I've made some revisions to my change IP daemon script. I was having trouble with ZoneEdit getting out of sync because the script would miss an IP change, so I've updated it to check not whether the workstation thinks the IP is different, but rather check with ZoneEdit. I do call a small VBScript file, because I couldn't figure out how to parse the IP address from the ZoneEdit page using BASH scripting. I find that every problem is a nail.
$ cat bat/chipd eEdit. ipfile=/etc/chipd.txt logfile=/var/log/chipd.log actual_ip_src="http://bovwimi.net/" defined_ip_src="http://www.zoneedit.com/auth/edit.html?zone=yousuck.net" datefmt="%n%Y-%m-%d %T" #Output banner date +"$datefmt" echo "Starting $0..." # Get the current actual IP from a website date +"$datefmt" echo "Grabbing current IP from $actual_ip_src..." actual_ip=$(lynx -source $actual_ip_src | grep -i "" | awk '{print $4}' ) # If we get a blank IP from the web, set actual to value in ipfile, # where we stored the IP we pulled during the last run if chipd if [ "$actual_ip" == "" ]; then actual_ip=$(cat $ipfile) fi # pull HTML from ZoneEdit (contains IP) date +"$datefmt" echo "Grabbing defined IP from $defined_ip_src..." cd ~/bat lynx -source -auth=luser:password "$defined_ip_src" | grep "span class=" zone">anglo-hexon.net " > ipcrap_temp.txt defined_ip=$(cscript parseip.vbs ipcrap_temp.txt) # If we get a blank IP from ZoneEdit, set defined to actual if [ "$defined_ip" == "" ]; then date +"$datefmt" echo "Retrieved a blank defined_ip, resetting value to $actual_ip..." defined_ip=$actual_ip fi # Determine if the IP has changed, if so, update everything if [ "$actual_ip" == "$defined_ip" ]; then date +"$datefmt" echo "IP hasn't changed (old=$defined_ip, new=$actual_ip)..." else date +"$datefmt" echo "New IP detected (old=$defined_ip, new=$actual_ip), updating..." zedit >> $logfile sendip fi # Store the new IP defined_ip="$actual_ip" export defined_ip echo $defined_ip > $ipfile
Add Comment
You must be logged in as a member to add comment to this blogSidebar