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

Bash Script Help to fix dissapearing nvram rules in shibby FW

Discussion in 'Tomato Firmware' started by Sean Rhodes, Nov 12, 2013.

  1. Sean Rhodes

    Sean Rhodes Networkin' Nut Member

    I have a problem with the contents of my nvram rules disappearing for some reason, even after a nvram commit. It has been going on since V104 and I have no idea why. Has anyone else experienced this?

    After about a couple of hours the rules disappear from the gui. When I perform a nvram get rrule1 the contents are empty.

    To fix it I currently manually do the following (try to avoid keep performing nvram commit):

    Code:
    nvram unset rrule1
    nvram unset rrule2
    nvram unset rrule3
    nvram unset rrule4
    nvram set rrule1="1|-1|-1|127|14:10:9F:D9:25:1D||minecraft.net$ riotgames.com$
    leagueoflegends.com$ doubleclick.net$ creeperrepo.net$ creeperhost.net$ skype.com$
    youtube.com$|0|Site Blocking"
    nvram set rrule2="1|1200|960|31|14:10:9F:D9:25:1D|||0|Rule 1"
    nvram set rrule3="1|1425|840|96|14:10:9F:D9:25:1D|||0|Rule 2"
    nvram set rrule4="0|-1|-1|127|7C:ED:8D:FD:73:A9>14:10:9F:D9:25:1D|||0|Wifi"
    ifconfig eth1 down
    ifconfig eth2 down
    sleep 3
    ifconfig eth1 up
    ifconfig eth2 up

    I would like to create a bash script to read the rules and if the contents are empty just unset them, reset and restart (not sure how the rules are applied, i.e. is it better to do a service restart on the iptables, or is taking the ethernet down and up sufficient).

    so far I have:
    Code:
    rr="nvram get rrule$1"
    ru="nvram unset rrule$1"
    rs="nvram set rrule$1"
    rrule1="1|-1|-1|127|14:10:9F:D9:25:1D||minecraft.net$ riotgames.com$
    leagueoflegends.com$ doubleclick.net$ creeperrepo.net$ creeperhost.net$ skype.com$
    youtube.com$|0|Site Blocking"
    rrule2="1|1200|960|31|14:10:9F:D9:25:1D|||0|Rule 1"
    rrule3="1|1425|840|96|14:10:9F:D9:25:1D|||0|Rule 2"
    rrule4="0|-1|-1|127|7C:ED:8D:FD:73:A9>14:10:9F:D9:25:1D|||0|Wifi"
    COUNT=4
    if [ "$rr" = " " ]
    until [  $COUNT -lt 4 ]; do
    ru
    let COUNT-=1
    done
    else
    fi
    rs="blah blah"
    else
    fi
    
    Can someone help me as to how to increment the rules to unset 1 to 4 and exit if they are not empty?
     

Share This Page