[solved] Security LED Script WRT300n v1.1

Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Broadcom SoC based Hardware
Goto page Previous  1, 2, 3  Next
Author Message
fggs
DD-WRT Guru


Joined: 28 Jan 2008
Posts: 1741

PostPosted: Mon Feb 22, 2010 7:14    Post subject: Reply with quote
Can you paste line 9 as well?
Sponsor
DHC_DarkShadow
DD-WRT Guru


Joined: 22 Jun 2008
Posts: 2440
Location: Am now Dark_Shadow

PostPosted: Mon Feb 22, 2010 7:35    Post subject: Reply with quote
1. #!/bin/sh
2.
3. sleep 1
4. if "$(nvram get wl0_security_mode)" != "disabled"
5. then
6. gpio enable 3
7. else
8. gpio disable 3
9. fi

_________________
The New Me
fggs
DD-WRT Guru


Joined: 28 Jan 2008
Posts: 1741

PostPosted: Mon Feb 22, 2010 7:47    Post subject: Reply with quote
Did you removed the [[?

Line 4 should be: if [ "$(nvram get wl0_security_mode)" != "disabled" ]
DHC_DarkShadow
DD-WRT Guru


Joined: 22 Jun 2008
Posts: 2440
Location: Am now Dark_Shadow

PostPosted: Mon Feb 22, 2010 11:44    Post subject: Reply with quote
fggs wrote:
Did you removed the [[?

Line 4 should be: if [ "$(nvram get wl0_security_mode)" != "disabled" ]
Embarassed yea i sure did
ok this is the script

Code:
#!/bin/sh

sleep 1
if [ "$(nvram get wl0_security_mode)" != "disabled" ]
 then
 gpio enable 3
 else
 gpio disable 3
fi


No errors now, but it still turns on the led even when the security is disabled.

_________________
The New Me
DHC_DarkShadow
DD-WRT Guru


Joined: 22 Jun 2008
Posts: 2440
Location: Am now Dark_Shadow

PostPosted: Mon Feb 22, 2010 13:30    Post subject: Reply with quote
OK, this works from telnet

gpio enable 3 = turns security led off
gpio disable 3 = turns security led on

Code:
#!/bin/sh

sleep 1
if [ "$(nvram get wl0_security_mode)" != "disabled" ]
 then
 gpio disable 3
 else
 gpio enable 3
fi


however, when the script is place in /jffs/etc/config/security.if it doesn't work. It doesn't appear to do anything.

I can run the security.if from telnet and it still works.

_________________
The New Me
LOM
DD-WRT Guru


Joined: 28 Dec 2008
Posts: 7631

PostPosted: Mon Feb 22, 2010 13:43    Post subject: Reply with quote
Not that it will make any difference on your scripts ability to execute but why do have a != there?

Remove the ! and change the order of enable and disable.. Very Happy

_________________
Kernel panic: Aiee, killing interrupt handler!
DHC_DarkShadow
DD-WRT Guru


Joined: 22 Jun 2008
Posts: 2440
Location: Am now Dark_Shadow

PostPosted: Mon Feb 22, 2010 14:09    Post subject: Reply with quote
LOM wrote:
Not that it will make any difference on your scripts ability to execute but why do have a != there?

Remove the ! and change the order of enable and disable.. Very Happy
I copied part of another script, that's why it's there.

If you notice this works if run manually from telnet, how will swapping them change how a .if file is handled?

EDIT: swapped, it still runs manually and not in an .if

Code:
#!/bin/sh

#sleep 1
if [ "$(nvram get wl0_security_mode)" = "disabled" ]
 then
 gpio enable 3
 else
 gpio disable 3
fi

_________________
The New Me
LOM
DD-WRT Guru


Joined: 28 Dec 2008
Posts: 7631

PostPosted: Mon Feb 22, 2010 14:35    Post subject: Reply with quote
How about changing the extension to .sesbutton , does it work when you push the button?
_________________
Kernel panic: Aiee, killing interrupt handler!
DHC_DarkShadow
DD-WRT Guru


Joined: 22 Jun 2008
Posts: 2440
Location: Am now Dark_Shadow

PostPosted: Mon Feb 22, 2010 14:40    Post subject: Reply with quote
LOM wrote:
How about changing the extension to .sesbutton , does it work when you push the button?
is the "reserved" button the same as the sesbutton?

EDIT: NM, I tried it, it works.

_________________
The New Me
LOM
DD-WRT Guru


Joined: 28 Dec 2008
Posts: 7631

PostPosted: Mon Feb 22, 2010 14:55    Post subject: Reply with quote
So the automatic execute of .if files is broken..
_________________
Kernel panic: Aiee, killing interrupt handler!
DHC_DarkShadow
DD-WRT Guru


Joined: 22 Jun 2008
Posts: 2440
Location: Am now Dark_Shadow

PostPosted: Mon Feb 22, 2010 14:59    Post subject: Reply with quote
LOM wrote:
So the automatic execute of .if files is broken..
I didn't think about that, but your probably right. I am at work, so I will try to downgrade FW and see where it starts working again.
_________________
The New Me
DHC_DarkShadow
DD-WRT Guru


Joined: 22 Jun 2008
Posts: 2440
Location: Am now Dark_Shadow

PostPosted: Mon Feb 22, 2010 19:12    Post subject: Reply with quote
I have went all the way back to 12774, BS an Eko alike and cannot get an .if to run. run's via telnet but thats it.

Not sure where, but somewhere along the lines, .sesbutton stopped working correctly.

EDIT: I got the .sesbutton figured out. Script was different. It works now, but .if does not.

Am I the only one with a 300n v1.1 that has this problem?

_________________
The New Me
DHC_DarkShadow
DD-WRT Guru


Joined: 22 Jun 2008
Posts: 2440
Location: Am now Dark_Shadow

PostPosted: Mon Feb 22, 2010 20:33    Post subject: Reply with quote
Any body with a 300n v1.1 that the security light works correctly please post. Even if it don't work properly please post.
_________________
The New Me
phuzi0n
DD-WRT Guru


Joined: 10 Oct 2006
Posts: 10143

PostPosted: Mon Feb 22, 2010 22:13    Post subject: Reply with quote
Emildev was spot on with how to correctly execute the original script (but the script had disable/enable mixed up). It was designed to run as a background process, but now you've stripped out the loop so it will only check once and then exit. Removing the loop is how you would correctly adapt it as a .if script but it seems that not only are .if script gone, but also .ipup and .ipdown scripts as well. I can find no mention of any of the 3 in the source code.

You can rewrite it to be a single line in your startup script like so:

while sleep 1; do if [ `nvram get wl0_security_mode` = "disabled" ]; then gpio enable 3; else gpio disable 3; fi; done &

Tested and confirmed that this does fix the security LED on my wrt300n v1.1 though I never look at it anyways.

_________________
Read the forum announcements thoroughly! Be cautious if you're inexperienced.
Available for paid consulting. (Don't PM about complicated setups otherwise)
Looking for bricks and spare routers to expand my collection. (not interested in G spec models)
DHC_DarkShadow
DD-WRT Guru


Joined: 22 Jun 2008
Posts: 2440
Location: Am now Dark_Shadow

PostPosted: Mon Feb 22, 2010 22:40    Post subject: Reply with quote
And again, absolutely amazing Phuzi0n and Emildev!!

thanks to all who responded

Fix in first post, will add to wiki when I get home.

_________________
The New Me
Goto page Previous  1, 2, 3  Next Display posts from previous:    Page 2 of 3
Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Broadcom SoC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum