How to create your own script repository?
You can add your own script repository to the platform. A dedicated or virtual server can be used as a repository.
Adding a repository
To create your own script repository:
- On the repository server:
- Install and configure the web server.
- Create a directory for the repository. The directory must be accessible to external connections via HTTP. For example, /var/www/html/recipes/.
- Copy the script files into the repository directory.
Create a metadata.json file with script descriptions in the repository directory:
Example of metadata.json file
{ "type": "recipe", "recipe": [ { "name": "ForLinux", "tags": [ "linux" ], "description": "script1", "file_name": "script1.sh", "updated_at": "2020-05-15 12:01:12" }, { "name": "ForWindows", "tags": [ "windows" ], "description": "script2", "file_name": "script2.ps", "updated_at": "2022-04-14 07:57:13" } ] }
YMLComments to the filetype — repository type. Specify the value of recipe
recipe — an array with script descriptions:
- name — script name
- tags — script tags. For example, linux or windows
- description — description of the script
- file_name — file name of the script
- updated_at — date and time of the last update
- Get the authorization token:
curl -k -X POST -H "accept: application/json" -H "Content-Type: application/json" 'https://domain.com/auth/v4/public/token' -d '{"email": "admin_email", "password": "admin_pass"}'
CODEComments to the commanddomain.com — domain name or IP address of the server with the platform
admin_email — platform administrator's email
admin_pass — platform administrator's password
In response, you will get the message in the form:
Example of response in JSON
{ "confirmed": true, "expires_at": null, "id": "6", "token": "4-e9726dd9-61d9-2940-add3-914851d2cb8a" }
CODESave the received token value.
Execute an API request to create a repository in the platform:
curl -H 'x-xsrf-token: <token>' -X POST https://localhost/vm/v3/repository -d '{"name":"<repo_name>","url":"<repo_url"}'
BASHComments to the command<token> — authorization token
<repo_name> — internal name of the repository
<repo_url> — repository directory URL. For example, http://example.com/recipes
Checking the repository added
- Connect to the server with the platform via SSH.
Request a list of repositories:
docker exec -it mysql bash -c "mysql isp -p\$MYSQL_ROOT_PASSWORD -e \"SELECT name,url FROM vm_repository WHERE type='recipe';\""
BASHExample of response
+-------------------+-------------------------------------------------------+ | name | url | +-------------------+-------------------------------------------------------+ | recipe_repository | http://download.ispsystem.com/OSTemplate/vm6/recipes/ | | My repo | http://example.com/recipes/ | +----+-------------------+--------+-----------------------------------------+
CODE- In the platform interface:
- Check the display of scripts from the added repository.
- Run the script from the repository on the VM.
Updating the script list
The list of scripts in the platform is synchronized with the repository every 15 minutes. To update the list of scripts manually:
- Get the authorization token:
curl -k -X POST -H "accept: application/json" -H "Content-Type: application/json" 'https://domain.com/auth/v4/public/token' -d '{"email": "admin_email", "password": "admin_pass"}'
CODEComments to the commanddomain.com — domain name or IP address of the server with the platform
admin_email — platform administrator's email
admin_pass — platform administrator's password
In response, you will get the message in the form:
Example of response in JSON
{ "confirmed": true, "expires_at": null, "id": "6", "token": "4-e9726dd9-61d9-2940-add3-914851d2cb8a" }
CODESave the received token value.
Execute the API request:
curl -H 'x-xsrf-token: <token>' -X POST "https://domain.com/vm/v3/repository/<repo_id>/update" -d ''
BASHComments to the command<token> — authorization token
domain.com — domain name or IP address of the server with the platform
<repo_id> — id of the repository