From 4d86a57d751b44ee1dd2c91cbb20c6259b934a95 Mon Sep 17 00:00:00 2001 From: Bastian de Byl Date: Wed, 26 Aug 2026 02:10:51 -0400 Subject: [PATCH] fix: stop the Zomboid entrypoint withholding the admin password The flag was gated on the admin database not existing yet, treating the file's presence as proof the admin user had been created. It is not: PZ creates the DB file in ServerWorldDatabase.create() before it creates the admin user, so a boot interrupted between the two leaves a database with no admin in it. After that the guard withheld -adminpassword on every subsequent start, the server fell back to an interactive "Enter new administrator password:" prompt, read EOF because a detached container has no stdin, and died with NoSuchElementException. systemd restarted it into exactly the same state, 50 times, which is how this was found. Passing it unconditionally costs nothing when the admin already exists and removes the deadlock entirely. Co-Authored-By: Claude Opus 5 (1M context) --- .../podman/templates/zomboid/entrypoint.sh.j2 | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/ansible/roles/podman/templates/zomboid/entrypoint.sh.j2 b/ansible/roles/podman/templates/zomboid/entrypoint.sh.j2 index 049e743..4c0ca9b 100644 --- a/ansible/roles/podman/templates/zomboid/entrypoint.sh.j2 +++ b/ansible/roles/podman/templates/zomboid/entrypoint.sh.j2 @@ -73,17 +73,22 @@ configure_memory() { } configure_memory -# Check if first run (no admin DB) -ADMIN_DB="${CONFIG_DIR}/db/${SERVER_NAME}.db" - # Build server arguments # Note: -modfolders is NOT used - mods are configured via INI only # Reference: IndifferentBroccoli/projectzomboid-server-docker SERVER_ARGS="-cachedir=${CONFIG_DIR} -servername ${SERVER_NAME}" -# Add admin password for first run -if [ ! -f "${ADMIN_DB}" ] && [ -n "${ADMIN_PASSWORD}" ]; then - echo "=== First run: setting admin password ===" +# Always pass the admin password when we have one. +# +# This used to be gated on the admin DB not existing yet, on the assumption that +# the file's presence meant the admin user was already set up. It does not: PZ +# creates the DB file in ServerWorldDatabase.create() *before* it creates the +# admin user, so any boot interrupted between those two steps leaves a database +# that exists but has no admin. From then on the guard withheld the flag, the +# server fell back to an interactive "Enter new administrator password:" prompt, +# read EOF because a detached container has no stdin, and died with +# NoSuchElementException -- on every restart, forever. +if [ -n "${ADMIN_PASSWORD}" ]; then SERVER_ARGS="${SERVER_ARGS} -adminpassword ${ADMIN_PASSWORD}" fi