From 85af75b82acef725b7e243020861305016fbd4c9 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 20 Feb 2025 03:04:26 +0100 Subject: [PATCH] Use PGPASSWORD --- immich/rootfs/etc/cont-init.d/99-run.sh | 53 ++++++++++--------------- 1 file changed, 20 insertions(+), 33 deletions(-) diff --git a/immich/rootfs/etc/cont-init.d/99-run.sh b/immich/rootfs/etc/cont-init.d/99-run.sh index 194926a4f..5bbbc3141 100755 --- a/immich/rootfs/etc/cont-init.d/99-run.sh +++ b/immich/rootfs/etc/cont-init.d/99-run.sh @@ -89,7 +89,7 @@ setup_root_user() { else bashio::log.warning "DB_ROOT_PASSWORD not set. Generating a random 12-character alphanumeric password and storing it in the addon options." export DB_ROOT_PASSWORD="$(tr -dc 'A-Za-z0-9' /dev/null; then + # 1. Try connecting as root with the known default password "securepassword" + if PGPASSWORD="securepassword" psql -U root -h "${DB_HOSTNAME}" -p "${DB_PORT}" -d postgres -c '\q' 2>/dev/null; then + # If successful, root has the default password; update it bashio::log.info "Detected root user with default password. Updating to new DB_ROOT_PASSWORD..." - psql "postgres://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOSTNAME}:${DB_PORT}" <