Author
Message
DHC_DarkShadow DD-WRT Guru Joined: 22 Jun 2008 Posts: 2440 Location: Am now Dark_Shadow
Posted: Mon Feb 22, 2010 4:07 Post subject: [solved] Security LED Script WRT300n v1.1
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
Back to top
Sponsor
jumran DD-WRT User Joined: 31 Jul 2009 Posts: 492 Location: Toronto, ON, CA
Back to top
fggs DD-WRT Guru Joined: 28 Jan 2008 Posts: 1741
Posted: Mon Feb 22, 2010 4:18 Post subject:
Save as startup script perhaps?
Back to top
DHC_DarkShadow DD-WRT Guru Joined: 22 Jun 2008 Posts: 2440 Location: Am now Dark_Shadow
Posted: Mon Feb 22, 2010 4:56 Post subject:
Somethings wrong with the script, it doesn't do anything when I run it through the "run command" in the GUI. _________________The New Me
Back to top
fggs DD-WRT Guru Joined: 28 Jan 2008 Posts: 1741
Posted: Mon Feb 22, 2010 5:04 Post subject:
I don't think "Run commands" is capable of handling scripts..
Back to top
DHC_DarkShadow DD-WRT Guru Joined: 22 Jun 2008 Posts: 2440 Location: Am now Dark_Shadow
Posted: Mon Feb 22, 2010 5:10 Post subject:
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
Back to top
fggs DD-WRT Guru Joined: 28 Jan 2008 Posts: 1741
Posted: Mon Feb 22, 2010 5:26 Post subject:
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
Back to top
DHC_DarkShadow DD-WRT Guru Joined: 22 Jun 2008 Posts: 2440 Location: Am now Dark_Shadow
Posted: Mon Feb 22, 2010 5:28 Post subject:
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
Back to top
emildev DD-WRT User Joined: 12 Dec 2009 Posts: 70
Posted: Mon Feb 22, 2010 5:31 Post subject:
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
Back to top
DHC_DarkShadow DD-WRT Guru Joined: 22 Jun 2008 Posts: 2440 Location: Am now Dark_Shadow
Posted: Mon Feb 22, 2010 5:45 Post subject:
ok misread the wiki
Have /jffs/etc/config /security.if
tried my script again = no go
tried fggs script = no go _________________The New Me
Back to top
DHC_DarkShadow DD-WRT Guru Joined: 22 Jun 2008 Posts: 2440 Location: Am now Dark_Shadow
Posted: Mon Feb 22, 2010 6:00 Post subject:
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
Back to top
fggs DD-WRT Guru Joined: 28 Jan 2008 Posts: 1741
Posted: Mon Feb 22, 2010 6:07 Post subject:
Remove "done" from the script.
Back to top
DHC_DarkShadow DD-WRT Guru Joined: 22 Jun 2008 Posts: 2440 Location: Am now Dark_Shadow
Posted: Mon Feb 22, 2010 6:31 Post subject:
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
Back to top
fggs DD-WRT Guru Joined: 28 Jan 2008 Posts: 1741
Posted: Mon Feb 22, 2010 6:49 Post subject:
With security set as disabled, type "nvram get wl0_security_mode" without "" and see what it reports..
Back to top
DHC_DarkShadow DD-WRT Guru Joined: 22 Jun 2008 Posts: 2440 Location: Am now Dark_Shadow
Posted: Mon Feb 22, 2010 7:11 Post subject:
fggs wrote: With security set as disabled, type "nvram get wl0_security_mode" without "" and see what it reports..
disabled _________________The New Me
Back to top