Deployment Scripts are a feature available free-of charge on all Mammoth VPS that can provide automated setup of new software, configuration of preferred defaults, and general customisation of the VPS.
Screenshot of of a reinstall using the "LAMP Stack" script
(click to view)
When using a deployment script, the selected script can ask for configuration values through mPanel (such as the MySQL root password, in the example above). Upon giving your confirmation, the script and its configuration values are written into the VPS. As the VPS boots up, the rescue console is shown so that you may monitor the progress of the script.
A variety of pre-written scripts by Mammoth and other customers are available for selection, or you can create your own in mPanel. Scripts can be kept private to your account, or shared with other Mammoth customers.
Deployment scripts can be written in using any language interpreter that the distribution has installed - typically Bash, Python, or Perl. During deployment, the script is written into the VPS and temporarily replaces the standard Linux console login prompt (getty/mingetty). In other words, the script executes after all daemons and system services have been started when the system is ready for interactive use.
A script can specify that it supports particular environment parameters, as you might set in the shell via MYVAR=value. After selecting the script in mPanel, the script user is prompted to supply values for each of the environment parameters the script supports.
When developing multiple deployment scripts, you may find that you have a common core of functionality that is used in each script. Instead of repeating this functionality in each script, it can be defined in a separate script and then referenced through an include directive.
To start creating a deployment script, login to mPanel and go to the Deployment Scripts section. After clicking the "Add" button, fill out the form as follows:
A script can request environment parameters by inserting<?env?> directives into the script's source code. In mPanel, these directives are displayed within the web interface and the supplied values are then passed to the script's environment during execution.
An env directive accepts a number of arguments as follows:
<?env name="default_user" ?>
is exposed to a
bash script as $DEFAULT_USER
. If the supplied name
contains the string "password", then the input on mPanel is
starred-out instead of being displayed as text.<?env name="default_user" label="Default User" ?>
<?env name="default_user" default="" ?>
<?env name="default_user" example="sudo user to create during deployment" ?>
<?env name="colour" oneof="red,green,blue" default="green" ?>
<?env name="colour" manyof="red,green,blue" default="red,blue" ?>The selected values are supplied to the script as a comma-separated string; for example
COLOUR="red,blue"
As env directives are not removed from the script during deployment, they should be commented out - usually by placing a hash at the start of the line.
A script can request that another deployment script be written
into the VPS during deployment via the
<?include?>
directive. Scripts can be referenced
via their file ID or their external ID, e.g.
# Include by file ID <?include file="mammoth-debian-lib" ?> # Include by external ID <?include file="1" ?>
During deployment, the referenced file is written to the VPS's disk and the include directive is replaced by the name of the file the script was written to. In Bash, you can include the file as follows:
#!/bin/bash source <?include file="mammoth-debian-lib" ?> ...
Scripts referenced via an include directive cannot use env directives or include other scripts themselves; that is, they are simply written into the VPS for deployment with no processing.
Mammoth's deployment scripts are broadly compatible with
StackScripts; <udf>
and
<ssinclude>
tags are mapped to
<?env?>
and <?include?>
directives with the same semantics. In the general case a
StackScript can be used unmodified as a deployment script as long
as its includes have also been added in our system.