-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathglctl.sh
More file actions
executable file
·80 lines (62 loc) · 1.26 KB
/
glctl.sh
File metadata and controls
executable file
·80 lines (62 loc) · 1.26 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env bash
set -euo pipefail
SERVICE=gravitlauncher
WORKDIR=/app
DATADIR=/app/data
SOCKET=control-file
info() { echo "[INFO] $*"; }
err() {
echo "[ERROR] $*" >&2
exit 1
}
send_control() {
local cmd="$1"
echo "$cmd" | docker compose exec -T -w "$WORKDIR" "$SERVICE" socat UNIX-CONNECT:"$SOCKET" -
}
CMD=${1:-help}
shift || true
case "$CMD" in
start)
docker compose up -d
;;
stop)
docker compose stop
;;
restart)
docker compose restart
;;
logs)
docker compose logs -f "$SERVICE"
;;
attach)
docker compose attach "$SERVICE"
;;
ps)
docker compose ps
;;
stats)
docker compose stats
;;
shell)
docker compose exec -it -w "$WORKDIR" "$SERVICE" /bin/bash
;;
control)
[[ $# -gt 0 ]] || err "Usage: glctl.sh control <command>"
send_control "$*"
;;
load-module)
[[ $# -eq 1 ]] || err "Usage: glctl.sh load-module MODULE_NAME"
send_control "modules load $1"
;;
edit-config)
docker compose exec -it "$SERVICE" sh -c "${EDITOR:-nano} $DATADIR/LaunchServerConfig.json"
;;
cp-to)
[[ $# -eq 2 ]] || err "Usage: glctl.sh cp-to SRC DST_IN_CONTAINER"
docker cp "$1" "$(docker compose ps -q $SERVICE):$2"
;;
cp-from)
[[ $# -eq 2 ]] || err "Usage: glctl.sh cp-from SRC_IN_CONTAINER DST"
docker cp "$(docker compose ps -q $SERVICE):$1" "$2"
;;
esac