Help with Script

Discussion in 'DD-WRT Firmware' started by jimbronie, Feb 5, 2008.

  1. jimbronie

    jimbronie Network Guru Member

    Hey guys,
    I want to give the automatic repair script a try, to see if it will resolve my connection issues with my cable modem.

    I am using dd-wrt v23 sp2. I went to admin-commands. Should this script be a startup script or a firewall script? Or should it be another type of script. (Startup and firewall are the only options.

    Here is the script I am going to use.

    UDHCPC="udhcpc -i vlan1 -p /var/run/ -s /tmp/udhcpc"

    ME=`basename $0`
    RUNNING=`ps | awk '/'"$ME"'/ {++x}; END {print x+0}'`
    if [ "$RUNNING" -gt 3 ]; then
    echo "Another instance of \"$ME\" is running"

    while sleep $INTERVAL
    TARGET=`ip route | awk '/default via/ {print $3}'`
    RET=`ping -c $PACKETS $TARGET 2> /dev/null | awk '/packets received/ {print $4}'`

    if [ "$RET" -ne "$PACKETS" ]; then
    echo Ping failed, releasing IP address: $IFACE
    #send a RELEASE signal
    kill -USR2 `cat /var/run/` 2> /dev/null
    #ensure udhcpc is not running
    killall udhcpc 2> /dev/null
    echo Renewing IP address: $IFACE
    echo Waiting 10 s ...
    sleep 10
    echo Network is up via $TARGET

    Any help for a "network challenged" user appreciated.

  2. mstombs

    mstombs Network Guru Member

    This looks like it is designed to be run from the firewall script, this will run every time the wan reconnects - it checks whether another copy is running and exits to avoid duplicates.

    Unfortunately doing this won't show you any error messages (in case commands/ variables have changed in different versions), and in worst case you may have to reset to defaults to clear the script.

    an alternative which is safer but slightly trickier is to create the script as a file in the temporary ram disk and run it from there - then a simple reboot will clear any trace!
  3. jimbronie

    jimbronie Network Guru Member

    thanks I will give it a try.
  4. jimbronie

    jimbronie Network Guru Member

    Didn't work. Is there a wiki on doing the ramdisk thing? The script actually works and fixes the problem, I just need it to run all the time. I am assuming that the startup and firewall scripts only run on startup.

    Is there a way to have this run let say every 10-15 minutes?
  5. mstombs

    mstombs Network Guru Member

    The firewall script should run every time the WAN reconnects, but this script should keep looping every 10 seconds forever once started! But maybe something monitors the firewall script and kills it if it doesn't terminate - I'm not currently running dd-wrt (but lots of similarities with Tomato)!

    The danger of using start-up is that it may interfere, and start too early, maybe add a "sleep 120" at the top to give core process time to connect.

    To run from ram disk you need to look at using "winscp" and something like "notepad++" on a windows PC. Create the file with Unix file format (notepad doesn't know about this). Copy the file to "/var/". Make it executable with "chmod +x /var/" and run it with "/var/ &".
  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