Files
euchre_camp/scripts/setup-casaos.sh
T
2026-03-31 03:57:07 -07:00

82 lines
2.5 KiB
Bash
Executable File

#!/bin/bash
# CasaOS Setup Script for EuchreCamp
# Run this script to prepare EuchreCamp for CasaOS deployment
set -e
echo "=========================================="
echo "EuchreCamp CasaOS Setup Script"
echo "=========================================="
echo ""
# Check if Docker is available
if ! command -v docker &> /dev/null; then
echo "❌ Docker is not installed or not in PATH"
echo "Please install Docker before continuing"
exit 1
fi
# Check if docker-compose is available
if ! command -v docker-compose &> /dev/null && ! docker compose version &> /dev/null; then
echo "❌ Docker Compose is not installed"
echo "Please install Docker Compose before continuing"
exit 1
fi
# Generate secrets if they don't exist
echo "Generating secrets..."
BETTER_AUTH_SECRET=$(openssl rand -base64 32 | tr -d '\n')
POSTGRES_PASSWORD=$(openssl rand -base64 16 | tr -d '\n')
echo "✅ Generated BETTER_AUTH_SECRET: $BETTER_AUTH_SECRET"
echo "✅ Generated POSTGRES_PASSWORD: $POSTGRES_PASSWORD"
echo ""
# Create .env file if it doesn't exist
if [ ! -f .env ]; then
echo "Creating .env file..."
cat > .env << EOF
# EuchreCamp Environment Configuration
# Generated by setup-casaos.sh
# Database Configuration
DATABASE_PROVIDER=postgresql
DATABASE_URL=postgresql://euchre:${POSTGRES_PASSWORD}@postgres:5432/euchre_camp
DATABASE_SHADOW_URL=postgresql://euchre:${POSTGRES_PASSWORD}@postgres:5432/euchre_camp_shadow
# Better Auth Configuration
BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET}
BETTER_AUTH_URL=http://localhost:3000
# Application Configuration
NODE_ENV=production
# Trusted Origins (update with your CasaOS IP/hostname)
TRUSTED_ORIGINS=http://localhost:3000,http://127.0.0.1:3000
EOF
echo "✅ Created .env file"
else
echo "⚠️ .env file already exists, skipping creation"
fi
echo ""
echo "=========================================="
echo "Setup Complete!"
echo "=========================================="
echo ""
echo "Next steps for CasaOS deployment:"
echo "1. Build the Docker image:"
echo " docker-compose -f docker-compose.casaos.yml build"
echo ""
echo "2. Start the application:"
echo " docker-compose -f docker-compose.casaos.yml up -d"
echo ""
echo "3. Access the application at http://localhost:3000"
echo ""
echo "4. Create admin user:"
echo " docker exec -it euchre-camp node scripts/create-admin-via-api.js"
echo ""
echo "Important: Update BETTER_AUTH_URL and TRUSTED_ORIGINS in .env"
echo "with your CasaOS server's IP address or hostname!"
echo ""