fix(installer): DB-Passwort-Mismatch bei Re-Install verhindern

Bei vorhandener config.yml wird das DB-Passwort daraus gelesen und
PostgreSQL entsprechend aktualisiert — verhindert Auth-Fehler beim
zweiten Installer-Durchlauf auf demselben Server.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
sysops
2026-03-20 01:05:51 +01:00
parent 48e04f36fd
commit d262253faf
+6
View File
@@ -101,6 +101,12 @@ info "Richte PostgreSQL ein..."
systemctl enable postgresql --quiet systemctl enable postgresql --quiet
systemctl start postgresql systemctl start postgresql
# Falls config.yml schon existiert, DB-Passwort daraus lesen (verhindert Passwort-Mismatch bei Re-Install)
if [ -f "$CONFIG_DIR/config.yml" ]; then
EXISTING_PW=$(grep -A5 '^database:' "$CONFIG_DIR/config.yml" | awk '/password:/{print $2}' | head -1)
[[ -n "$EXISTING_PW" ]] && DB_PASSWORD="$EXISTING_PW" && info "DB-Passwort aus vorhandener config.yml übernommen"
fi
su -c "psql -tc \"SELECT 1 FROM pg_roles WHERE rolname='archivmail'\" | grep -q 1 \ su -c "psql -tc \"SELECT 1 FROM pg_roles WHERE rolname='archivmail'\" | grep -q 1 \
&& psql -c \"ALTER USER archivmail WITH PASSWORD '$DB_PASSWORD'\" \ && psql -c \"ALTER USER archivmail WITH PASSWORD '$DB_PASSWORD'\" \
|| psql -c \"CREATE USER archivmail WITH PASSWORD '$DB_PASSWORD'\"" postgres || psql -c \"CREATE USER archivmail WITH PASSWORD '$DB_PASSWORD'\"" postgres