From 41126309f874a244f54cfd0fd87f7ee32fd02194 Mon Sep 17 00:00:00 2001 From: saulteafarmer Date: Wed, 14 May 2025 16:17:35 +0000 Subject: [PATCH] Update setup.sh --- setup.sh | 48 ++++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/setup.sh b/setup.sh index 39e3755..ac17acb 100644 --- a/setup.sh +++ b/setup.sh @@ -5,18 +5,25 @@ REPO_DIR="." SECRETS_DIR="$REPO_DIR/data/secrets" RUNTIME_ENV="$SECRETS_DIR/runtime.env" -# 1️⃣ Create secrets folder +# 1️⃣ Ensure secrets folder mkdir -p "$SECRETS_DIR" -# 2️⃣ Generate per‐install secrets -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}" +# 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" +else + echo "🔐 No existing secrets found. Generating new ones…" -# 3️⃣ Write runtime.env -cat > "$RUNTIME_ENV" < "$RUNTIME_ENV" <}" +echo " DB_PASS: ${DB_PASS:-}" +echo " DB_NAME: ${DB_NAME:-}" echo -echo "▶️ Access the web UI at: http://localhost:3000" +echo "🔑 Flask session secret:" +echo " ${FLASK_SECRET:-}" +echo +echo "🌐 Open the web UI: http://localhost:3000"