fix(installer): preserve secrets across re-runs
Re-running the installer after a failed build regenerated JWT_SECRET and MARIADB_ROOT_PASS, overwriting .env with values that didn't match the already-set MariaDB password. Now reads existing .env values and only generates new ones on a fresh install.
This commit is contained in:
@@ -6,6 +6,13 @@ Pre-1.0 versions treat MINOR as feature releases and PATCH as bug fixes.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## [0.6.5] — 2026-04-12
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
- **`install.sh` regenerates secrets on re-run** — `JWT_SECRET`, `JWT_REFRESH_SECRET`, and `MARIADB_ROOT_PASS` were always generated fresh, so re-running the installer after a failed build overwrote `.env` with secrets that no longer matched the already-configured MariaDB password. The installer now reads existing values from `.env` (if present) and only generates new secrets when none exist.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## [0.6.4] — 2026-04-12
|
## [0.6.4] — 2026-04-12
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nixpanel-server",
|
"name": "nixpanel-server",
|
||||||
"version": "0.6.4",
|
"version": "0.6.5",
|
||||||
"private": true,
|
"private": true,
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"server",
|
"server",
|
||||||
|
|||||||
+14
-4
@@ -82,11 +82,21 @@ if [[ -z "$ADMIN_EMAIL" ]]; then
|
|||||||
ADMIN_EMAIL="admin@$(hostname -f 2>/dev/null || echo localhost)"
|
ADMIN_EMAIL="admin@$(hostname -f 2>/dev/null || echo localhost)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Redirect all interactive reads to /dev/tty so curl | bash works correctly
|
# ── Preserve secrets across re-runs ──────────────────────────────────────────
|
||||||
|
# If .env already exists, reuse the same secrets so a failed-and-retried
|
||||||
|
# install doesn't leave MariaDB with a password that doesn't match .env.
|
||||||
|
_EXISTING_ENV="${INSTALL_DIR}/server/.env"
|
||||||
|
if [[ -f "$_EXISTING_ENV" ]]; then
|
||||||
|
_read_env() { grep -m1 "^$1=" "$_EXISTING_ENV" 2>/dev/null | cut -d= -f2- | tr -d '"'; }
|
||||||
|
MARIADB_ROOT_PASS=$(_read_env MARIADB_PASSWORD)
|
||||||
|
JWT_SECRET=$(_read_env JWT_SECRET)
|
||||||
|
JWT_REFRESH_SECRET=$(_read_env JWT_REFRESH_SECRET)
|
||||||
|
fi
|
||||||
|
|
||||||
MARIADB_ROOT_PASS=$(openssl rand -base64 24 | tr -dc 'a-zA-Z0-9' | head -c 24)
|
# Fill in any values that weren't in the existing .env (or first install)
|
||||||
JWT_SECRET=$(gen_secret)
|
MARIADB_ROOT_PASS=${MARIADB_ROOT_PASS:-$(openssl rand -base64 24 | tr -dc 'a-zA-Z0-9' | head -c 24)}
|
||||||
JWT_REFRESH_SECRET=$(gen_secret)
|
JWT_SECRET=${JWT_SECRET:-$(gen_secret)}
|
||||||
|
JWT_REFRESH_SECRET=${JWT_REFRESH_SECRET:-$(gen_secret)}
|
||||||
|
|
||||||
# ── Confirm ───────────────────────────────────────────────────────────────────
|
# ── Confirm ───────────────────────────────────────────────────────────────────
|
||||||
echo -e "${BOLD}Installation summary:${RESET}"
|
echo -e "${BOLD}Installation summary:${RESET}"
|
||||||
|
|||||||
+1
-1
@@ -73,7 +73,7 @@ export async function buildApp() {
|
|||||||
|
|
||||||
fastify.get('/api/health', async () => ({
|
fastify.get('/api/health', async () => ({
|
||||||
status: 'ok',
|
status: 'ok',
|
||||||
version: '0.6.4',
|
version: '0.6.5',
|
||||||
timestamp: new Date().toISOString(),
|
timestamp: new Date().toISOString(),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user