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

Script Help...Ignore MAC's...See MAC's...LED Control...

Discussion in 'Tomato Firmware' started by joelinkup, Jan 18, 2008.

  1. joelinkup

    joelinkup LI Guru Member

    Router is a WRT54GL using either HyperWRT Thibor 15c or Tomato Firmware. I am providing the following 2 scripts that work perfectly as a reference tool for the help I need on another script. I have tried to do this myself but I cannot get the job done. I ask for your HELP. I need a script that will do the following.

    Script where Client There = Steady Amber Cisco LED, Client Active = Steady White Cisco LED, No Client = Dark Cisco LED, and where 3 MAC Addresses are Ignored, and where seeing any of 4 other MAC Addresses invokes a Blinking Amber Cisco LED...

    The visual will be as follows. 3 print servers will be Totally Ignored. A Blinking Amber Cisco LED will indicate that 1 or more of 4 cameras are accessing the router while nothing else is. A Steady Amber Cisco LED will indicate that a client other than or in addition to a camera is accessing the router. A Steady White Cisco LED will indicate there is activity by these other clients. A Dark Cisco LED will indicate that no client is accessing the router.

    I am adding that the Client Active = Steady White Cisco LED is NOT mandatory if it will simplify the script. This is because the assumption can be made that IF a client is accessing the router there will eventually be activity. It is the visual that they are there that is important not their activity.

    Any help you can give to me is GREATLY Appreciated. THANK YOU ALL very much.

    --------------------------------------------------------------

    Script where Client There = Steady Amber Cisco LED, Client Active = Steady White Cisco LED, No Client = Dark Cisco LED, and where 3 MAC Addresses are Ignored...

    #!/bin/sh
    I=`nvram get wl0_ifname`
    while sleep 1; do
    minusbridge=$(wl assoclist | grep -v A1:B1:C1:D1:E1:F1 | grep -v A2:B2:C2:D2:E2:F2 | grep -v A3:B3:C3:D3:E3:F3)
    if [ -n "$minusbridge" ] ; then
    XFER=`ifconfig $I|grep bytes`
    if [ "$XFER" != "$PXFER" ]; then
    LED="amber off white on"
    PXFER=$XFER
    else
    LED="amber on white off"
    fi
    else
    LED="amber off white off"
    fi
    if [ "$LED" != "$PLED" ]; then
    led $LED
    PLED=$LED
    fi
    done

    -------------------------------------------------------------------

    Script where Client There = Steady Amber Cisco LED, Client Active = Steady White Cisco LED, No Client = Blinking Amber Cisco LED, and where 3 MAC Addresses are Ignored...

    #!/bin/sh
    I=`nvram get wl0_ifname`
    while sleep 1; do
    minusbridge=$(wl assoclist | grep -v A1:B1:C1:D1:E1:F1 | grep -v A2:B2:C2:D2:E2:F2 | grep -v A3:B3:C3:D3:E3:F3)
    while [ "$minusbridge" == "" ] ; do
    led amber off white off
    sleep 1
    led amber on white off
    minusbridge=$(wl assoclist | grep -v A1:B1:C1:D1:E1:F1 | grep -v A2:B2:C2:D2:E2:F2 | grep -v A3:B3:C3:D3:E3:F3)
    done

    if [ -n "$minusbridge" ] ; then
    XFER=`ifconfig $I|grep bytes`
    if [ "$XFER" != "$PXFER" ]; then
    LED="amber off white on"
    PXFER=$XFER
    else
    LED="amber on white off"
    fi
    else
    LED="amber off white off"
    fi
    if [ "$LED" != "$PLED" ]; then
    led $LED
    PLED=$LED
    fi
    done

    -------------------------------------------------------------------
     
  2. yaqui

    yaqui LI Guru Member

    Following this part of his post:

    Code:
    ### Define Variables ###
    clientpresent="amber on"
    clientactive="white on"
    ledsoff="amber off white off"
    I=`nvram get wl0_ifname`
    
    #Start the loop
    while sleep 1 ; do
    
    ## Initialize ##
    seecameras=""
    clientsminusprinters=""
    blinkamber=""
    clientleds=""
    
    ### Define Functions ###
    #look for camera macs
    seecameras ()
    {
    if [ [ wl assoclist | grep A1:B1:C1:D1:E1:F1 || wl assoclist | grep A2:B2:C2:D2:E2:F2 || wl assoclist | grep A3:B3:C3:D3:E3:F3 ] ]; then
         return 0 # true
       else
         return 1 # false
    fi
    }
    
    #look for clients other than printer macs
    clientsminusprinters ()
    {
    ignoredmacs=$(wl assoclist | grep -v A1:B1:C1:D1:E1:F1 | grep -v A2:B2:C2:D2:E2:F2 | grep -v A3:B3:C3:D3:E3:F3)
    if [ -n "ignoredmacs" ] ; then
        return 0  # true
      else
        return 1  # false
      fi
    }
    
    #blink amber led function
    blinkamber () 
    { 
    led amber off
    sleep 1
    led amber on 
    }
    
    #client present leds
    clientleds ()
    {
    XFER=`ifconfig $I|grep bytes`
    if [ "$XFER" != "$PXFER" ]; then
    	LED=$clientactive
    	PXFER=$XFER
    	else
    	LED=$clientpresent
    fi
    if [ "$LED" != "$PLED" ]; then
            led $LED
            PLED=$LED
    fi
    }
    
    ### MAIN ###
    
    if [ [ seecameras && clientsminusprinters == 1 ] ]; then
    blinkamber
    
    elif [ [ clientsminusprinters && seecameras ] ]; then
    clientleds
    
    else
    #default command
    led $ledsoff
    fi
    done
    
     

Share This Page