From 4d2262e48fa0d1734cf15b0a9fc5c71ac3a01047 Mon Sep 17 00:00:00 2001 From: saulteafarmer Date: Wed, 14 May 2025 16:39:31 +0000 Subject: [PATCH] Update setup.sh --- setup.sh | 62 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/setup.sh b/setup.sh index ac17acb..7c51c32 100644 --- a/setup.sh +++ b/setup.sh @@ -1,53 +1,59 @@ #!/usr/bin/env bash set -euo pipefail -REPO_DIR="." -SECRETS_DIR="$REPO_DIR/data/secrets" -RUNTIME_ENV="$SECRETS_DIR/runtime.env" +REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ENV_FILE="$REPO_DIR/.env" -# 1️⃣ Ensure secrets folder -mkdir -p "$SECRETS_DIR" - -# 2️⃣ If runtime.env already exists, source it -if [ -f "$RUNTIME_ENV" ]; then - echo "♻️ Found existing secrets in $RUNTIME_ENV — reusing." - # shellcheck disable=SC1091 - source "$RUNTIME_ENV" +if [ -f "$ENV_FILE" ]; then + echo "♻️ Found existing $ENV_FILE — reusing." else - echo "🔐 No existing secrets found. Generating new ones…" + echo "🔐 Generating new $ENV_FILE…" - # generate defaults + # ── Database defaults DB_USER="postgres" DB_PASS="$(openssl rand -hex 16)" DB_NAME="lnbitsdb" - FLASK_SECRET="$(openssl rand -hex 32)" DATABASE_URL="postgresql://${DB_USER}:${DB_PASS}@db:5432/${DB_NAME}" - cat > "$RUNTIME_ENV" < "$ENV_FILE" <}" -echo " DB_PASS: ${DB_PASS:-}" -echo " DB_NAME: ${DB_NAME:-}" +echo "🔑 Your Flask secret: $FLASK_SECRET" echo -echo "🔑 Flask session secret:" -echo " ${FLASK_SECRET:-}" -echo -echo "🌐 Open the web UI: http://localhost:3000" +echo "🌐 Web UI available at http://localhost:3000"