#!/bin/sh # Daily clean restart (cron). Skipped while a human is playing (bots have address 'bot'), and also # skipped if the player count can't be read: better a missed restart than kicking someone. . "$(dirname "$0")/env.sh" LOG=logs/watchdog.log [ "$(docker inspect -f '{{.State.Status}}' "$NAME" 2>/dev/null)" = running ] || exit 0 H=$(python3 tools/qlq.py 127.0.0.1 "$QPORT" --humans 2>/dev/null) case "$H" in ''|*[!0-9]*) echo "$(date '+%F %T') daily restart skipped: player count unknown" >> $LOG; exit 0 ;; esac if [ "$H" -gt 0 ]; then echo "$(date '+%F %T') daily restart skipped: $H player(s) on" >> $LOG exit 0 fi echo "$(date '+%F %T') daily restart" >> $LOG [ -n "$DRYRUN" ] || docker restart "$NAME" >/dev/null 2>&1