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" } ] }
Comments to the file
- 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"}'
Comments to the commandIn 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" }
Save 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"}'
Comments to the command
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';\""
Example of response+-------------------+-------------------------------------------------------+ | name | url | +-------------------+-------------------------------------------------------+ | recipe_repository | http://download.ispsystem.com/OSTemplate/vm6/recipes/ | | My repo | http://example.com/recipes/ | +----+-------------------+--------+-----------------------------------------+
- 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"}'
Comments to the commandIn 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" }
Save 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 ''
Comments to the command