The MightyBox command-line interface (CLI) is designed to simplify interaction with your Cloud Platform account, allowing you to execute required commands via your local machine’s terminal. It can handle the vast majority of available operations remotely, complementing the wide stack of capabilities provided via the dashboard and MightyBox API.
The main benefit here is the advanced and comparatively simple automation tools that CLI provides to developers. Simple text commands can be easily grouped into scripts and, in such a way, mold a powerful mechanism for accomplishing various objectives: from the most common and frequent tasks’ automation to monitoring of apps and managing complex DevOps processes.
So, let’s start with the MightyBox CLI installation and reveal some key points of its usage before proceeding further.
Subsequently, you can dive deeper with the MightyBox CLI tutorials on particular operations.
CLI Installation
In order to install the MightyBox CLI at your local machine, you need to run just a single line of code via your terminal:
1 curl -s ftp://ftp.MightyBox.com/pub/cli/MightyBox-cli-installer.sh | bash
Notes:
- please ensure you have Java of the _8 version or higher _installed beforehand
- in case you are using Windows OS, you need to get the Unix-like environment installed first (e.g. Cygwin) and run all the appropriate commands within it
Consequently, the MightyBox CLI will be installed to the dedicated MightyBox folder at your home directory. The structure of the folders and bash scripts inside represents the hierarchy of MightyBox API, which results in a complete similarity of the corresponding working processes, so you can quickly get used to our CLI.
Getting Started
The base of the MightyBox CLI is represented with an executable .jar archive and some pre-configured commands (bash scripts) for operating. With the help of these commands, you are able to monitor, control and automate your environment’s lifecycle.
- To get started, the authentication should be passed. It is called automatically on the first CLI command use, e.g.:
Just follow the appearing questionnaire, specifying the asked values:
- Platform URL – MightyBox installation URL in the app.{hoster_domain} format
- Email – email (login) bound to your account
- Password – your account password
If the entered data is correct, you’ll see the MightyBox logo and version of the currently used platform.
1 ~/MightyBox/users/authentication/signin --login {email} --password {password} --platformUrl {platformUrl}
Here, the values in braces should be substituted with the corresponding account parameters (described above).
The “ result”: 0 property within the received response (circled in the image above) means that the operation has passed successfully and without errors. Such behavior stands for all of the commands you run.
- The information on the actual user session (i.e. platform address and your credentials) is stored within the automatically generated ~/.config/MightyBox/MightyBox.properties file. It is automatically fetched when necessary, allowing you to concentrate on performed operations with no repetitive authentication steps required.
By default, the CLI command is considered successfully executed even if the called API method returns an error. You can change this behavior with the MightyBox.non_zero_exit_code parameter added to the configuration file. It defines if the CLI command should respond with zero code as usual (false – default value) or with a non-zero code when the executed API method returns an error (true).
- In case you are new to our API and need details on its command-line interface structure, you can access the embedded help file:
1 ~/MightyBox/help<br>
Here, you can see the hierarchical list of the available command types (methods). Each method has a dedicated same-named folder with several scripts (i.e. available functions) inside.
- In order to get the list of all possible operations for a particular method, you can use a simple listing command for the appropriate directory, for example:
1 ls ~/MightyBox/environment/control
Each of the presented functions can be easily called using the full path to it.
- For more information on a particular operation, run it without parameters to see the complete list of missed requirements.
You can also check our API documentation for getting additional information.
- By default, the “loading” animation is displayed while waiting for any command execution. It provides a visual representation of the action in progress.
However, if you need to save the response into a file (e.g. to use it in some automation tasks), this element may be redundant and corrupt JSON formatting. To hide the loading animation, append your command with the following argument:
1 --silent true
In such a way, the received output can be immediately used by your automation scripts without any additional edits.
Now, as you have some basic knowledge of MightyBox CLI, you can continue exploring it on your own.
CLI Tutorials
Ensuring the full-functional remote management, MightyBox CLI works with all types of environments and applications. It supports all of the appropriate actions, from the simplest to the complex ones. To reveal its capabilities with real showcases, we present some of the most common examples of its usage:
- environment creation
- environment start/stop
- environment cloning
- environment migration
- server scaling
- container redeploy
- container volumes
- mount points
- VCS projects deployment
- swap Public IPs
- install JPS
Subsequently, when you catch the idea of how to work with MightyBox CLI and the possibilities it provides, you can start creating your own automation scripts for some frequent environment lifecycle operations.