Before you begin
Use the v0.13 CLI and authenticate. Run workspace-management and recipe commands from your local terminal. Commands identified as running inside a workspace require its console terminal or SSH session. Replace example resource IDs with the values returned for your account. Create, update, and delete setup scripts from your local terminal. Inside a workspace,rig setup-script ls works, but the commands that change a script refuse: an account script also runs in your other workspaces, so a workspace can’t change one.
How Setup Scripts Work
When a workspace starts, Rigbox executes all attached setup scripts inside the VM as thedeveloper user. Scripts run sequentially in the order you specify, with the workspace’s network access and sudo privileges.
Each script has a run mode that controls when it executes:
Create a Setup Script
Write the script to a local file, then create it with the CLI. The CLI create command uses the API’s defaultfirst_boot run mode; use the Setup Scripts API when you need to explicitly choose every_start. Once created, attach its returned ID to the intended workspaces.
Script Content Guidelines
Setup scripts run as bash inside the workspace VM. Here are guidelines for writing reliable scripts:Attach Scripts to a Workspace
Pass--setup-script-id (repeatable) when spawning a workspace. Scripts run in the order you list them.
Script Ordering
Scripts execute sequentially in array order. This is important when scripts have dependencies:List Your Scripts
Retrieve all setup scripts in your account.Update a Script
Modify an existing script’s name and/or body. Pass--name, --file, or both.
Updating a script affects all future workspace starts that reference it. Already-running workspaces will pick up the change on their next restart (for
every_start scripts) or not at all (for first_boot scripts that have already executed).Delete a Script
Combining with Templates
Templates can include their own setup scripts. When you create a workspace with both a template and additionalsetup_script_ids, the template’s scripts run first, followed by yours.
- Template
devscripts (e.g., install Node.js, npm packages) - Your script
ss_my_custom_config(e.g., clone your repo, set up environment)
Use Case: Team Onboarding
Create a single setup script that configures everything a new team member needs. Every workspace they create starts fully configured.Use Case: Ephemeral Demo Environments
For product demos, create a setup script that loads sample data and starts services:Debugging Setup Scripts
If a setup script fails, the workspace will still start, but the script’s exit code and output are captured. Read workspace logs after startup; there is nosetup_status field to query on the workspace response:
Verify and troubleshoot
Use the returned definition ID when attaching it to a workspace. After startup, inspectrig workspace logs --workspace WORKSPACE_ID; for service specs, check the installed unit with the commands above. A running VM does not prove a setup script or application completed successfully.
For failures, start with runtime logs, health checks, or resource exhaustion.
Next Steps
- Service Specs - define background services that auto-start after setup completes
- Snapshots - snapshot a fully configured workspace and restore it later
- Managed AI Proxy - add AI capabilities to your scripted environments