The reset script died on its very first line. log() piped through tee into zomboid/logs/world-reset.log, that directory was owned by the container's subuid, and the script runs as the podman user -- so tee returned EACCES and set -e killed the run before it stopped the server or touched a save. Every `@bot` reset since had been a no-op that reported nothing. Nothing mounts zomboid/logs into a container; it only holds output from host-side helpers running as the podman user, so it is now owned by that user rather than by the subuid the container volumes need. log() no longer treats the file as load-bearing either. stdout is already captured by the journal, so an unwritable log is worth continuing past rather than aborting a wipe over. Verified end to end by writing the trigger exactly as the bot does: server stopped, saves and player database deleted, service restarted. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
63 lines
2.0 KiB
Django/Jinja
63 lines
2.0 KiB
Django/Jinja
#!/bin/bash
|
|
# Zomboid World Reset Script
|
|
# Triggered by systemd path unit when discord bot requests reset
|
|
|
|
set -e
|
|
|
|
LOGFILE="{{ podman_home }}/.local/share/volumes/zomboid/logs/world-reset.log"
|
|
TRIGGER_FILE="{{ podman_home }}/.local/share/volumes/gregtime/data/zomboid-reset.trigger"
|
|
SERVER_NAME="{{ zomboid_server_name }}"
|
|
SAVES_PATH="{{ podman_home }}/.local/share/volumes/zomboid/data/Saves/Multiplayer/${SERVER_NAME}"
|
|
DB_PATH="{{ podman_home }}/.local/share/volumes/zomboid/data/db/${SERVER_NAME}.db"
|
|
|
|
log() {
|
|
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $1"
|
|
echo "$msg"
|
|
# stdout is already captured by the journal; the file is a convenience.
|
|
# Never let it be fatal -- an unwritable log used to abort the whole wipe
|
|
# on the very first line, under set -e.
|
|
echo "$msg" >> "$LOGFILE" 2>/dev/null || true
|
|
}
|
|
|
|
# Ensure XDG_RUNTIME_DIR is set for systemctl --user
|
|
export XDG_RUNTIME_DIR="/run/user/$(id -u)"
|
|
|
|
log "World reset triggered"
|
|
|
|
# Read requester info from trigger file if available
|
|
# Note: Must use podman unshare because file is owned by container's UID (232071)
|
|
if podman unshare test -f "$TRIGGER_FILE"; then
|
|
REQUESTER=$(podman unshare cat "$TRIGGER_FILE")
|
|
log "Requested by: $REQUESTER"
|
|
podman unshare rm -f "$TRIGGER_FILE"
|
|
fi
|
|
|
|
# Stop server
|
|
log "Stopping zomboid service..."
|
|
systemctl --user stop zomboid.service || true
|
|
sleep 5
|
|
|
|
# Delete world (using podman unshare to work within user namespace)
|
|
log "Deleting world saves at: $SAVES_PATH"
|
|
if [[ -d "$SAVES_PATH" ]]; then
|
|
podman unshare rm -rf "$SAVES_PATH"
|
|
log "World saves deleted"
|
|
else
|
|
log "No world saves found at $SAVES_PATH"
|
|
fi
|
|
|
|
# Delete player database
|
|
log "Deleting player database at: $DB_PATH"
|
|
if [[ -f "$DB_PATH" ]]; then
|
|
podman unshare rm -f "$DB_PATH"
|
|
log "Player database deleted"
|
|
else
|
|
log "No database found at $DB_PATH"
|
|
fi
|
|
|
|
# Start server
|
|
log "Starting zomboid service..."
|
|
systemctl --user start zomboid.service
|
|
|
|
log "World reset complete - new world will generate on first connection"
|