Scripts allow you to set up virtual machines automatically: install software applications, modify configuration files, and perform other operations. You can select a script when creating a virtual machine. It will be executed right after the operating system is installed. You can also start a script on the existing virtual machine. Scripts from the ISPsystem repository are available per default.
On a Linux OS, you can run Shell scripts written in bash, and on a Windows OS, you can run Powershell scripts.
You can set parameters for the script. Their values will need to be entered or selected from the list when running the script. Variables can be used as parameters to be entered manually. Then, when the script is run, the value of the variable will be displayed in the parameter input field.
Creating a script
To create a script:
- Go to Scripts → Create a script.
- Enter a script Name.
- Select who will have the Access to the image:
- Owner;
- All.
- Specify a Description. It is displayed in the script list.
- Specify Filters to run the script. The script is available to run on a VM if the conditions of all filters match. The OS tags filter is mandatory, the others are optional.
- If necessary, specify the requested script parameters:
- Press Add parameter .
- Specify the parameter Name and Description . If you use a variable name as a parameter, its description will be added automatically.
- You can specify parameter values that will be offered when the script is run. To do this, click Add:
- For a mandatory parameter, enable the Required option.
- To add more parameters to the script, press Add one more parameter to script.
- Select a Script type:
- Shell script — for Linux OS;
- Powershell script — for Windows OS.
- Enter the Script in the editor window. To expand the editor window to the full screen, press . To return to the window mode, press . The editor has an auto-complete feature. For example, if you need to insert in a script the name of an external variable, start typing and the editor will suggest endings.
- To send an email to the user after running the script, press Add in the Notification to email section.
- By default, you are offered to set up an English email template — Email for EN.
- Enter the Email subject.
- Next, specify the content of the email in the Content field. In this field, you can use the same variables and parameters that you used in the script. Read more about creating email templates in Email templates in scripts.
- Click Preview to preview the email.
- If you need an email template in Russian, press Add the email for RU. If you no longer need any of the templates, press Delete the email for RU / Delete the email for EN.
- Click on Create.
Example of creating a script
Example of email template
Operations with scripts
To change script settings, go to Scripts → select script → menu → Edit.
To change the access settings of a script from the ISPsystem repository, go to Scripts → select script → menu → Information.
To run the script on a VM, enter Virtual machines → select the VM → menu → Run script → select the script → enter the script parameters → Run .
To interrupt execution of the script, press in the VM card or the task queue.