-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin-console
More file actions
51 lines (46 loc) · 1.82 KB
/
admin-console
File metadata and controls
51 lines (46 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env bash
# Stream the game server admin console (container stdout or server-console.txt).
# Usage: ./admin-console [--file] [--tail N]
# Default: docker compose logs -f projectzomboid
# --file: tail -f server-data/server-console.txt (when on host with mounted server-data)
# --tail N: show last N lines before following (default 100 for docker, 50 for file)
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
USE_FILE=false
TAIL_LINES=100
while [[ $# -gt 0 ]]; do
case "$1" in
--file) USE_FILE=true; shift ;;
--tail) TAIL_LINES="$2"; shift 2 ;;
-h|--help)
echo "Usage: $(basename "$0") [--file] [--tail N]"
echo " Stream the game server admin console."
echo " Default: docker compose logs -f projectzomboid (last ${TAIL_LINES} lines)"
echo " --file: tail -f server-data/server-console.txt instead"
echo " --tail N: show last N lines before following"
exit 0
;;
*) echo "Unknown option: $1" >&2; exit 1 ;;
esac
done
if [[ "$USE_FILE" == true ]]; then
CONSOLE_FILE="server-data/server-console.txt"
if [[ ! -f "$CONSOLE_FILE" ]]; then
echo "Console file not found: $CONSOLE_FILE" >&2
exit 1
fi
echo "=== Admin console (file: $CONSOLE_FILE) ==="
echo "Press Ctrl+C to stop"
echo "-------------------------------------------"
exec tail -n "${TAIL_LINES}" -f "$CONSOLE_FILE"
else
if ! docker compose ps --status running --quiet projectzomboid 2>/dev/null | grep -q .; then
echo "Container 'projectzomboid' is not running. Use --file to tail server-console.txt instead." >&2
exit 1
fi
echo "=== Admin console (docker logs -f projectzomboid) ==="
echo "Press Ctrl+C to stop"
echo "-----------------------------------------------------"
exec docker compose logs -f --tail "${TAIL_LINES}" projectzomboid
fi