
Game Configuration: Scripts & Lifecycle
This is Part 7 of the Game Configuration series. Scripts let you run custom commands at specific points during a game server's lifecycle β before or after install, start, and stop events.
What Are Lifecycle Scripts?
Lifecycle scripts are custom shell or PowerShell scripts that execute automatically during server operations. They're used for tasks like:
- Downloading game files during installation
- Setting file permissions before startup
- Backing up world data before shutdown
- Running update checks after installation
- Cleaning temporary files after stopping
Script Properties
Each script has several key settings:
Timing
When the script runs relative to the event:
- Before β runs before the event (e.g., before installation starts)
- After β runs after the event completes (e.g., after installation finishes)
Event
Which lifecycle event triggers the script:
| Event | When It Fires |
|---|---|
| Install | When the game server is being installed or reinstalled |
| Start | When the game server is starting up |
| Stop | When the game server is shutting down |
Common Combinations
| Timing + Event | Use Case |
|---|---|
| Before Install | Download game files via SteamCMD or curl |
| After Install | Set permissions, copy default configs |
| Before Start | Check for updates, validate files |
| After Start | Send notification, register with master server |
| Before Stop | Save world, create backup |
| After Stop | Clean up temp files, compress logs |
Platform
Which operating system the script targets:
- Both β runs on Windows and Linux nodes (provide scripts for each)
- Windows Only β only runs on Windows nodes
- Linux Only β only runs on Linux nodes
When set to "Both", you write separate scripts for each platform using the platform tabs in the script editor.
Execution Context
Where the script runs:
- Docker Container β runs inside a Docker container (isolated, safe, can use a different image)
- Node Server (Host) β runs directly on the host machine (has full access)
Most scripts should use Docker Container for safety. Use Node Server only when the script needs host-level access.
Docker Container Settings
When using Docker Container context, you can configure:
- Container Image β override the default image (e.g., use a Debian installer image for downloading files)
- Container Entrypoint β the shell to use (bash, sh, ash)
- Container Mount Path β where the server files are mounted inside the container
This is particularly useful for installation scripts that need tools not present in the game's runtime image.
Advanced Settings
- Working Directory β the directory where the script executes (default:
/) - Timeout β maximum time in seconds before the script is killed (0 = unlimited)
- Retry on Failure β automatically retry the script if it fails
- Max Retries β how many times to retry (default: 3)
Script Content
The script editor provides a full code editor with syntax highlighting. Write your script in either Bash (Linux) or PowerShell (Windows) using the platform tabs.
Environment variables from the game config are available inside scripts. You can reference them directly:
#!/bin/bash
echo "Installing to ${SERVER_FOLDER}"
echo "Server name: ${SERVER_NAME}"
Ordering
Scripts can be reordered by dragging them in the list. Scripts execute in the order shown β top to bottom β for each timing+event combination.
Tips
- Use the "Before Install" event for SteamCMD downloads β this is where most game templates fetch their files
- Set a reasonable timeout for installation scripts β some game downloads take several minutes
- The Docker Container context with a custom image (like
ghcr.io/ptero-eggs/installers:debian) gives you access to tools likecurl,unzip, andjqthat may not be in the game's runtime image - Scripts show their timing, event, and platform as badges in the list for quick identification
- You can enable/disable individual scripts with the toggle β useful for temporarily skipping a script without deleting it