Help Tweaking KeepAlive Script

Discussion in 'Tomato Firmware' started by astehn, Feb 11, 2009.

  1. astehn

    astehn LI Guru Member

    I've been successfully using the script pasted at the bottom of this post, having assembled it from other posts (mostly As you'll see, Tomato basically tries as many as 4 ping attempts to the OpenDNS primary server, and if it gets no response, it reboots my DSL modem, then reboots itself. Otherwise, if there is a successful ping response, it just logs the running of the script and then quits.

    What I'd really like to do is be able to add one more loop to test another IP with ping, just to ensure that the router doesn't reboot if the one OpenDNS server goes down. I think I need a more or less identical while/do loop to ping another outside IP only if there are 4 unsuccessful pings to the OpenDNS IP. The trouble is that I'm lousy at scripting (I'm much better at copying other people's work!) and have failed at my attempts. So I'd really appreciate any help!

    Here's the script I'm currently using without trouble:

    cat <<END > /tmp/
    while ( ( /bin/ping -c 1 | /bin/grep -q '100% packet loss' ) && \
     [ \$ping_attempt -lt '3' ] )
     ping_attempt=\`expr \$ping_attempt + 1\`
     /bin/sleep 1
     if [ \$ping_attempt = 3 ] ; then
      wget -q [url]http://user:password@[/url]  
      sleep 45
    logger "The keep alive script finished"
    chmod 755 /tmp/
    cru a KeepAliveScript "0,15,30,45 * * * * /tmp/ >/dev/null 2>&1"
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice