VMmanager Knowledge Base
en En
es Es
Your experience drives our roadmap
Tell us how we can enhance ISPsystem platforms
for your business. The survey takes 5 minutes.
Take the survey

How to create your own script repository?

You can add a custom script repository to the platform. A dedicated or virtual server can be used as a repository. A different set of scripts can be displayed for each interface language in the platform.

Adding a repository

To create a custom script repository, perform the following actions on the repository server and the platform server.

On the repository server:

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

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

      You do not need to create all files. For example, if scripts must be displayed only in the Russian and English interfaces, create only the files metadata_ru.json and metadata_en.json.

      If the same set of scripts with the same descriptions must be displayed for all platform languages, create only the file metadata.json.

  5. Fill in the metadata files.
    Example metadata.json description 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"
        }
      ]
    }
    File details
  6. If necessary, add additional fields.
    Example metadata.json file with additional fields
    {
      "type": "recipe",
      "recipe": [
        {
          "name": "helloworld",
          "tags": ["centos", "debian", "ubuntu", "new"],
          "description": "description1",
          "file_name": "helloworld.sh",
          "updated_at": "2017-11-13 13:31:03",
          "type": "shell",
          "params": [
            {
              "name": "greeting",
              "description": "Greeting text",
              "required": false,
              "type": "input"
            },
            {
              "name": "mode",
              "type": "select",
              "select_values": ["fast", "slow"]
            }
          ]
        }
      ]
    }
    File details

On the platform server:

  1. Obtain an 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. Run an API request to create the repository in the platform: 
curl -H 'x-xsrf-token: <token>' -X POST https://localhost/vm/v3/repository -d '{"name":"<repo_name>","url":"<repo_url"}'
Command details

Supported metadata.json parameters

The following is a list of parameters processed when synchronizing the script repository. Some of them are not described in the JSON schema but are supported by the platform.

Attention!
  • The JSON schema does not prohibit additional fields, so extra parameters are not rejected during validation;
  • fields  type  and  params  are supported by the platform but are not described in the JSON schema, so their presence and format are not checked during validation;
  • fields  tagstype  and  params  in the  recipe  are not marked as required in the JSON schema, but have specific processing behavior:

    • tags  — if the field is missing, the script will not be saved;
    • type  — if the field is not specified, the value  shell ;
    • params  — if the field is not specified, the script runs without additional parameters.

Top level

ParameterTypeRequiredDefaultDescription
typestringyesRepository type
recipearray of objectyesList of repository scripts

Array element  recipe

FieldTypeRequiredDefaultDescription
namestring, up to 255 charactersyesScript name
descriptionstring, up to 255 charactersyesScript description
file_namestring, up to 255 charactersyesScript file name in the repository. Together with the repository address, it forms a download link
updated_atstring, date and timeyesDate and time of the last script update. Used to track changes to the script file
tagsarray of stringnoScript tags, for example  linux ,  windows ,  centos ,  ubuntu . Determine which operating systems the script will be displayed for in the platform web interface
typestringnoshellScript execution method. Allowed values:  shell ,  ansible ,  power_shell
paramsarray of objectnoParameters requested by the platform from the user when launching the script

Array element  params

FieldTypeRequiredDefaultDescription
namestringyesParameter name
descriptionstringnoParameter description, displayed to the user when launching the script
requiredboolnofalseWhether the parameter is required when launching the script
typestringnoinput

Input field type. Allowed values:

  • input  — regular input field;
  • select  — drop-down list.
select_valuesarrayyes, if  type  =  selectList of values for the drop-down list

Verifying the repository

Verification confirms that the repository is available for use in the platform.

To verify the repository:

  1. In the platform web interface, in the Scripts section, check that scripts from the added repository are displayed.
  2. Run a script from the repository on a VM.
  3. If no scripts are displayed, check the list of repositories using an API request:
    1. Connect to the server with the platform via SSH. For more information about connecting via SSH, see Workstation setup.
    2. Obtain an 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. Run the request:
      `curl -H 'x-xsrf-token: <token>' -X GET 'https://domain.com/vm/v3/repository?where=%28type%20EQ%20%27recipe%27%29'`
      Example response
      {
        "last_notify": 17387,
        "list": [
          {
            "hidden": true,
            "id": 1,
            "immortal": true,
            "name": "recipe_repository",
            "os_count": 0,
            "storage": null,
            "type": "recipe",
            "url": "http://download.ispsystem.com/OSTemplate/vm6/recipes/"
          },
          {
            "hidden": false,
            "id": 22,
            "immortal": false,
            "name": "testrepo",
            "os_count": 0,
            "storage": null,
            "type": "recipe",
            "url": "http://<IP>/recipes/"
          },
          {
            "hidden": false,
            "id": 34,
            "immortal": false,
            "name": "myrepo",
            "os_count": 0,
            "storage": null,
            "type": "recipe",
            "url": "http://<IP>/"
          }
        ],
        "size": 3

Updating the script list

The script list in the platform is synchronized with the repository every 15 minutes. To update the script list manually:

  1. Obtain an 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. Run the API request:

    curl -H 'x-xsrf-token: <token>' -X POST "https://domain.com/vm/v3/repository/<repo_id>/update" -d ''
    
    Command details
Useful tips