rybbit/setup.sh
Bill Yang 1d0ffdf9d9 Refactor authentication and environment configuration
- Removed the .env.example file as it is no longer needed.
- Added DISABLE_SIGNUP environment variable to docker-compose files for cloud and development environments.
- Updated setup script to include DISABLE_SIGNUP with a default value of false.
- Modified auth.ts to utilize DISABLE_SIGNUP for controlling signup functionality.
- Introduced DISABLE_SIGNUP constant in const.ts to manage its value from environment variables.
2025-05-03 13:14:13 -07:00

44 lines
No EOL
1.3 KiB
Bash

#!/bin/bash
# Exit immediately if a command exits with a non-zero status.
set -e
# Check if domain name argument is provided
if [ -z "$1" ]; then
echo "Usage: $0 <domain_name>"
echo "Example: $0 myapp.example.com"
exit 1
fi
DOMAIN_NAME="$1"
BASE_URL="https://${DOMAIN_NAME}"
# Generate a secure random secret for BETTER_AUTH_SECRET
# Uses OpenSSL if available, otherwise falls back to /dev/urandom
if command -v openssl &> /dev/null; then
BETTER_AUTH_SECRET=$(openssl rand -hex 32)
elif [ -e /dev/urandom ]; then
BETTER_AUTH_SECRET=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 32)
else
echo "Error: Could not generate secure secret. Please install openssl or ensure /dev/urandom is available." >&2
exit 1
fi
# Create or overwrite the .env file
echo "Creating .env file..."
cat > .env << EOL
# Variables configured by setup.sh
DOMAIN_NAME=${DOMAIN_NAME}
BASE_URL=${BASE_URL}
BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET}
DISABLE_SIGNUP=false
EOL
echo ".env file created successfully with domain ${DOMAIN_NAME}."
# Build and start the Docker Compose stack
echo "Building and starting Docker services..."
docker compose up --build -d
echo "Setup complete. Services are starting in the background."
echo "You can monitor logs with: docker compose logs -f"