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

WAN Up Script not loading

Discussion in 'Tomato Firmware' started by Beast, Oct 11, 2010.

  1. Beast

    Beast Network Guru Member

    Hi

    I'm running {Tomato Firmware v1.28.9051 MIPSR1-beta22 K26 USB vpn3.6} on WRTSL54GS.

    I am trying to run a small add blocking script from the wan up. But it does not run from there for some reason. I placed just the line (logger WANUP ----TEST--TEST--TEST--TEST--TEST--TEST-TEST) in the WAN Up, and rebooted. I found no log entry of this line in my log file. ?????

    So I placed the script in the init area and it works, with one small problem I loose the host file after a reboot.

    Here is the script :

    logger AddBlocking Script Executing
    sleep 5
    test -s /tmp/mnt/USBDRIVE/dlhosts
    if [ $? == 1 ] ; then
    echo -e "#!/bin/sh\nwget -O - http://www.mvps.org/winhelp2002/hosts.txt | grep 127.0.0.1 | sed -e '2,\$s/127.0.0.1/0.0.0.0/g' -e 's/[[:space:]]*#.*$//' > /etc/hosts\nlogger DOWNLOADED http://www.mvps.org/winhelp2002/hosts.txt\nkillall -1 dnsmasq" > /tmp/mnt/USBDRIVE/dlhosts
    chmod 777 /tmp/mnt/USBDRIVE/dlhosts
    /tmp/mnt/USBDRIVE/dlhosts
    fi
    cru a Gethosts "45 20 * * 5 /tmp/mnt/USBDRIVE/dlhosts"


    Edit: Ok I think I see why I loose the host file. I made a change from the original script to save the dlhosts file to my usb drive, instead of /tmp/ DIR which I assume gets wiped out durning a reboot. But the file remains on the usb drive hence failing the initial TEST. After looking at the created dlhost file on the usb drive I saw that it really wasn't the list but rather the script to d/l it. I had made the change thinking I would save about a 1mb of ram by loading the file to usb drive.
     
  2. Toastman

    Toastman Super Moderator Staff Member Member

  3. tmr250z

    tmr250z LI Guru Member

    For your second issue, it looks to me like you altered the script a little too much. You should have only changed "/etc/hosts" to "/tmp/mnt/USBDRIVE/dlhosts", and left the references to "/tmp/dlhosts" alone. That way, the hosts file will be on the usb drive, not the script that creates it.

    Code:
    logger WAN UP Script Executing
    sleep 5
    test -s /tmp/dlhosts
    if [ $? == 1 ] ; then
        echo -e "#!/bin/sh\nwget -O - http://www.mvps.org/winhelp2002/hosts.txt | grep 127.0.0.1 | sed -e '2,\$s/127.0.0.1/0.0.0.0/g' -e 's/[[:space:]]*#.*$//' > /tmp/mnt/USBDRIVE/dlhosts\nlogger DOWNLOADED http://www.mvps.org/winhelp2002/hosts.txt\nkillall -1 dnsmasq" > /tmp/dlhosts
        chmod 777 /tmp/dlhosts
        /tmp/dlhosts
    fi
    cru a Gethosts "45 23 * * 5 /tmp/dlhosts"
     

Share This Page