Enhanced Shell Prompt (ESP) is a Bash prompt that contains various checks to help a tech know what is happening on a server they are logged into. Every time the PS1 prompt is rendered, checks for upcp, backups, easyapache, new SSH connections, and also service checks for yum locks, apache, exim, mysql, and various other items are run.
To use esp run the following command on CentOS/CL 6 or 7:
source <(curl -sL https://raw.githubusercontent.com/cPanelRicky/ESP/master/esp)
Configuration options in ESP are Bash environment variables declared before the source command. This allows configuration options to be set while not using any configuration files, and are easy to declare. For example if we wanted to declare that we wanted to run SSP, we could set 'ssp=1' before the source command as shown below:
Example:
ssp=1 source <(curl -sL https://raw.githubusercontent.com/cPanelRicky/ESP/master/esp)
You can enable SSP to run on script execution by declaring a Bash environment variable called ssp before running the command for this script.
Configuration Option: ssp
Options: '1' - Enable SSP, Default is disabled
As of esp 0.03 directory listings are now enabled by default, however this may not be desired for all servers or techs. To disable this option, there is the following configuration option to disable this feature.
esp_cl_disable
Any value to this varable will disable the cl feature and is only checked on the initial run. The command cl-off can be used after the initial run.
The second configuration option for the directory listing is the amount of files it will list. By default this is 150, however it can be changed with the option esp_cl_maxfiles
esp_cl_maxfiles
ESP checks can be disabled individually or all of them can be disabled at once. The checks are disabled by declaring the following variables before the source command or with export once ESP has been run.
esp_check_disable_all
esp_check_disable_yum
esp_check_disable_backup
esp_check_disable_easyapache
esp_check_disable_apache
esp_check_disable_apache
esp_check_disable_mysql
esp_check_disable_mailserver
esp_check_disable_cpsrvd
esp_check_disable_tailwatchd
ESP is different that SSP in the fact that SSP runs an compressive set of checks on the initial login. ESP runs checks constantly as an analyst is working on the server to notify the tech of changing conditions on the server as they work as well as create aliases, and Bash functions for repetitive commands.
Currently the script will check for the following in the PS1 Alerts:
- If EasyApache is running
- If upcp is running
- If backups are running
- If Apache is down
- If Exim is down
- If MySQL is down
- If an new ssh connection/logout is detected
- If the mailserver is down
- If yum is running or has an stale lock
ESP has many features that can be useful besides being able to read minds. ESP comes with a command 'cphelp' that can be used to get more information on the available commands..
ESP features development hooks to allow for extra features and functions inside ESP without the need of forking the code and modifying ESP. Hooks are relatively easy to use and can add a lot of custom functions to ESP. To create an hook all you need to do is declare an bash function with the name of the hook. Then when esp hits the hook it will test to see if the user has declared an hook and if so run it.
esp_hook_pre
This hook is run at the ESP startup, so if you wanted to run some code on ESP startup you can use this hook. This hook is not enclosed in safety timeouts, so if the command gets caught in an loop it will crash the shell.
An example of the pre hook could be to read ESP configuration options from a file. ESP currently has no plans on developing this, however it has been requested. A pre hook can be used to accomplish this. In the following example we will declare an bash function and then load the configuration from inside this function/hook:
function esp_hook_pre { [[ -f ~/.esprc ]] && source ~/.esprc;};
Now you can run ESP and ESP will detect the hook and load ~/.esprc if it exists. Additionally, you can combine the function, with configuration options and the ESP command for an (admittedly large) one liner.
export esp_check_disable_mysql=1 function esp_hook_pre { [[ -f ~/.esprc ]] && source ~/.esprc;}; source /dev/stdin <(curl -sL https://raw.githubusercontent.com/cPanelRicky/ESP/master/esp)
esp_hook_post
Post hooks are useful for running code after ESP startup has completed. The post hook is the last thing run before ESP startup ends before dropping the user to the ESP shell. This command is not run through the safety timeout system so if your hook gets caught in a loop it will crash the shell.
An example of the ESP post hook is to modify the PS1 variable. Like the pre hook we will be declaring an bash function with the hook name and placing the hook code inside the function:
function esp_hook_post { export PS1="$PS1 >>>"; };
Like the pre hook you can place the function before the esp command for an one liner:
function esp_hook_post { export PS1="$PS1 >>>"; }; source /dev/stdin <(curl -sL https://raw.githubusercontent.com/cPanelRicky/ESP/master/esp)
Ausaf Lateef
Ricky Grassmuck
Citizen Kepler - Creator
Jerald Johnson - Contributor
Terrance Robotham - Previous Maintainer