#!/bin/bash # NextSnap Setup Script set -e echo "NextSnap Setup" echo "==============" echo "" # Check if .env exists if [ -f .env ]; then echo "✓ .env file already exists" read -p "Do you want to overwrite it? (y/N) " -n 1 -r echo "" if [[ ! $REPLY =~ ^[Yy]$ ]]; then echo "Keeping existing .env file" exit 0 fi fi # Copy .env.example cp .env.example .env echo "✓ Created .env file" # Generate secret key SECRET_KEY=$(python3 -c "import secrets; print(secrets.token_hex(32))") sed -i "s/your-secret-key-here/$SECRET_KEY/" .env echo "✓ Generated SECRET_KEY" # Get Nextcloud URL read -p "Enter your Nextcloud URL (e.g., https://cloud.example.com): " NEXTCLOUD_URL if [ -n "$NEXTCLOUD_URL" ]; then sed -i "s|https://nextcloud.example.com|$NEXTCLOUD_URL|" .env echo "✓ Set NEXTCLOUD_URL" fi # Get port read -p "Enter port to expose (default: 8000): " PORT if [ -n "$PORT" ]; then sed -i "s/PORT=8000/PORT=$PORT/" .env echo "✓ Set PORT" fi echo "" echo "Setup complete! Configuration saved to .env" echo "" echo "Next steps:" echo " 1. Review and adjust .env if needed" echo " 2. Run: make build" echo " 3. Run: make up" echo " 4. Visit: http://localhost:${PORT:-8000}" echo "" echo "For production deployment, see DEPLOYMENT.md"