Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 3 Apr 1999 20:45:49 +1000 (EST)
From:      Rowan Crowe <rowan@sensation.net.au>
To:        freebsd-isp@freebsd.org
Subject:   pppd redial script
Message-ID:  <Pine.BSF.4.01.9904032015420.13153-100000@velvet.sensation.net.au>

next in thread | raw e-mail | index | archive | help
Hi all,

This is a redial script I wrote the other night, which redials after the
link drops out but backs off exponentially if redial attempts keep
failing. (In Australia, we pay 25c per call, so if the other end is
answering but there's some sort of PPP problem, constant redials could end
up costing $$$). Redial delay is capped at 300 seconds maximum.

Basically the delays for repeated failed attempts will go something like:
5, 15, 45, 135, 300, 300, 300...

Once the link has been up more than 10 minutes, it is considered "stable"
and the redial delay is reset to 5 seconds when it next drops.

I'd be interested in any comments. Feel free to use it yourselves. To run
it in the background use '&' on the commandline. (the info messages could
probably be >>'d to a log file).


#!/bin/sh
delay1=5
while :
do
  stime=`date "+%s"`
  # use your own pppd options here, but make sure you have -detach
  /usr/sbin/pppd -detach connect '/usr/bin/chat -v -f /etc/ppp/ppp-sens.scr' /dev/cuaa0 115200 deflate 15 bsdcomp 15 203.20.114.194: lcp-echo-interval 30 lcp-echo-failure 2
  etime=`date "+%s"`
  connectedtime=`expr ${etime} - ${stime}`
  echo "time connected=${connectedtime} seconds"
  if [ "`expr ${connectedtime} \< 600`" = "1" ]; then
    delay1=`expr ${delay1} \* 3`
    echo "delay now ${delay1} seconds"
    if [ "`expr ${delay1} \> 300`" = "1" ]; then
      echo "capping delay at 300 seconds"
      delay1=300
    fi
  fi
  if [ "`expr ${connectedtime} \> 600`" = "1" ]; then
    echo "resetting delay to 5 seconds"
    delay1=5
  fi
  echo "sleeping ${delay1} seconds"
  sleep ${delay1}
done



--
Rowan Crowe                     Sensation Internet Services, Melbourne Aust
fidonet: 3:635/728                                          +61-3-9388-9260
http://www.rowan.sensation.net.au/             http://www.sensation.net.au/



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-isp" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.01.9904032015420.13153-100000>