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

stealthMode script for Asus RT-AC68U

Discussion in 'Tomato Firmware' started by alllexx, Aug 27, 2014.

  1. alllexx

    alllexx Reformed Router Member

    stealthMode script by Monter & Shibby only supports RT-N16, RT-N66U and RT-AC66U routers as of now. However, if you slightly "hack" the script and force to think the router is N66U, it works for AC68U, except for not turning off the power led. After trying to enable different gpio's one by one, I found that you have to issue `/sbin/gpio enable 3` to disable the power led.

    So, what do we have now? LAN, WAN and WLAN leds can be disabled the same way it's done for n66u, and power led is disabled with `/sbin/gpio enable 3`. The only leds left are the two usb leds, but those leds are always off whatever you do with the latest Shibby's build anyway. Hence, until ac68u is officially supported, I store this script on my jffs partition and use it to turn the leds off/on:

    Code:
    #!/bin/sh
    #
    # Turn off/on all led for Asus routers RT-N16 and RT-N66U and RT-AC66U
    #
    # Version: 0.10 "Sunset"
    # Authors: Monter, Shibby
    #
    # Unlock lan ports, Permanent On function, Sunset mode,
    # Scheduler mode and Clear All option written by Monter
    
    # configuration
    VERSION="v0.10"
    # /configuration
    
    # Please do not make any changes in the code below without authors permission
    # Send your bug report to monter[at]techlog.pl
    
    dir=`/bin/echo $( cd "$(/usr/bin/dirname "$0")" ; /bin/pwd -P )`
    stms=`/usr/bin/basename ${0}`
    
        case "$1" in
            on)
                /usr/sbin/et robowr 0x00 0x18 0x1e0
                /bin/sleep 1 # strobo effect
                $dir/$stms perm_on
                /usr/bin/logger -p6 -s -t stealthMode Activated
                /usr/sbin/cru a stealthmode "*/5 * * * * $dir/$stms perm_on"
            ;;
            sun)
                if /usr/bin/[ "$2" != "" -a "0$(/bin/echo $2 | /usr/bin/tr -d ' ')" -ge 0 ] 2>/dev/null; then
                    /usr/bin/logger -p6 -s -t stealthMode Sunset Enabled
                    /usr/sbin/cru a stealthsun_on "0 2 * * * $dir/$stms sun_on $2"
                    $dir/$stms sun_on $2
                else
                    /usr/bin/logger -p3 -s -t stealthMode Sunset error - the city code does not specified!
                    $dir/$stms
                    exit 1
                fi
            ;;
            sun_on)
                # check internet connection
                CONERR=1
                YAHOOAPIS="weather.yahooapis.com"
    
                if /usr/bin/[ `/bin/echo $YAHOOAPIS | /usr/bin/wc -c` -gt 2 ]; then
                  /bin/ping -q -w 1 -c 1 $YAHOOAPIS > /dev/null
                  if /usr/bin/[ $? == 0 ]; then CONERR=0; fi
                fi
    
                # result of internet connection check
                if /usr/bin/[ "$CONERR" -ne 0 ] ; then
                    /usr/bin/logger -p3 -s -t stealthMode Sunset error - no active Internet connection!
                    $dir/$stms
                    exit 1
                else
                    if /usr/bin/[ "$2" != "" -a "0$(/bin/echo $2 | /usr/bin/tr -d ' ')" -ge 0 ] 2>/dev/null; then
                        $dir/$stms sch_clear # clear scheduled tasks when sunset is enabled
                        sun=`l=$2;/usr/bin/wget -q -O - http://weather.yahooapis.com/forecastrss?w=$l | /bin/grep astronomy | /usr/bin/awk -F\" '{print $4}' | /usr/bin/awk -F\" '{split($1, A, " ");split(A[1], B, ":");HR=B[1];MIN=B[2];if(A[2] == "pm") HR+=12;$1=sprintf("%d %d", MIN, HR);}1'`
                        if /usr/bin/[ "$sun" = "" ] ; then /usr/bin/logger -p3 -s -t stealthMode Weather sunset time error!; exit 1; else /usr/sbin/cru a stealthsunset $sun "* * * $dir/$stms on"; fi
                        sur=`l=$2;/usr/bin/wget -q -O - http://weather.yahooapis.com/forecastrss?w=$l | /bin/grep astronomy | /usr/bin/awk -F\" '{print $2}' | /usr/bin/awk -F\" '{split($1, A, " ");split(A[1], B, ":");HR=B[1];MIN=B[2];if(A[2] == "pm") HR+=12;$1=sprintf("%d %d", MIN, HR);}1'`
                        if /usr/bin/[ "$sur" = "" ] ; then /usr/bin/logger -p3 -s -t stealthMode Weather sunrise time error!; exit 1; else /usr/sbin/cru a stealthsunrise $sur "* * * $dir/$stms off"; fi
                        /usr/bin/logger -p6 -s -t stealthMode Sunset city code: $2, sunset: $( /bin/echo $sun | /usr/bin/awk '{$1=sprintf("%02d", $1); print $2":"$1 }' ), sunrise: $( /bin/echo $sur | /usr/bin/awk '{$1=sprintf("%02d", $1); print $2":"$1 }' )
                        HOUR=$(/bin/date +%k); SUNRUN=$( /bin/echo $sun | /usr/bin/awk '{ print $2 }' ); SURRUN=$( /bin/echo $sur | /usr/bin/awk '{ print $2 }' ); if /usr/bin/[ "$HOUR" -ge "$SURRUN" -a "$HOUR" -le "$SUNRUN" ] ; then
                            /usr/bin/logger -p6 -s -t stealthMode The time now is $( /bin/date +%H:%M), so StealthMode will be activated at next sun set
                        else
                            $dir/$stms on
                        fi
                    else
                        /usr/bin/logger -p3 -s -t stealthMode Sunset error - the city code does not specified!
                        $dir/$stms
                        exit 1
                    fi
                fi
            ;;
            perm_on)
                    /usr/sbin/wl -i eth2 leddc 1
                    /sbin/gpio enable 3 #power led
                    /sbin/gpio enable 4 #white led at the back
                /usr/sbin/et robowr 0x00 0x18 0x1e0
                /usr/sbin/et robowr 0x00 0x1a 0x1e0
                /usr/sbin/wl -i eth1 leddc 1
            ;;
            sun_off)
                /usr/bin/logger -p6 -s -t stealthMode Sunset Disactivated
                /usr/sbin/cru d stealthsun_on
                /usr/sbin/cru d stealthsunset
                /usr/sbin/cru d stealthsunrise
                $dir/$stms off
            ;;
            sch_on)
                if /usr/bin/[ "${2}" != "" -a "${2}" -le 23 -a "0$(/bin/echo $2 | /usr/bin/tr -d ' ')" -ge 0 ] 2>/dev/null; then
                  if /usr/bin/[ "${3}" != "" -a "${3}" -le 59 -a "${3}" -eq "${3}" ] 2>/dev/null; then SCHMIN=${3}; else SCHMIN="0"; fi
                  /usr/sbin/cru a stealthsheduleon $SCHMIN $2 "* * * $dir/$stms on"
                  /usr/bin/logger -p6 -s -t stealthMode Scheduled On set to $2:$(/usr/bin/printf "%02d" $SCHMIN)
                else
                  /usr/bin/logger -p3 -s -t stealthMode Scheduled On error - Hour / Minutes does not specified!
                  $dir/$stms
                  exit 1
                fi
            ;;
            sch_off)
                if /usr/bin/[ "${2}" != "" -a "${2}" -le 23 -a "0$(/bin/echo $2 | /usr/bin/tr -d ' ')" -ge 0 ] 2>/dev/null; then
                  if /usr/bin/[ "${3}" != "" -a "${3}" -le 59 -a "${3}" -eq "${3}" ] 2>/dev/null; then SCHMIN=${3}; else SCHMIN="0"; fi
                  /usr/sbin/cru a stealthsheduleoff $SCHMIN $2 "* * * $dir/$stms off"
                  /usr/bin/logger -p6 -s -t stealthMode Scheduled Off set to $2:$(/usr/bin/printf "%02d" $SCHMIN)
                else
                  /usr/bin/logger -p3 -s -t stealthMode Scheduled Off error - Hour / Minutes does not specified!
                  $dir/$stms
                  exit 1
                fi
            ;;
            sch_clear)
                /usr/sbin/cru d stealthsheduleon
                /usr/sbin/cru d stealthsheduleoff
                /usr/bin/logger -p6 -s -t stealthMode Scheduler Tasks Deleted
            ;;
            clear_all)
                $dir/$stms sun_off
                $dir/$stms sch_clear
                /usr/bin/logger -p6 -s -t stealthMode Complete shutdown and delete all jobs from Crontab - done
            ;;
            off)
                /usr/sbin/cru d stealthmode
                    /usr/sbin/wl -i eth2 leddc 0
                    /sbin/gpio disable 3 #power led
                    /sbin/gpio disable 4 #white led at the back
                /usr/sbin/et robowr 0x00 0x18 0x1ff
                /usr/sbin/et robowr 0x00 0x1a 0x1ff
                /bin/sleep 1 # delay before repeat off commands - strobo error fix
                /usr/sbin/et robowr 0x00 0x18 0x1ff
                /usr/sbin/et robowr 0x00 0x1a 0x1ff
                /usr/sbin/wl -i eth1 leddc 0
                /usr/bin/logger -p6 -s -t stealthMode Disactivated
            ;;
            *)
                /bin/echo "stealthMode Sunset ${VERSION} by Monter"
                /usr/bin/logger -p1 -s -t Usage "$stms {on|off|sun <city_code>|sun_off|sch_on <H> <M>|sch_off <H> <M>|sch_clear|clear_all}"
                /bin/echo
                /bin/echo " [Standard mode]"
                /bin/echo "   on | off        - enable or disable steathMode in real time"
                /bin/echo
                /bin/echo " [Sunset mode]"
                /bin/echo "   sun <city_code> - will daily get the sunrise and sunset times of a specific"
                /bin/echo "                     location automatically and activate Sunset mode"
                /bin/echo "                     To be able to determine your <city_code> you need to first"
                /bin/echo "                     go to http://weather.yahoo.com/ and look up your location"
                /bin/echo "                     The last NUMBERS in the URL will be your <city_code>"
                /bin/echo "                     Example: \"$stms sun 514048\" if you live in Poznan/Poland ;)"
                /bin/echo "                     This feature requires a working Internet connection"
                /bin/echo "   sun_off         - fully deactivate Sunset mode"
                /bin/echo
                /bin/echo " [Scheduled mode]"
                /bin/echo "   sch_on <H> <M>  - set the hour and minutes of the scheduled enable/disable"
                /bin/echo "   sch_off <H> <M>   stealthMode in Standard mode and adding jobs to the Crontab"
                /bin/echo "                     Hour and minute time must be a numbers without any additional"
                /bin/echo "                     characters, where hour is a mandatory parameter, while not"
                /bin/echo "                     specifying an minute will assign a default 00 value"
                /bin/echo "                     These options add just the right job for Crontab, nothing more"
                /bin/echo "   sch_clear       - removes tasks from Crontab for scheduled enable/disable"
                /bin/echo "                     stealthMode function set by sch_on and sch_off switches"
                /bin/echo
                /bin/echo " [Repair / debug]"
                /bin/echo "   clear_all       - removes all jobs from Crontab and completely disables all"
                /bin/echo "                     available stealthMode modes"
                /bin/echo
                exit 1
        esac
    
    @Monter & Shibby: sorry for violating the "Please do not make any changes in the code below without authors permission" part! Just wanted to share this with other ac68u users until you add support for ac68u in the next versions.

    Regards,
    Alex
     
    Last edited: Sep 5, 2014
    Lugoues likes this.
  2. alllexx

    alllexx Reformed Router Member

    There's another led that I missed out: the white led at the back. You can disable and enable it with `/sbin/gpio enable 4` and `/sbin/gpio disable 4` respectively
     
  3. blackmack

    blackmack Addicted to LI Member

    Thanks for the script. Especially back logo light was really annoying at night. I found that USB leds can be controlled with "/sbin/gpio disable 14" for USB 3.0 and "led usb on" for 2.0.
     
  4. alllexx

    alllexx Reformed Router Member

    You're welcome :) Just note that all the credits for this script go to Monter & Shibby ;)
    Thanks for the info on usb leds
     
  5. meazz1

    meazz1 Addicted to LI Member

    does this script work for Asus RT AC56U?
     
  6. bpkengor

    bpkengor New Member Member

    Way dumb question, I know: how does one get this script to run? In Administration Scripts? if yes in the Init section?

    and, does this become a permanent setting? how does one "toggle" back to LED lights displaying? delete/disable the script?
     
  7. dc361

    dc361 LI Guru Member

    Not a dumb question at all.. on my RT-AC68U, I have the edited script on a usb stick and I have the following line in my firewall script (Administration->Scripts->Firewall(tab))

    /mnt/sda1/stealthMode sun 3789

    This tells the script to enable 'sun' mode (turn the leds off when the sun goes down and on again at sunrise.) The 3789 is the city code for my city - you can lookup this code by going to https://weather.yahoo.com/ and looking up the weather for your city. When the page displays, look at the URL in the browser and the city code will be included. In my case the URL is: https://weather.yahoo.com/canada/prince-edward-island/charlottetown-3789/

    Good luck..
     
  8. Brian_E

    Brian_E Connected Client Member

    So let's say I wanted to turn off all leds, including the white one at the rear, at 10.30pm and back on at 6.00am, exactly what code would I need to add and would it go in the jffs partition? Also, perhaps a stupid question but I can't remember where to access the jffs partition in Tomato (I'm currently using Merlin's firmware and I use WinSCP to access the jffs partition) - is it accessible via the GUI?
     
  9. dc361

    dc361 LI Guru Member

    Ok.. to use jffs, you have to enable it first by going to the Administration->JFFS menu of the tomato web interface.

    Once it is enabled, copy the script from the first post above and create file called stealthMode with the contents. Use WinSCP to copy the file/script to the /jffs directory on the router.

    This next procedure may be unnecessary but you did say you wanted 'exactly' the commands.. At this point the stealthMode file should be in /jffs so we need to set it as executable. You could SSH into the router to do this or
    go to the TOOLS->System Commands page on the web interface and enter the following command and then press the execute button at the bottom of the page:

    chmod a+x /jffs/stealthMode


    Next, using the web interface on the router go to Administration->Scripts from the menu on the left and then click the firewall tab at the top of the window on the right. Enter the following two commands in text area and press save at the bottom of the page:

    /jffs/stealthMode sch_on 22 30
    /jffs/stealthMode sch_off 6 00

    Good luck..
     
  10. Brian_E

    Brian_E Connected Client Member

    I couldn't access the router with WinSCP ("access denied"), so given the other apparent problems with the current Shibby build, I have put Merlin's firmware back on for now. I'll maybe come back to this later.
     
  11. dc361

    dc361 LI Guru Member

    With WinSCP, you need to make sure it is in SCP mode and not SFTP plus use the username root not admin.
     
  12. Brian_E

    Brian_E Connected Client Member

    OK thanks. I'll give it a go next week when my daughter goes back to school. By the way, I may try Shibby build 132 next time, rather than 134. Do you happen to know whether the leds for the USB devices work with that build on an RT-AC68U (they don't with build 134 as others have noted)?
     
  13. Brian_E

    Brian_E Connected Client Member

    Actually, I managed to find time to do this early this morning, before anyone else was awake.

    It seems to be working OK; the only exception being the led for the USB (which lights the USB 2 led, even though my memory stick is plugged into the USB 3 socket), which stays on even when all the other lights have gone off.
     
  14. mcpatric

    mcpatric New Member Member

Share This Page