#!/bin/bash set -e ENV_FILE=".env" ENV_EXAMPLE=".env.example" echo "Kaboot Setup Script" echo "===================" echo "" if [ -f "$ENV_FILE" ]; then read -p ".env file already exists. Overwrite? (y/N): " -n 1 -r echo "" if [[ ! $REPLY =~ ^[Yy]$ ]]; then echo "Aborting. Existing .env file preserved." exit 0 fi fi if [ ! -f "$ENV_EXAMPLE" ]; then echo "Error: .env.example not found. Run this script from the project root." exit 1 fi echo "Generating secrets..." PG_PASS=$(openssl rand -base64 36 | tr -d '\n') AUTHENTIK_SECRET_KEY=$(openssl rand -base64 60 | tr -d '\n') cp "$ENV_EXAMPLE" "$ENV_FILE" if [[ "$OSTYPE" == "darwin"* ]]; then sed -i '' "s|^PG_PASS=.*|PG_PASS=${PG_PASS}|" "$ENV_FILE" sed -i '' "s|^AUTHENTIK_SECRET_KEY=.*|AUTHENTIK_SECRET_KEY=${AUTHENTIK_SECRET_KEY}|" "$ENV_FILE" else sed -i "s|^PG_PASS=.*|PG_PASS=${PG_PASS}|" "$ENV_FILE" sed -i "s|^AUTHENTIK_SECRET_KEY=.*|AUTHENTIK_SECRET_KEY=${AUTHENTIK_SECRET_KEY}|" "$ENV_FILE" fi echo "" echo "Created .env file with generated secrets." echo "" echo "Next steps:" echo " 1. Review .env and adjust settings if needed" echo " 2. Run: docker compose up -d" echo " 3. Open: http://localhost:9000/if/flow/initial-setup/" echo " 4. Follow docs/AUTHENTIK_SETUP.md to configure the OAuth2 provider" echo ""