InfoDepot Wiki

READ MORE

InfoDepot Wiki
Register
Advertisement

Your here: Home / WiFi / TomatoUSB Tutorials / TomatoUSB - Script Name Extensions

ray123 Wrote:

Oh, sorry. I thought this was common knowledge. Guess not.

Another sneak peak:

The order of looking for the scripts is:

  1. NVRAM - shell script entered into the Tomato configuration web interface.
  2. /etc/config/ - file
  3. /jffs/etc/config/ - file
  4. /opt/etc/config/ - file
  5. /mmc/etc/config/ - file
  6. /tmp/config/ - file

The files are executed in each directory in alpha-numeric order. The convention for naming such files is "NN-description.suffix", where NN is a two digit number for controlling the order in which the files are executed. Each directory is examined completely before moving on to the next directory. The files should have execute privilege. (chmod +x filename). The files can be either a shell script or an executable program.

When the triggering event occurs, the Tomato system will begin executing the corresponding scripts. It will wait up to N seconds for each script to finish, and then continue. It will stop waiting either when the time is up or when the script exits, whichever comes first. The time (in seconds) is the number in the brackets in the above event list.

Notes on wait times: The wait time is for each individual script, not for all the scripts. This means that, for example, if you have 10 init scripts and each has a "sleep 5" in it, then the total delay during system startup will be 20 seconds. Furthermore, each script will continue for (at least) an additional 3 seconds before exiting. So it is possible for several different scripts to overlap in their execution.

The wait is for the script/process that gets spawned. If you have a script that you know will take a long time and don't want the system to hang for the duration of the time-out, then the script should spawn a sub-process (A.K.A. background process) and then exit immediately. The background process would be the one which does the real work.


teddy_b Wrote:

/opt/etc/config/01-some-rules.fire
/opt/etc/config/02-more-rules.fire
…..
/opt/etc/config/01-optware-wan.wanup
…..

etc

Here's the list of current names/events (script name extensions):

sesx---------------SES/AOSS Button custom script. Param: ??
brau---------------"bridge/auto" button pushed. Param: mode (bridge/auto/etc)
fire-----------------When firewall service has been started or re-started.
shut---------------At system shutdown, just before wan/lan/usb/etc. are stopped.
init-----------------At system startup, just before wan/lan/usb/etc. are started. The root filesystem and /jffs are mounted, but not any USB devices.
usbmount-------After an auto-mounted USB drive is mounted.
usbumount------Before an auto-mounted USB drive is unmounted.
usbhotplug------When any USB device is attached or removed.
wanup-------------After WAN has come up.
autostop----------When a USB partition gets un-mounted. Param: the mount-point (directory).
If unmounted from the GUI, the directory is still mounted and accessible.
If the USB drive was unplugged, it is still mounted but not accessible.

User scripts -- no directories are searched.

autorun------------When a USB disk partition gets auto-mounted. Param: the mount-point (directory).
But not if the partition was already mounted. Only the files in that directory will be run.
Advertisement