VMmanager Knowledge Base
en En
es Es
Your feedback is an opportunity for improvement!
Take part in the survey and contribute to the development of the ISPsystem ecosystem.
Take the survey

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:

  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 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
  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
The article was last updated on 04.13.2023. The article was prepared by technical writers of ISPsystem.