Console servers all run the embedded Linux operating system and Administrator class users can configure the console server and monitor and manage attached serial console and host devices from the command line (refer faq 233).
The Linux kernel in the console server also supports GNU bash shell script enabling the Administrator to write custom scripts - that can be run manually or automatically.
- Custom script can run when booting.
The /etc/config/rc.local script runs whenever the system boots. By default this script file is empty. You can add any commands to this file if you want them to be run at boot time e.g. if you wanted to display hello world:
#!/bin/sh
echo "Hello World!"
If this script has been copied from a Windows machine you may need to run the following command on the script before bash can run it successfully:
# dos2unix /etc/config/rc.local
Another scenario would be to call another custom script from the /etc/config/rc.local file, ensuring that your custom script will run whenever the system is booted. In faq 334 the custom script uses this method to ping a target device and then power cycle the device in event of a ping request failure. - Custom scripts can be embedded in the monitoring and automated response process:
- The Auto-Response facility (in firmware V35.1 and later) monitors the console servers, attached devices and state outcomes from running custom scripts, for trigger events (refer faq414-Custom-Script-Checks.html). These triggers then automatically initiate a sequence of actions which can include the sequenced execution of custom scripts. (refer faq409-Auto-Response-Alerts.html)
- Even with earlier firmware (pre V3.5.1) custom scripts can be run each time a particular alert triggers. Examples include:
- The Auto-Response facility (in firmware V35.1 and later) monitors the console servers, attached devices and state outcomes from running custom scripts, for trigger events (refer faq414-Custom-Script-Checks.html). These triggers then automatically initiate a sequence of actions which can include the sequenced execution of custom scripts. (refer faq409-Auto-Response-Alerts.html)
- You can also create custom scripts that run whenever a particular configurator has run (refer faq 336)
- Custom scripts can also be run manually from the command line (or called from other scripts).
There are a number of specific function scripts that may be useful to the Administrator:
- /etc/scripts/backup-usb .... this script saves and loads custom configuration using a USB flash disk (refer faq 333)
- delete-node .....this script deletes nodes (i.e. users, groups, hosts, UPS's etc) from the command line (refer faq 335)
- /etc/scripts/serial-address .... running this script from the command line, creates an alias on the WAN Ethernet for each configured serial port on the device, and then creates the necessary port forwards so that connecting to SSH or telnet (port 22 or 25), connects the user directly through to that port (and not to a pmshell menu).
Bash commands

GNU bash, version 2.05.0(1)-release (arm-OpenGear-linux-gnu) supports the following shell commands:
alias [-p] [name[=value] ... ] bg [job_spec] bind [-lpvsPVS] [-m keymap] [-f fi break [n] builtin [shell-builtin [arg ...]] case WORD in [PATTERN [| PATTERN] cd [-PL] [dir] command [-pVv] command [arg ...] compgen [-abcdefjkvu] [-o option] complete [-abcdefjkvu] [-pr] [-o o] continue [n] declare [-afFrxi] [-p] name[=value] dirs [-clpv] [+N] [-N] disown [-h] [-ar] [jobspec ...] echo [-neE] [arg ...] enable [-pnds] [-a] [-f filename] eval [arg ...] exec [-cl] [-a name] file [redirec] exit [n] export [-nf] [name ...] or export false fc [-e ename] [-nlr] [first] [last] fg [job_spec] for NAME [in WORDS ... ;] do COMMA function NAME { COMMANDS ; } or NA getopts optstring name [arg] hash [-r] [-p pathname] [name ...] help [-s] [pattern ...] history [-c] [-d offset] [n] or hi if COMMANDS; then COMMANDS; [ elif jobs [-lnprs] [jobspec ...] or job kill [-s sigspec | -n signum | -si let arg [arg ...] |
local name[=value] ... logout popd [+N | -N] [-n] printf format [arguments] pushd [dir | +N | -N] [-n] pwd [-PL] read [-ers] [-t timeout] [-p promp] readonly [-anf] [name ...] or read return [n] select NAME [in WORDS ... ;] do COMMANDS set [--abefhkmnptuvxBCHP] [-o opti] shift [n] shopt [-pqsu] [-o long-option] opt source filename suspend [-f] test [expr] time [-p] PIPELINE times trap [arg] [signal_spec ...] true type [-apt] name [name ...] typeset [-afFrxi] [-p] name[=value ulimit [-SHacdflmnpstuv] [limit] umask [-p] [-S] [mode] unalias [-a] [name ...] unset [-f] [-v] [name ...] until COMMANDS; do COMMANDS; done variables - Some variable names an wait [n] while COMMANDS; do COMMANDS; done { COMMANDS ; } |
Comments
0 comments
Article is closed for comments.