Cloud Script
Cloud Scripts are an important feature that allows the configuration of a Server during creation via a remote script.
To do this in addition to using temporary scripts our services expose also a personal script library making it possible to create reusable and customizable scripts.
Although library management is recommended via the Web panel it is still possible via API.
Info
Remember: the use of environment variables is possible only with scripts from the script library, it is not allowed with temporary scripts.
Adding a New Script
The following request can be used to add a new script:
HTTP request
POST /ecs/v2/scripts
{
"title": "my-script",
"content": "#!/bin/bash\necho \"Hello, World!\" > /root/greet.txt",
"windows": false,
}
HTTP Response
{
"id": 0,
"user": "foo",
"title": "my-script",
"content": "#!/bin/bash\necho \"Hello, World!\" > /root/greet.txt",
"windows": false,
"public": false,
"category": null
}
Status Code | Message | Explanation |
---|---|---|
400 | Cant use relative path i user scripts | it is impossible to use relative path or home path (~/) in cloud scripts |
400 | Error content cant be null | script content cannot be empty |
400 | Error title cant be null | script title cannot be empty |
400 | Error can't have more then 20 scripts remove a script before try to create another | The size of the cloud script library does not support more than 20 scripts per user |
Get present scripts
To get all of the user's scripts you can perform the following request:
HTTP Request
GET /ecs/v2/scripts
HTTP Response
{
"status": "ok",
"scripts": [
{
"id": 0,
"user": "foo",
"title": "my-script",
"content": "#!/bin/bash\necho \"Hello, World!\" > /root/greet.txt",
"windows": false,
"public": false,
"category": null
},
{
"id": 1,
"user": "foo",
"title": "my-script-w",
"content": "#ps1\necho \"Hello, World!\" > C:\\Users\\Administrator\\Desktop\\greet.txt",
"windows": true,
"public": false,
"category": null
}
]
}
Getting a Specific Script
To get a script in the specific, you can use the following request:
HTTP Request
GET /ecs/v2/scripts
HTTP Response
{
"status": "ok",
"script": {
"id": 0,
"user": "foo",
"title": "my-script",
"content": "#!/bin/bash\necho \"Hello, World!\" > /root/greet.txt",
"windows": false,
"public": false,
"category": null
}
}
Modifying a particular Script
You can edit an already created script using the following prompt:
HTTP Request
PUT /ecs/v2/scripts/{scriptid}
{
"title": "my-script-renamed", //opzionale
"content": "#!/bin/bash\necho \"Hello, Guys!\" > /root/greet.txt", //opzionale
"windows": false, //opzionale
}
HTTP Response
{
"status": "ok",
"script": {
"id": 0, //identificativo
"user": "foo",
"title": "my-script-renamed",
"content": "#!/bin/bash\necho \"Hello, Guys!\" > /root/greet.txt",
"windows": false, //indica se lo script è destinato a macchine windows
"public": false, //indica se lo script è pubblico per altri utenti
"category": null
}
}
You may get the following errors:
Status Code | Message | Explanation |
---|---|---|
400 | Cant use relative path i user scripts | it is impossible to use relative path or home path (~/) in cloud scripts |
400 | Error content cant be null | script content cannot be empty |
400 | Error title cant be null | script title cannot be empty |
Delete a Script
Of course you can remove scripts that you no longer intend to use, this can be done with the following request:
HTTP Request
DELETE /ecs/v2/scripts/{scriptid}