---
title: "Startup Scripts"
description: "Automate VM setup with startup scripts. Use pre-built Edge library scripts or create your own to install software, configure services, and set up your environment on first boot."
url: https://edge.network/docs/compute/scripts/
---

# Startup Scripts

Automation

# Startup Scripts

Run scripts automatically on new VMs after OS installation. Choose from the Edge library or bring your own.

## How It Works

Startup scripts execute once, automatically, when a VM first boots. They run as `root` via the guest agent — no SSH connection required. Scripts have a 10-minute timeout, and their output is captured for debugging.

1
Select a script when creating a VM
2
VM boots and OS installs
3
Script runs automatically

## Edge Script Library

Pre-built, tested scripts maintained by Edge. Available to all users out of the box.

### Web Servers & Stacks

| Script | Description | Parameters |
| LAMP Stack | Apache, MySQL 8, PHP 8.3 | `db_password` |
| LEMP Stack | Nginx, MySQL 8, PHP 8.3-FPM | `db_password` |
| Node.js | Node.js 22 LTS, PM2, Nginx reverse proxy | `node_version` |
| Python | Python 3.12, pip, Gunicorn, Nginx | — |

### Applications

| Script | Description | Parameters |
| WordPress | Nginx, MySQL, PHP-FPM, WP-CLI | `site_title` `admin_email` `db_password` |
| Docker | Docker CE, Docker Compose | — |

### Development Tools

| Script | Description | Parameters |
| PostgreSQL | PostgreSQL 16, remote access configured | `db_password` `db_name` |
| Redis | Redis 7, password auth, AOF persistence | `redis_password` |

### Security

| Script | Description | Parameters |
| Hardened SSH | Disable password auth, fail2ban, UFW | — |

## Using a Script When Creating a VM

- Navigate to **Compute → Create VM**
- Configure your VM as usual (region, OS, resources, SSH keys)
- In the **Startup Script** section, select a script from the dropdown
- If the script has parameters, fill them in (passwords are auto-generated if left blank)
- Click **Create VM**

The script will run automatically once the VM finishes provisioning. You can check its status on the VM detail page.

**Tip:** Scripts run before SSH is available. Your VM's software will be ready by the time you connect.

## Creating Custom Scripts

Create your own scripts to automate any setup you need.

- Go to **Compute → Scripts**
- Switch to the **My Scripts** tab
- Click **Create Script**
- Write your bash script and optionally define parameters
- Save — your script is now available in the VM creation dropdown

### Script Guidelines

Start with `#!/bin/bash` and `set -e`

Exit on error so failures are caught and reported.

Log progress with `echo`

Output is captured and visible on the VM detail page.

Use `export DEBIAN_FRONTEND=noninteractive`

Prevents apt from prompting for input during package installation.

Keep it under 10 minutes

Scripts are killed after 10 minutes. For longer setups, have the script kick off a background task.

### Parameters

Use the `${param_name}` syntax in your script. When the VM is created, parameter values are substituted before execution.

```
#!/bin/bash
set -e

DB_PASSWORD="${db_password:-$(openssl rand -base64 16)}"

echo "Setting up database with password: $DB_PASSWORD"
# ... your setup logic ...
```

The `:-default` syntax provides a fallback if the parameter is empty.

## Checking Execution Status

After creating a VM with a startup script, you can monitor its progress on the VM detail page.

**Pending** — VM is still provisioning, script queued
**Running** — script is executing inside the VM
**Completed** — script finished successfully
**Failed** — script encountered an error (click "View output" for details)

## API & Agent Access

Startup scripts can also be used via the API and the AI agent.

### Inline Script (API / Agent)

Pass a script directly when creating a VM using the `setup_script` field:

```
POST /agent/compute/vms
{
  "name": "my-server",
  "size": "small",
  "setup_script": "#!/bin/bash\nset -e\napt update && apt install -y nginx"
}
```

### Using a Library Script (Agent)

```
POST /agent/deploy/app
{
  "project": "my-blog",
  "compute": {
    "size": "small",
    "setup_script": "#!/bin/bash\n..."
  }
}
```

### Checking Status

```
GET /api/compute/vms/{vm_id}/scripts

{
  "executions": [
    {
      "id": "...",
      "script_name": "setup_script",
      "status": "completed",
      "output": "=== Docker Installed ===\nDocker: Docker version 27.4...",
      "started_at": "2026-03-03T00:15:00Z",
      "completed_at": "2026-03-03T00:17:34Z"
    }
  ]
}
```

## Troubleshooting

### Script shows "Failed"

- • Click "View output" on the VM detail page to see the error
- • Make sure your script starts with `#!/bin/bash`
- • Check that all package names are correct for the selected OS
- • Ensure `DEBIAN_FRONTEND=noninteractive` is set for apt commands

### Script still "Pending" after VM is running

Scripts are executed shortly after the VM reaches "running" status. Allow up to 30 seconds for the guest agent to initialise. If the status doesn't change, the guest agent may not be available — try restarting the VM.

### Script timed out

Scripts are killed after 10 minutes. If your setup takes longer, have the script start a background process and exit. For example, use `nohup ./long-task.sh &`.

[Back to Docs](https://edge.network/docs) [Need help?](https://edge.network/support)
