CLI
s2ctl is a Serverspace in the command line. The CLI gives you the ability to control your infrastructure via terminal, just like via the control panel. The tool is available on our Github.
Installation
s2ctl is available for Linux and Windows as a separate binary file. Download the archive from Github and unzip it.
Installation on Linux
- Download the archive from the GitHub repository:
wget https://github.com/itglobalcom/s2ctl/releases/download/vX.X.X/s2ctl-vX.X.X-linux.tar.gz
X.X.X.X is the number of the latest version of the utility.
- Unzip the downloaded archive:
tar -xzf s2ctl-vX.X.X-linux.tar.gz
- Navigate to the created directory and run the s2ctl utility:
cd s2ctl-vX.X.X-linux
./s2ctl --help - (Optional) You can also add the directory which contains the s2ctl executable to the $PATH environment variable to access the utility from anywhere in the operating system. To see what is in the $PATH variable right now, type the command:
echo $PATH
To add a new directory to the list, use the command:
export PATH=$PATH:"
" The $PATH variable is set by the shell each time it starts, but you can make it include the path to the utility in every new shell you open. The exact method depends on which shell you're using.
For example, for bash you need to add the following line about the corresponding file:echo 'export PATH=$PATH:"
"' >> .bashrc Use the command to apply the changes:
source ~/.bashrc
Installation on Windows
-
- Download the file s2ctl-vX.X.X-windows.zip from Github and unzip it.
- Run the command line:
- Press Win+R or Start → Search → Enter run → OK
- Enter cmd command → OK
- By default, the command line displays the home directory of the current user. Navigate to the directory with the extracted file:
cd
- Go to the desired directory and run the command:
s2ctl --help
- (Optional) You can also add the directory where you placed the s2ctl binary to the PATH environment variable to access the utility from anywhere in the operating system.
- Find System (Control Panel) in Search, and open it.
- Click the Advanced system settings.
- Click on Environment Variables. In the System Variables section find the PATH variable and select it. Click Edit. If the PATH variable does not exist, click New.
- In the Edit System Variable (or New System Variable) window, specify the value for the PATH environment variable. Click OK. Close all remaining windows by clicking OK.
Authorization
In order to work with the CLI you must create an API key for the project and also a context. Otherwise, you will need to pass the API key with each request.
Context Creation
Using contexts simplifies the use of the s2ctl utility. In this case you do not have to explicitly specify the API key for each command.
To create a context, use the following command:
s2ctl context create -k -n
For example:
s2ctl context create -k lmGwbvllpIqIrKROOCLgE5Z941MKP5EYfbkgwtqJZGigfXUTpuYRpNQkCqShmm6r -n example
Key Transfer
To pass the API key explicitly, it must be specified at the end of the command with the --apikey option:
s2ctl --apikey
For example:
s2ctl images --apikey lmGwbvllpIqIrKROOCLgE5Z941MKP5EYfbkgwtqJZGigfXUTpuYRpNQkCqShmm6r
Usage Examples
Get information about the project with the following command:
s2ctl project show
This will return information about the project:
id: '1'
balance: '400.24'
currency: EUR
state: Active
created: '2019-04-08T10:35:53.7021047Z'
Create server:
s2ctl server create --name test-cli --location nj3 --image Ubuntu-20.04-X64 --cpu 2 --ram 2048M --volume boot:30720M --volume volume:10240M --public-network 50 --public-network 60
This will return the task ID, which can be used to track the server creation process:
task_id: lt1512053