VMmanager Knowledge Base
en En
es Es

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.

The platform can display a different set of scripts for each interface language.

Adding a repository

To create your own script repository:

  1. On the repository server:
    1. Install and configure the web server.
    2. Create a directory for the repository. The directory must be accessible to external connections via HTTP. For example, /var/www/html/recipes/.
    3. Copy the script files into the repository directory.
    4. Create files with script descriptions in the repository directory:

      • metadata_en.json — for display in the English interface of the platform;
      • metadata_es.json — for display in the Spanish interface of the platform;
      • metadata_ru.json — for display in the Russian interface of the platform;
      • metadata.json — for display in any interface of the platform. 

        You don’t have to create all the files. For example, if you only need to display scripts for the Spanish and English interfaces, create only the metadata_es.json and metadata_en.json files.

        If you need to display a single set of scripts with the same description for all languages on the platform, create only the metadata.json file.

         

        Example of 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
  2. 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 command

    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"
    }

    Save the received token value.

  3. 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

  1. Connect to the server with the platform via SSH.
  2. 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/                           | 
    +----+-------------------+--------+-----------------------------------------+
  3. In the platform interface:
    1. Check the display of scripts from the added repository.
    2. 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:

  1. 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 command

    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"
    }

    Save the received token value.

  2. 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