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