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}" <