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

Disable Wireless after reboot/power loss?

Discussion in 'Tomato Firmware' started by DOOManiac, Jul 28, 2007.

  1. DOOManiac

    DOOManiac LI Guru Member

    Hey guys. First let me say that I love Tomato. Fantastic stuff. :D

    Let me apologize if this is something that has come up and been answered already, but I honestly did search and couldn't find anything.

    I like to keep my wireless turned off except for when I'm explicitly using it, either for my Wii, Laptop, or iPhone. Then it's just a simple touch of the SES button, and all is good on the world.

    Except for when the phone reboots.

    Whenever the phone restarts, either from a power loss, the admin interface, from a cron, the wireless comes back on. I've got it disabled in the admin page, but that doesn't seem to matter.

    Is there a way I can force the wireless to turn off whenever the router reboots? I tried adding 'wl radio off', which I found in a thread here, to the Init section (both above and below my cron addition for the Sunday reboot), but no dice.

    Thanks for any help you can give me w/ this. I'll appreciate it.
     
  2. yaqui

    yaqui LI Guru Member

    Try putting this in init:
    Code:
    while [ true ] ; do
    service wlan stop
    done
     
  3. DOOManiac

    DOOManiac LI Guru Member

    I'm not too familiar w/ shell scripting (as opposed to other coding), but wouldn't this just put the service stop command in an infinite loop? Where is it gonna exit?
     
  4. yaqui

    yaqui LI Guru Member

    Yes you said wireless was not stopping so I figured that would stop it and keep stopping it!

    This should keep checking to see if it is stopped... and if it is stopped it won't stop it again.
    Code:
    messages=/var/log/messages
    while [ true ] ; do
    if ! grep -q "wlan stopped" $messages ; then 
    service wlan stop
    logger service wlan stopped
    fi
    done
     
  5. Overflow-ar

    Overflow-ar LI Guru Member

    shouldn't this have a sleep?, to avoid the script being executed several times each second and hog all cpu resorces.
     
  6. yaqui

    yaqui LI Guru Member

    I suppose you could, I didn't think that it would execute that many times between wlan stopping and logging.

    So I guess put sleep 5 between service wlan stop and the logger... not sure how much time it may need.

    Edit: plus it may re-run without need, when the log file cycles through and the message is gone. If someone has a more viable method please add!

    I wanted to do a grep on services running but not sure how you see that... "ps" does not show wlan - unless it is called something else, or running under some other process name that can be grepped ??????
     
  7. yaqui

    yaqui LI Guru Member

    netstat -r
    shows the iface's but I don't see wlan

    I know eth1 is for wireless but I don't see that listed either.. hmm

    and 'chkconfig' doesn't exist in this shell!

    Maybe this will work:
    Code:
    while [ true ] ; do
    if netstat -r | grep -q "eth1" ; then 
    service wlan stop
    logger service wlan stopped
    fi
    done
     
  8. DOOManiac

    DOOManiac LI Guru Member

    Is there a way you can do an 'at' on this thing?

    I'd rather not deal w/ a lot of complex looping stuff. If I could just do "at 1 minute service stop wlan" or whatever the syntax for the at is. That seems like it would be a lot easier...


    Also, I don't want to force the wireless to always be off. Sometimes I'll want to turn it on. I just don't want it coming on by default whenever the router resets...
     
  9. t4thfavor

    t4thfavor Network Guru Member

    Find the ses button script, and set it up to do a 1 minute stop when it is pushed, and then a 1 minute start when it is pushed again. I am sure that the button script is documented somewhere.
     
  10. yaqui

    yaqui LI Guru Member

    Just put this in init then, I will only run it the one time when the router runs the init script.
    Code:
    sleep 5
    service wlan stop
    logger service wlan stopped
    
    There, there is no looping now.
    Or, if you want just a simple check to see wireless is enabled and try to shut it down once at start up; try this:
    Code:
    sleep 5
    if dmesg | grep -q "eth1" ; then 
    service wlan stop
    logger wlan should now have been stopped this one time
    fi 
     
  11. DOOManiac

    DOOManiac LI Guru Member

    Thanks for the reply, but neither of these work for me. Wireless turns on, then I'm guessing this script runs because it turns off, but then about 15 seconds later wireless comes back on again. If I increase the sleep duration that doesn't help any.
     
  12. yaqui

    yaqui LI Guru Member

    Setup a cron to do it every minute:
    Place in init:
    Code:
    sleep 5
    cru a stopwireless "* * * * * service wlan stop"
     
  13. DOOManiac

    DOOManiac LI Guru Member

    But I don't want a cron to turn it off every minute. I do use wireless occassionally and don't want it shutting off while I'm using it. That's why I'd love the SES toggle. But I just don't use it most of the time, hence me wanting it off a lot.

    It's kind of odd that with all the awesome things Tomato does it can't do something so simple, turning off the wireless radio and keeping it off, that every manufacturer's firmware I've ever seen does. Even Linksys and Netgear manage to do that right. :/
     
  14. yaqui

    yaqui LI Guru Member

    Can anyone esle confirm:
    Tomato v1.07
    unchecking
    Basic > Network > UNCHECK Enable Wireless > and hit SAVE

    Unchecking does not survive a power loss and/or reboot? It seems as if mine does survive and works fine ("no wireless" setting remains).

    After power loss - still unchecked and still no eth1 in netstat -r
     

    Attached Files:

  15. DOOManiac

    DOOManiac LI Guru Member

    This may be part of the confusion. In the interface I was using Status (Overview) > Wireless > Disable button. It's this that doesn't survive a power loss.

    Trying Basic > Wireless > Unchecking box + save disables it across reboots, however it breaks the SES button's wireless toggle. :(
    It seems I can't help but be a pain in the ass to you guys.
     
  16. yaqui

    yaqui LI Guru Member

    I don't think the setting on that page saves it to nvram; just have to use the other setting. Maybe the Tomato authors will make the SES button work how you want it to.... I still don't understand.

    There is probably some way to program the SES button in a script to get it working how you want.

    I still don't know what you meant by "phone" either.
     
  17. DOOManiac

    DOOManiac LI Guru Member

    Boy do I feel dumb. I just went back and read my original post:

    Oops. I meant whenever the router restarts.... :doh:

    No wonder I sow confusion around here. :(
     
  18. yaqui

    yaqui LI Guru Member

    Go to Administration > Buttons / LED > set 0-2 seconds pull-down menu to "Run custom script" > Then paste the below into custom script box > hit: SAVE

    Put in custom script box:
    Code:
    wlstate=$(nvram get wl_radio)
    
    if [ $wlstate = "0" ] ; then
       nvram set wl_radio=1
       led wlan on
       onstate=$(nvram get wl_radio)
       logger wireless is now ON and wl_radio is $onstate
       nvram commit
       kill -HUP 1
       elif [ $wlstate = "1" ] ; then
            nvram set wl_radio=0
            led wlan off
            offstate=$(nvram get wl_radio)
            logger wireless is now OFF and wl_radio is $offstate
            nvram commit
            kill -HUP 1
    fi
    I think that may be what you need, it looks up the setting of wl_radio (on or off) and will enable the button to toggle and save the setting to NVRAM, thus surviving power-loss.
     
  19. DOOManiac

    DOOManiac LI Guru Member

    I tried this, but it didn't work either. :/
    Pushing the SES button seemed to do nothing. I also tried changing the elsif to plain else and that didn't do it either.

    Oh well, I guess I'll just live w/ the wireless being on after reboots. Thanks for all the time you spent trying to help me though! I really do appreciate it.
     
  20. yaqui

    yaqui LI Guru Member

    Tested:
    Pushed Button,
    waited 10 seconds,
    checked settings and wireless was shut off,
    then unplugged and rebooted,
    wireless remained off.

    Not sure why it didn't work for you.

    Works great !
     
  21. linkuser9

    linkuser9 Guest

    Hi guys. I too want to turn off the wireless by default on a WRT54G v.8.
    The linksys firmware defaults to ON/UNSECURED if you hit the reset button. I'm fearful that someone will accidentally reset the router and expose our network unsecured. Or that the firmware will crash or some other unknown issue will cause a reset. I want the wireless to remain OFF unless I manually turn it on and configure WPA encryption. I would want it to survive reboots AND resets if possible.

    What router are you guys running Tomato on? Not sure from this thread.

    Thanks!
     

Share This Page