Spaces:
Running on CPU Upgrade

lighting-mvp / scripts /setup.sh
DanielKretschmer's picture
WonderAnaconda
Lighting MVP
427634d
Raw History Blame Contribute Delete
2.99 kB
#!/usr/bin/env bash
#
# Lighting MVP one-time setup script.
#
# Generates a .env file with the minimum required environment variables.
# Read HANDOVER.md before running this; it explains what the values mean
# and which optional settings you may want to add.
#
# Usage:
# scripts/setup.sh # writes .env if missing
# scripts/setup.sh --force # overwrite existing .env (regenerates password)
# scripts/setup.sh --print # print to stdout, don't write
#
set -euo pipefail
force=false
print_only=false
for arg in "$@"; do
case "$arg" in
--force) force=true ;;
--print) print_only=true ;;
-h|--help)
sed -n '3,15p' "$0"
exit 0
;;
*)
echo "Unknown argument: $arg" >&2
echo "Use --help for usage." >&2
exit 2
;;
esac
done
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
ENV_FILE="$REPO_ROOT/.env"
if [[ -f "$ENV_FILE" && "$force" == false && "$print_only" == false ]]; then
echo "$ENV_FILE already exists. Pass --force to overwrite, or --print to dump a fresh template to stdout." >&2
exit 1
fi
# Generate a strong random password. Falls back to /dev/urandom if openssl is
# missing so the script works on minimal containers.
if command -v openssl >/dev/null 2>&1; then
ACCESS_PASSWORD="$(openssl rand -base64 24 | tr -d '/+=' | cut -c1-24)"
else
ACCESS_PASSWORD="$(tr -dc 'A-Za-z0-9' < /dev/urandom | head -c 24)"
fi
env_contents=$(cat <<EOF
# Lighting MVP environment configuration.
# Generated by scripts/setup.sh on $(date -u +"%Y-%m-%dT%H:%M:%SZ").
# Re-run with --force to regenerate the password.
#
# REQUIRED
# --------
# Shared password protecting the UI and all API endpoints. Anyone with
# this password can use the tool, so treat it like a service password:
# share over a secure channel, rotate if leaked.
LIGHTING_MVP_ACCESS_GATE_PASSWORD=$ACCESS_PASSWORD
# OPTIONAL
# --------
# Postgres connection string. Leave unset to use a local SQLite DB
# (lighting_mvp.db). Set to a Neon / RDS / hosted Postgres URL for any
# shared or persistent deployment.
# LIGHTING_MVP_DATABASE_URL=postgresql://user:pass@host:5432/dbname
# Where transient pipeline files are staged. Default is /tmp (ephemeral).
# Mount a persistent volume and point this at it for prod.
# LIGHTING_MVP_STORAGE_ROOT=/data
# Which LLM provider to use. Can also be changed live from the gear icon.
# LIGHTING_MVP_AGENT_PROVIDER=anthropic
EOF
)
if [[ "$print_only" == true ]]; then
echo "$env_contents"
exit 0
fi
echo "$env_contents" > "$ENV_FILE"
chmod 600 "$ENV_FILE"
echo "Wrote $ENV_FILE (mode 0600)."
echo
echo "Next steps:"
echo " 1. docker build -t lighting-mvp ."
echo " 2. docker run --rm -p 7860:7860 --env-file .env lighting-mvp"
echo " 3. Open http://localhost:7860 and log in with the password in .env"
echo " 4. Click the gear icon (⚙) to complete the Claude or Codex login flow."
echo
echo "Full walkthrough: HANDOVER.md"