[wplug] Some scripting help (smoothwall)

Mike techmike at gmail.com
Mon Feb 21 13:28:08 EST 2005


Makes sense..  Now to throw a wrench into the mixture which I forgot before.  

Adding something to prevent this puppy from looping endlessly should a
dsl outage occur.

Would some sort of counter work, increment for each failed renewal, at
3 or so quit trying.  Upon succusful renewal reset the counter.. 
Makes sense, but would it work?

-Mike


On Mon, 21 Feb 2005 18:10:29 +0200, Alexandros Papadopoulos
<apapadop at alumni.cmu.edu> wrote:
> On Monday 21 February 2005 17:39, Mike wrote:
> >  I've never really scripted anything before so I'm going to need all
> >    the help I can get.  I run a smoothwall box for my internet
> > firewall. Well lately my ISP's PPPOe server has been on the fritz
> > requiring me to either reboot or renew my IP every so often to keep
> > working. So I'm thinking, how about a script that I can put in cron
> > to run every 5 mintues or so..
> >    1.  ping XXX.XXX.XXX.XXX
> >    a.  if response okay, do nothing.
> >    b.  if response fails run:
> >    /etc/rc.d/rc.netaddress.down; /etc/rc.d/rc.netaddress.up;
> >    /usr/local/bin/restartsquid
> >    and add log entry to some netrestart.log
> >    Should be simple enough right, but where to begin..  :)
> 
> http://www.tldp.org/LDP/abs/html/testconstructs.html
> 
> The script you're looking for could look somewhat like this:
> 
> #!/bin/bash
> # If we're online, don't renew our IP.
> echo -n "Testing for connectivity: "
> /bin/ping -c 2 XXX.XXX.XXX.XXX &> /dev/null
> if [ $? -eq 0 ]
> then
>  # This means we're online
>  echo -n "OK"
> else
>  echo -n " Not online, will renew our IP."
> /etc/rc.d/rc.netaddress.down
> sleep 1
> /etc/rc.d/rc.netaddress.up
> sleep 1
> /usr/local/bin/restartsquid
> echo "Renewed our IP at `date`" >> /var/log/netrestart.log
> fi
> 
> This would obviously require running it as root, so test it well before
> use.
> 
> -A
> _______________________________________________
> wplug mailing list
> wplug at wplug.org
> http://www.wplug.org/mailman/listinfo/wplug
>


More information about the wplug mailing list