WB-2P-LR5. User manual
70
1.
2.
3.
10 Appendix A. Launch user script when starting the system
Sometimes you need the device to implement certain actions when starting, which cannot be implemented
through settings in configuration file. In this case you may configure a user script through a configuration file that
will be launched when the system starting. You may set any needed commands sequence.
For user script launching, there is a settings section in the configuration file cfg.yaml:
UserScript:
Enable: "0"
URL: ""
Option
«Enable»
permits (if the value is 1) or forbids (if the value is 0) launch of the script, path to which is in
URL
parameter.
The userscript might be located on remote server as well as on the device. The script is loaded via HTTP or TFTP
from remote server. Examples of configuration files for user script launching using different sources are given
below:
Launch from HTTP server
To launch a script from HTTP server, enter the entire path to the file in HTTP-URL format to
URL
parameter:
URL: "
http://192.168.0.250/user-script/script.sh
In this case, after the device started, file script.sh, which is kept in the catalogue having 192.168.0.250
address, will be automatically loaded via HTTP from the defined server. Then it will be launched.
Launch from TFTP server
To launch a script from TFTP server, enter the entire path to the file in TFTP-URL format to
URL
parameter:
URL: "
tftp://192.168.0.250/user-script/script.sh
In this case, after the device started, file script.sh, which is kept in the catalogue having 192.168.0.250
address, will be automatically loaded via TFTP from the defined server. Then it will be launched.
Local script launch
Due to the peculiar properties of the file system, a local script should be stored in /etc/config catalogue as
the content of the catalogue is saved after device reload. You may create script in /etc/config catalogue
through vi editor or load it from TFTP server using
tftp –gl
sh <TFTP-server
address>
command. After
creating a script, you should set rights for launching using the following command:
chmod 777 /etc/config/user.sh
In configuration file, URL for local script launching should be set as follows:
URL: "
"
A user script should start from the
#!/bin/sh
directive.