[solved] Security LED Script WRT300n v1.1

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


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

PostPosted: Mon Feb 22, 2010 4:07    Post subject: [solved] Security LED Script WRT300n v1.1 Reply with quote
Fixed by Phuzi0n

Copy & Paste to commands window, click save startup


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


Original Post
I would like somebody with some Linux scripting experience to look over this small script i wrote.

Background:
WRT300N v1.1 BS Build 13832 mini
The security led does not illuminate when security is set. A tick has been made on the issue.

Code:
gpio enable 3 = LED Off
gpio disable 3 = LED On


This is what I got:

Code:
#!/bin/sh

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


My next question is how to get it to run?

_________________
The New Me


Last edited by DHC_DarkShadow on Mon Feb 22, 2010 22:34; edited 1 time in total
Sponsor
jumran
DD-WRT User


Joined: 31 Jul 2009
Posts: 492
Location: Toronto, ON, CA

PostPosted: Mon Feb 22, 2010 4:18    Post subject: Reply with quote
Eko had previously fixed this issue after I reported it for the WRT150N. Not sure if you can figure it out based on the source code below.

http://svn.dd-wrt.com:8000/dd-wrt/changeset/13241
fggs
DD-WRT Guru


Joined: 28 Jan 2008
Posts: 1720

PostPosted: Mon Feb 22, 2010 4:18    Post subject: Reply with quote
Save as startup script perhaps?
DHC_DarkShadow
DD-WRT Guru


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

PostPosted: Mon Feb 22, 2010 4:56    Post subject: Reply with quote
Somethings wrong with the script, it doesn't do anything when I run it through the "run command" in the GUI.
_________________
The New Me
fggs
DD-WRT Guru


Joined: 28 Jan 2008
Posts: 1720

PostPosted: Mon Feb 22, 2010 5:04    Post subject: Reply with quote
I don't think "Run commands" is capable of handling scripts..
DHC_DarkShadow
DD-WRT Guru


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

PostPosted: Mon Feb 22, 2010 5:10    Post subject: Reply with quote
Is the script ok then? I have almost zero linux knowledge and even less scripting. The only way I git this is piecing together bits and pieces.
_________________
The New Me
fggs
DD-WRT Guru


Joined: 28 Jan 2008
Posts: 1720

PostPosted: Mon Feb 22, 2010 5:26    Post subject: Reply with quote
Try this way:

Code:
#!/bin/sh

sleep 1 
  if [ "$(nvram get wl0_security_mode)" != "disabled" ]
  then
  gpio enable 3
  else
  gpio disable 3
  fi
done
DHC_DarkShadow
DD-WRT Guru


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

PostPosted: Mon Feb 22, 2010 5:28    Post subject: Reply with quote
I have jffs enabled and a directory in it named etc. In etc I have "security.if"

Now correct me if I am wrong and I probably am, ".if" gets run when an interface goes up right?

_________________
The New Me
emildev
DD-WRT User


Joined: 12 Dec 2009
Posts: 70

PostPosted: Mon Feb 22, 2010 5:31    Post subject: Reply with quote
Goto Admin Commands

Save as startup:

sleep 30;/tmp/custom.sh &

This will run the Custom Script 30 seconds after router is online

Save as custom;

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

Your script structure is fine, not too sure about the query, never used that.

Another way to test first without rebooting everytime;

Save the script somewhere, make sure it is executable: chmod +x script and then run it as ./script.

E
DHC_DarkShadow
DD-WRT Guru


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

PostPosted: Mon Feb 22, 2010 5:45    Post subject: Reply with quote
ok misread the wiki

Have /jffs/etc/config/security.if

tried my script again = no go
tried fggs script = no go

_________________
The New Me
DHC_DarkShadow
DD-WRT Guru


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

PostPosted: Mon Feb 22, 2010 6:00    Post subject: Reply with quote
new development

ran the script via telnet

Code:
#!/bin/sh

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


result was

Code:
root@WRT300N v1:/jffs/etc/config# ./security.if
./security.if: line 10: syntax error: "done" unexpected

_________________
The New Me
fggs
DD-WRT Guru


Joined: 28 Jan 2008
Posts: 1720

PostPosted: Mon Feb 22, 2010 6:07    Post subject: Reply with quote
Remove "done" from the script.
DHC_DarkShadow
DD-WRT Guru


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

PostPosted: Mon Feb 22, 2010 6:31    Post subject: Reply with quote
i did and reran from telnet and it works, sortof.

With security enabled it turned the light on

When I select disabled it says disabled not found and the light does not go out.

Code:
root@WRT300N v1:/jffs/etc/config# ./security.if
./security.if: line 9: disabled: not found

_________________
The New Me
fggs
DD-WRT Guru


Joined: 28 Jan 2008
Posts: 1720

PostPosted: Mon Feb 22, 2010 6:49    Post subject: Reply with quote
With security set as disabled, type "nvram get wl0_security_mode" without "" and see what it reports..
DHC_DarkShadow
DD-WRT Guru


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

PostPosted: Mon Feb 22, 2010 7:11    Post subject: Reply with quote
fggs wrote:
With security set as disabled, type "nvram get wl0_security_mode" without "" and see what it reports..
disabled
_________________
The New Me
Goto page 1, 2, 3  Next Display posts from previous:    Page 1 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