1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Script that automatically reboots if ping is not successful

Discussion in 'Tomato Firmware' started by Tiansen, Apr 16, 2008.

  1. Tiansen

    Tiansen Addicted to LI Member

    I use Tomato firmware and have 2 routers - one is AP, other is ethernet bridge. I want to automatically reboot bridge if ping to AP is not successful. DD-WRT has GUI setting for this, for Tomato I must write a script. Can somebody please show me how to write script that will do that?
     
  2. mstombs

    mstombs Network Guru Member

  3. Tiansen

    Tiansen Addicted to LI Member

    Thread you mentioned is similar but there script checks wan connection and restarts wan service if necessary. I dont have any wan, but want to check (ping) Access Point from client. How can I do that? Must I reboot AP if there is no connection (DD-WRT does that) or can I just restart some service to force reconnection of client to AP? Please can somebody write something more specific how to do that because I am script newbie. :redface:
     
  4. mstombs

    mstombs Network Guru Member

    You can just put the IP of your other router in such a script. I would recommend you do look for the simplest command to restart comms rather than the brute force reboot which will lose all logs etc. Maybe "wl radio off" then "wl radio on" may do the trick, more script tips in this thread:-

    http://www.linksysinfo.org/forums/showthread.php?t=53955
     
  5. Tiansen

    Tiansen Addicted to LI Member

    Thank you for help. I've come up with this script:

    ping -q -c 1 192.168.1.1 > /dev/null
    if [ $? != 0 ] ; then
    reboot
    fi

    I type in this script in GUI of Tomato (Administration -> Scheduler -> Custom 1 -every minute). However it does not appear to run. If I type it in manually in terminal, it does work. Does Scheduler in Tomato 1.18 actually work?

    Then I tried to save this script in /jffs but could not do that because of read-only filesystem. How can I go around that? If I write to /home/root, script does not survive reboot. And how can I then run this script automatically every minute? If that custom script in GUI would work, then I dont need this messing around with script manually.

    P.S.: I tried with wl radio off and wl radio on instead of reboot but after issuing wl radio on, wlan led keeps blinking and never connects back.
     
  6. Tiansen

    Tiansen Addicted to LI Member

    Ok now, I managed to save my script (I formatted JFFS2, then mounted it). With init script I launch cru command with which I execute script periodically. Howerer I still have 2 questions:

    1. Is it possible to run a script for example every 30 seconds? Or is every minute minimum?
    2. What can I do to force wireless client reconnect (and it does not involve reboot)? Issuing wl radio off and wl radio on does not reconnect, wlan led is blinking and client does not connect back to AP.
     

Share This Page