Skip to content

User Scripts

User Scripts are saved scripts that run automatically during first-boot setup when you create or reinstall an instance. Typical uses: install a web server, configure a firewall, drop in a config file, register the machine with your inventory.

Script types: bash and python for Linux, powershell for Windows. The script body is stored encrypted.

In the user panel go to Compute > User Scripts.

The User Scripts list.

User Scripts list

  1. Click New script. The Add Script dialog opens.

    Add Script dialog

  2. Fill in:

Fields

Field What to enter
Name A label (letters, digits, spaces, dots, dashes, underscores).
Script Type Bash, Python or PowerShell.
Description (Optional) Optional.
Shebang Optional, Linux only. Defaults to #!/usr/bin/env bash or #!/usr/bin/env python3.
Script Content The script body, in the built-in code editor.
  1. Click Add Script.

Click Insert Variables in the editor to drop in a ready-to-edit template using the variables below.

The panel fills these in from the instance before the script runs. Use them directly ($PUBLIC_IP in Bash, $env:PUBLIC_IP in PowerShell):

Variable What it holds
PUBLIC_IP Primary public IPv4 address. Empty if the instance has none.
PRIVATE_IP Primary private IPv4 address. Empty if not configured.
VPC_IP Primary VPC IPv4 address. Empty if the instance is not on a VPC.
INSTANCE_HOSTNAME The instance hostname.
INSTANCE_UUID The instance’s unique ID.

Example Bash script:

#!/usr/bin/env bash
apt-get update
apt-get install -y nginx
echo "Server IP: $PUBLIC_IP" > /var/www/html/index.html
systemctl enable --now nginx

When you create or reinstall an instance (see Create an instance), the install form has a Select Scripts to Run field when the chosen OS image supports cloud-init. Pick one or more scripts; they run in the order you select them, each finishing before the next starts, with root (Linux) or System (Windows) privileges.

  • The script ran but did nothing visible. Check the cloud-init log on the instance: /var/log/cloud-init-output.log on Linux, or the Cloudbase-Init log directory under C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\ on Windows.
  • A variable came out empty. Variables are filled from the instance record at boot. If an IP had not been assigned yet, the matching variable is empty.