LightYear
/Docs
DocsComputeAutomate Server Setup with Startup Scripts

Automate Server Setup with Startup Scripts

Use cloud-init user data scripts to automatically configure your server on first boot.

intermediate
6 min read
LightYear Team
Updated April 24, 2026
cloud-initautomationstartupscripts
Ready to get started?

What Are Startup Scripts?

Startup scripts (cloud-init user data) run automatically when a server boots for the first time. Use them to install packages, configure services, and set up your environment without manual SSH.

Adding a Startup Script at Deploy Time

In the Deploy Server form, expand Advanced Options and paste your script in the User Data field.

Example: Install Docker and Pull an Image

>_BASH
$#!/bin/bash
$set -e
$
$# Update system
$apt-get update -y
$apt-get upgrade -y
$
$# Install Docker
$curl -fsSL https://get.docker.com | sh
$
$# Pull and run a container
$docker pull nginx:latest
$docker run -d -p 80:80 --name web nginx:latest
$
$echo "Setup complete" >> /var/log/startup.log

Example: Configure a GPU ML Environment

>_BASH
$#!/bin/bash
$set -e
$
$# Install CUDA
$wget -q https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
$dpkg -i cuda-keyring_1.1-1_all.deb
$apt-get update -q
$apt-get install -y cuda-12-2
$
$# Install Python packages
$pip3 install torch torchvision jupyterlab
$
$# Start Jupyter
$nohup jupyter lab --no-browser --ip=0.0.0.0 --port=8888 &

Viewing Script Output

>_BASH
$cat /var/log/cloud-init-output.log

Limitations

LimitationDetail
Execution timeScripts must complete within 30 minutes
Root accessScripts run as root by default
One-time onlyRuns on first boot only
Size limit64 KB maximum

Was this article helpful?

Your cookie choices for this website

This site uses cookies and related technologies, as described in our privacy policy, for purposes that may include site operation, analytics, and enhanced user experience. You may choose to consent to our use of these technologies, or manage your own preferences. Cookie policy