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):

    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||$$$$$$$$|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:
    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||$$$$$$$$|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"
    if [ "$rr" = " " ]
    until [  $COUNT -lt 4 ]; do
    let COUNT-=1
    rs="blah blah"
    Can someone help me as to how to increment the rules to unset 1 to 4 and exit if they are not empty?
  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