#!/usr/bin/env bash # Script to set up a test VM with *arr services # This script can be run in CI/CD or manually to configure test services set -e echo "Setting up test VM for Movie Map..." # Configuration RADARR_URL="${RADARR_URL:-http://localhost:7878}" SONARR_URL="${SONARR_URL:-http://localhost:8989}" LIDARR_URL="${LIDARR_URL:-http://localhost:8686}" # Test API keys (should be set via environment variables in CI/CD) RADARR_API_KEY="${RADARR_API_KEY:-test-radarr-key}" SONARR_API_KEY="${SONARR_API_KEY:-test-sonarr-key}" LIDARR_API_KEY="${LIDARR_API_KEY:-test-lidarr-key}" echo "Waiting for services to be ready..." sleep 10 # Function to wait for service to be ready wait_for_service() { local url=$1 local name=$2 local max_attempts=30 local attempt=0 echo "Waiting for $name to be ready at $url..." while [ $attempt -lt $max_attempts ]; do if curl -s -f "$url/api/v3/system/status" > /dev/null 2>&1 || \ curl -s -f "$url/api/v3/system/status" > /dev/null 2>&1 || \ curl -s -f "$url/api/v1/system/status" > /dev/null 2>&1; then echo "$name is ready!" return 0 fi attempt=$((attempt + 1)) sleep 2 done echo "Warning: $name did not become ready in time" return 1 } # Wait for services (if they're running) wait_for_service "$RADARR_URL" "Radarr" || true wait_for_service "$SONARR_URL" "Sonarr" || true wait_for_service "$LIDARR_URL" "Lidarr" || true echo "Test VM setup complete!" echo "RADARR_URL=$RADARR_URL" echo "SONARR_URL=$SONARR_URL" echo "LIDARR_URL=$LIDARR_URL" echo "" echo "Note: In a real CI/CD environment, you would:" echo "1. Start *arr services (via Docker, NixOS, or other means)" echo "2. Configure API keys via their web interfaces or APIs" echo "3. Add test data (10 movies, 10 shows, 10 artists)" echo "4. Set environment variables for the test suite"