Script Execution
From DD-WRT Wiki
Revision as of 08:15, 5 June 2009 (edit) Markus (Talk | contribs) (Undo revision 25564 by Ausimus1 (Talk)) ← Previous diff |
Revision as of 01:13, 8 June 2009 (edit) (undo) Dr. Ongo (Talk | contribs) m Next diff → |
||
Line 1: | Line 1: | ||
You are here: '''[[Main_Page|DD-WRT wiki mainpage]] / [[Index:Scripting|Scripting]] / Script Execution | You are here: '''[[Main_Page|DD-WRT wiki mainpage]] / [[Index:Scripting|Scripting]] / Script Execution | ||
- | =Introduction= | + | ==Introduction== |
- | Sometimes you want | + | Sometimes you want scripts to be executed automatically when something happens, this article explains how to make sure scripts get executed at a certain point. |
- | =General | + | ==General Information== |
There are four different directories DD-WRT searches for scripts, these are | There are four different directories DD-WRT searches for scripts, these are | ||
- | + | */etc/config/ | |
- | + | */jffs/etc/config/ | |
- | + | */mmc/etc/config/ | |
- | + | */tmp/etc/config/ | |
- | =Script | + | ==Script Types== |
- | You need to add an extension to the script if placed in one of the previous folders. Every extension has | + | You need to add an extension to the script if placed in one of the previous folders. Every extension has its own meaning. |
Line 22: | Line 22: | ||
|- | |- | ||
| .wanup | | .wanup | ||
- | | will be executed whenever an interface goes up (ex: | + | | will be executed whenever an interface goes up (ex: PPP connection is reestablished after a disconnect, goes up first time) and: _after_ firewall stuff, so good ending for custom QoS and stuf. |
|- | |- | ||
| .if | | .if | ||
- | | will be executed whenever an interface goes up (ex: | + | | will be executed whenever an interface goes up (ex: PPP connection is re-established after a disconnect, goes up first time) and: _after_ firewall stuff, so good ending for custom QoS and stuff - .wanup - should be a better place for disconnect/reconnect events than the ones above |
|- | |- | ||
| .ipup | | .ipup | ||
- | |is run when | + | |is run when PPP connection is reestablished after a disconnect, _after_ firewall stuff. |
|- | |- | ||
| .ipdown | | .ipdown | ||
- | | is run when a | + | | is run when a PPP connection has been shut down |
|- | |- | ||
| .sesbutton | | .sesbutton | ||
Line 37: | Line 37: | ||
|} | |} | ||
- | =Execute | + | ==Execute Scripts with a Different Extension or in a Different Folder== |
If you want to execute scripts with a different extension or those that are located in an other folder you can create this script | If you want to execute scripts with a different extension or those that are located in an other folder you can create this script | ||
- | + | <pre> | |
- | + | for I in `/bin/ls /jffs/etc/config/*.myextension`;do | |
- | + | sh $I & | |
- | + | done | |
- | + | </pre> | |
Of course you need to change the path (/jffs/etc/config) and the extension itself to match your desire. | Of course you need to change the path (/jffs/etc/config) and the extension itself to match your desire. | ||
- | ==How | + | ==How It Works== |
- | The command ''sh /jffs/etc/config/*.myextension'' will execute every script ending in | + | The command ''sh /jffs/etc/config/*.myextension'' will execute every script ending in .myextension found in the /jffs/etc/config directory. By setting this as the rc_startup value, your *.myextension scripts will load every time the router boots. |
- | =Links= | + | ==Links== |
[[Useful Scripts]] | [[Useful Scripts]] |
Revision as of 01:13, 8 June 2009
You are here: DD-WRT wiki mainpage / Scripting / Script Execution
Contents |
Introduction
Sometimes you want scripts to be executed automatically when something happens, this article explains how to make sure scripts get executed at a certain point.
General Information
There are four different directories DD-WRT searches for scripts, these are
- /etc/config/
- /jffs/etc/config/
- /mmc/etc/config/
- /tmp/etc/config/
Script Types
You need to add an extension to the script if placed in one of the previous folders. Every extension has its own meaning.
Extension | Explanation |
.startup | will be executed on system startup, normally boot-time and: _before_ the firewall is configured |
.wanup | will be executed whenever an interface goes up (ex: PPP connection is reestablished after a disconnect, goes up first time) and: _after_ firewall stuff, so good ending for custom QoS and stuf. |
.if | will be executed whenever an interface goes up (ex: PPP connection is re-established after a disconnect, goes up first time) and: _after_ firewall stuff, so good ending for custom QoS and stuff - .wanup - should be a better place for disconnect/reconnect events than the ones above |
.ipup | is run when PPP connection is reestablished after a disconnect, _after_ firewall stuff. |
.ipdown | is run when a PPP connection has been shut down |
.sesbutton | is executed when the SES/AOSS/EZ-SETUP button is pressed |
Execute Scripts with a Different Extension or in a Different Folder
If you want to execute scripts with a different extension or those that are located in an other folder you can create this script
for I in `/bin/ls /jffs/etc/config/*.myextension`;do sh $I & done
Of course you need to change the path (/jffs/etc/config) and the extension itself to match your desire.
How It Works
The command sh /jffs/etc/config/*.myextension will execute every script ending in .myextension found in the /jffs/etc/config directory. By setting this as the rc_startup value, your *.myextension scripts will load every time the router boots.