#!/bin/bash ########################################################################## #Matthew Russell 14 Feb 05 #IPRefreshDaemon.scr #Usage to launch as background process: [prompt]$./IPRefreshDaemon.scr & ########################################################################## # #Important: The commands you use in this script have to be consistent #with your particular install of Linux. I've tested them to work on #Mac OS X Panther and on Mandrake Linux 9.1. They should work on any #recent Linux distro, but make sure if you're in doubt # #Some explanation based on MY home network. YOUR home network will #probably be different, but this recipe should require very little change: # #For my wireless router, I can type http://gateway.2wire.net #into my browser and pull up a control center. Given this is the case, #I can open up http://gateway.2wire.net/broadband/index.html to get a page #that contains my external IP address that is assigned to my wireless #router, which also happens to be my default gateway. #This IP Address is the one that separates me from the WWW and can use #when redirecting users to my private server. I use this method to obtain #my IP address because it's simple and because my DSL provider uses DHCP, #which means that my external IP address can periodically change. If I #don't periodically rewrite the page that redirects, users will get #transferred to a bogus site or no site at all. # #As root in linux or on your Mac, you can type "ifconfig" at a prompt, #but if you're running a home network, you'll see your internal IP #address. Again, you want your EXTERNAL IP address # #Some helpful notes for you: # #If you have a static IP address, you won't need to do this and can just #hardcode your redirect page. If you're unsure as to whether or not #you have a static IP address, you probably don't. Unless you have #a 2Wire Home Portal, this exact script won't work for you, but your #wireless router or internet provider *should* be able to tell you how #to get this info, and this script should require very minimal changes. # #Check and double check paths and permissions: # Make sure cadaver is in the path if you use it. Type "which cadaver" # to make sure it's in there # Make sure permissions are set for any script (including this on you try # to run. Type "ls -al filename" to check permissions and use # "chmod u+x filename" to add executable permissions. # #Use the man pages to get help on commands. Type "man commandname" at any prompt ########################################################################### #loop forever and update the IP address every 5 minutes. This means if you #want to kill this process you have to do it manually. #Use the killRefreshDaemon.scr script to do that. ######### USER PREFS ############ REDIRECT_PAGE="frames.html" REFRESH_INTERVAL="1m" #anywhere up to ~5m is reasonable ################################# #must have spaces inside brackets! #no indent while [ 1 ]; do #get the page that contains my IP Address and suppress any output from wget #this is probably different for you wget -q "http://gateway.2wire.net/broadband/index.html" #Use a regex to pull out the IP Address with the help of our friend Perl #From looking at the HTML source to the page for MY network that contains #this info, I know it's in a line like this: #