WB-2P-LR2. User manual
68
1.
2.
3.
10 Appendix
А
. 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: ""
The
'Enable'
option allows (if the value is 1) or denies (if the value is 0) the script launch, the path to which is
specified in the
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. The script in the /etc/config directory can be
created either using the vi editor, or download it from an external TFTP server (using the
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.