Script Execution

From DD-WRT Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 05:51, 27 July 2007 (edit)
200.92.91.77 (Talk)
(General infomration)
← Previous diff
Revision as of 17:41, 22 March 2012 (edit) (undo)
Donny (Talk | contribs)
m (Script Types - WinSCP permissions)
Next diff →
(20 intermediate revisions not shown.)
Line 1: Line 1:
-=Introduction=+You are here: '''[[Main_Page|DD-WRT wiki mainpage]] / [[Index:Scripting|Scripting]] / Script Execution
-Sometimes you want script to be executed automatically when something happens, this article explains how to make sure scripts get executed at a certainpoint.+==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==
-=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/+*/etc/config/
- /jffs/etc/config/+*/jffs/etc/config/
- /mmc/etc/config/+*/mmc/etc/config/
- /tmp/etc/config/+*/tmp/etc/config/
-=Script types=+==Script Types==
-You need to add an extension to the script if placed in one of the previous folders. Every extension has it's own meaning.+You need to add an extension to the script if placed in one of the previous folders. Every extension has its own meaning.
Line 19: Line 19:
|- |-
| .startup | .startup
-| will be executed on system startup, normally boot-time and: _before_ the firewall is configured+| will be executed on system startup, normally boot-time and '''before''' the firewall is configured.
 +|-
 +| .prewall
 +| will be executed whenever the WAN interface goes up and '''before''' the firewall.
|- |-
| .wanup | .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.+| will be executed whenever the WAN interface goes up and '''after''' the firewall.
|- |-
| .if | .if
-| 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 stuff - .wanup - should be a better place for disconnect/reconnect events than the ones above+| will be executed whenever any interface goes up and '''after''' the firewall. (no longer in source code, must be deleted)
|- |-
| .ipup | .ipup
-|is run when ppp connection is reestablished after a disconnect, _after_ firewall stuff.+|is run when PPP connection is reestablished after a disconnect and '''after''' the firewall.
|- |-
| .ipdown | .ipdown
-| is run when a ppp connection has been shut down+| is run when a PPP connection has been shut down. (no longer in source code, must be deleted?)
|- |-
| .sesbutton | .sesbutton
Line 37: Line 40:
|} |}
-=Execute scripts with a different extension or in a different folder=+Remember to change permissions on any script files using chmod (chmod +x script_name) to permit execution.
-If you want to execute scripts with a different extension or those that are located in a other folder you can create this script+Scripts with .wanup may be run several times when the router boots. ( see http://www.dd-wrt.com/phpBB2/viewtopic.php?p=433984 ). People using WinSCP to transfer files to their router can right click on the filename after uploading and select "Properties" to change permissions.
- for I in `/bin/ls /jffs/etc/config/*.startup`+
- do+
- sh $I &+
- done+
-Ofcourse you need to change the path (/jffs/etc/config) and the extension itself to match your desire.+==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
 +<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.
-==How it works==+==How It Works==
-The command ''sh /jffs/etc/config/*.startup'' will execute every script ending in '''.startup''' found in the '''/jffs/etc/config''' directory. By setting this as the rc_startup value, your *.startup scripts will load every time the router boots.+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==
 +[[LED Scripts]]<br>
 +[[Startup Scripts]]<br>
[[Useful Scripts]] [[Useful Scripts]]
-[[Startup Scripts]]+[[Category:Scripts]]
- +
-[[Category:English documentation]]+

Revision as of 17:41, 22 March 2012

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.
.prewall will be executed whenever the WAN interface goes up and before the firewall.
.wanup will be executed whenever the WAN interface goes up and after the firewall.
.if will be executed whenever any interface goes up and after the firewall. (no longer in source code, must be deleted)
.ipup is run when PPP connection is reestablished after a disconnect and after the firewall.
.ipdown is run when a PPP connection has been shut down. (no longer in source code, must be deleted?)
.sesbutton is executed when the SES/AOSS/EZ-SETUP button is pressed

Remember to change permissions on any script files using chmod (chmod +x script_name) to permit execution. Scripts with .wanup may be run several times when the router boots. ( see http://www.dd-wrt.com/phpBB2/viewtopic.php?p=433984 ). People using WinSCP to transfer files to their router can right click on the filename after uploading and select "Properties" to change permissions.

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.

Links

LED Scripts
Startup Scripts
Useful Scripts