Add droplet sync and startup scripts

- droplet-sync.sh: Syncs assets from LFS repo on boot
- ralpha-ue5.service: Systemd service for auto-start
- droplet-setup-ue5-project.sh: One-time setup script

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
jamestagg 2026-01-20 17:27:30 -08:00
parent 22cac6b96b
commit ad72081760
4 changed files with 167 additions and 0 deletions

1
.gitignore vendored
View File

@ -40,3 +40,4 @@ Desktop.ini
# Starter content (if using)
**/StarterContent/
repomix-output.txt

View File

@ -0,0 +1,63 @@
#!/bin/bash
# One-time setup for ralpha-ue5 on DO droplet
# Run this after base UE5 is installed
set -e
REPO_DIR="/opt/ralpha-ue5"
GITHUB_TOKEN="${GITHUB_TOKEN:-}"
echo "=== Setting up ralpha-ue5 on droplet ==="
# Install jq for JSON parsing
apt-get update && apt-get install -y jq
# Create ralpha user if not exists
if ! id "ralpha" &>/dev/null; then
useradd -m -s /bin/bash ralpha
fi
# Clone ralpha-ue5 with LFS
if [ ! -d "$REPO_DIR" ]; then
echo "Cloning ralpha-ue5..."
if [ -n "$GITHUB_TOKEN" ]; then
git clone "https://${GITHUB_TOKEN}@github.com/jamestagg/ralpha-ue5.git" "$REPO_DIR"
else
git clone "https://github.com/jamestagg/ralpha-ue5.git" "$REPO_DIR"
fi
cd "$REPO_DIR"
git lfs install
git lfs pull
else
echo "ralpha-ue5 already exists at $REPO_DIR"
fi
# Create log directories
mkdir -p /var/log/ralpha
mkdir -p /var/lib/ralpha
chown -R ralpha:ralpha /var/log/ralpha /var/lib/ralpha
# Set ownership
chown -R ralpha:ralpha "$REPO_DIR"
# Make scripts executable
chmod +x "$REPO_DIR/scripts/"*.sh
# Create symlink for plugin (assumes main ralpha repo is at /opt/ralpha)
if [ -d "/opt/ralpha/plugin" ] && [ ! -L "$REPO_DIR/Plugins/RalphaPlugin" ]; then
mkdir -p "$REPO_DIR/Plugins"
ln -sf /opt/ralpha/plugin "$REPO_DIR/Plugins/RalphaPlugin"
echo "Created plugin symlink"
fi
# Install systemd service
cp "$REPO_DIR/scripts/ralpha-ue5.service" /etc/systemd/system/
systemctl daemon-reload
systemctl enable ralpha-ue5
echo "=== Setup complete ==="
echo "To start: systemctl start ralpha-ue5"
echo "To check status: systemctl status ralpha-ue5"
echo "Logs: /var/log/ralpha/"

65
scripts/droplet-sync.sh Normal file
View File

@ -0,0 +1,65 @@
#!/bin/bash
# Sync ralpha-ue5 assets on droplet boot
# Called by systemd service before launching UE5
set -e
REPO_DIR="${RALPHA_UE5_DIR:-/opt/ralpha-ue5}"
CATALOGUE_PATH="$REPO_DIR/RalphaData/catalogue/catalogue.json"
HASH_FILE="/var/lib/ralpha/catalogue-hash"
LOG_FILE="/var/log/ralpha/sync.log"
log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" | tee -a "$LOG_FILE"
}
mkdir -p "$(dirname "$LOG_FILE")"
mkdir -p "$(dirname "$HASH_FILE")"
log "Starting ralpha-ue5 sync..."
cd "$REPO_DIR"
# Store previous catalogue hash
PREV_HASH=""
if [ -f "$HASH_FILE" ]; then
PREV_HASH=$(cat "$HASH_FILE")
fi
# Fetch and pull latest
log "Fetching from origin..."
git fetch origin
# Check if we're behind
LOCAL=$(git rev-parse HEAD)
REMOTE=$(git rev-parse origin/master 2>/dev/null || git rev-parse origin/main)
if [ "$LOCAL" != "$REMOTE" ]; then
log "Updates available, pulling..."
git pull --ff-only
# Pull LFS objects for new/changed files
log "Pulling LFS objects..."
git lfs pull
log "Pull complete."
else
log "Already up to date."
fi
# Check catalogue hash
if [ -f "$CATALOGUE_PATH" ]; then
CURRENT_HASH=$(jq -r '.catalogue_hash // empty' "$CATALOGUE_PATH" 2>/dev/null || echo "unknown")
echo "$CURRENT_HASH" > "$HASH_FILE"
if [ "$PREV_HASH" != "$CURRENT_HASH" ]; then
log "Catalogue updated: $PREV_HASH -> $CURRENT_HASH"
# Could trigger cache invalidation or notify MCP server here
else
log "Catalogue unchanged: $CURRENT_HASH"
fi
else
log "Warning: Catalogue not found at $CATALOGUE_PATH"
fi
log "Sync complete."

View File

@ -0,0 +1,38 @@
[Unit]
Description=Ralpha UE5 Asset Server
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=ralpha
Group=ralpha
Environment="DISPLAY=:99"
Environment="RALPHA_UE5_DIR=/opt/ralpha-ue5"
Environment="UE5_DIR=/opt/UnrealEngine"
# Sync assets before starting
ExecStartPre=/opt/ralpha-ue5/scripts/droplet-sync.sh
# Start virtual framebuffer
ExecStartPre=/usr/bin/Xvfb :99 -screen 0 1920x1080x24 &
# Launch UE5 with ralpha-ue5 project (headless, MCP server enabled)
ExecStart=/opt/UnrealEngine/Engine/Binaries/Linux/UnrealEditor \
/opt/ralpha-ue5/Ralpha.uproject \
-RenderOffscreen \
-NoSound \
-NullRHI=0 \
-Vulkan \
-log \
-unattended
Restart=on-failure
RestartSec=10
# Logging
StandardOutput=append:/var/log/ralpha/ue5.log
StandardError=append:/var/log/ralpha/ue5-error.log
[Install]
WantedBy=multi-user.target