Fix DB/admin password regeneration on rerun in 5 services
Same bug class just fixed in mattermost.sh: immich, joplin, koha, mail-archiver, and nextcloud all generated a fresh random DB/admin password on every single run with no check for an existing one. Each backs its database with a persistent volume, so Postgres/MariaDB keeps the password from its first init while the freshly overwritten .env (or config-main.env for koha) no longer matches it — any rerun would have locked the app out of its own database. koha, mail-archiver, and nextcloud also regenerated an app-level admin login password the same way. Found by cross-referencing every service with a DB password against which ones actually guard reuse on rerun (only traccar.sh did, already correctly) rather than waiting to be told about each one individually. Fix mirrors traccar.sh's existing pattern: read the password back out of the existing .env/config file if present, only generate fresh when there's genuinely nothing there yet. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NQkdAn3iG5A4WoqU9FHMaN
This commit is contained in:
+6
-2
@@ -197,8 +197,12 @@ install_joplin() {
|
||||
ensure_docker_dir_ownership "$JOPLIN_DIR"
|
||||
cd "$JOPLIN_DIR" || return 1
|
||||
|
||||
local DB_PASS
|
||||
DB_PASS="$(generate_password 32)"
|
||||
# Reused across reruns if already set — the Postgres volume keeps the
|
||||
# password from its first init, so a fresh random one on every rerun
|
||||
# would lock Joplin out of its own database.
|
||||
local DB_PASS=""
|
||||
[ -f ".env" ] && DB_PASS="$(grep '^POSTGRES_PASSWORD=' .env | cut -d= -f2-)"
|
||||
[ -n "$DB_PASS" ] || DB_PASS="$(generate_password 32)"
|
||||
local BASE_URL="https://joplin.${SITE_DOMAIN}"
|
||||
|
||||
# Mirrors configure_caddy_for_service's own mode resolution (lib/common.sh):
|
||||
|
||||
Reference in New Issue
Block a user