-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·56 lines (51 loc) · 1.41 KB
/
entrypoint.sh
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
#!/bin/bash
# hook to handle graceful shutdown (saveworld)
if [ -x /home/lgsm/container_stop.sh ]; then
trap /home/lgsm/container_stop.sh INT QUIT TERM KILL
fi
if [ -z "$SERVERNAME" ]; then
# execute command given
"$@"
else
# run the server (update if needed)
if [ ! -x "$HOME/$SERVERNAME" ]; then
linuxgsm.sh $SERVERNAME
fi
if [ -n "$UPDATE_LGSM" -o ! -d "$HOME/lgsm/functions" ]; then
$SERVERNAME update-lgsm
fi
if [ ! -d "$HOME/serverfiles/steamapps" ]; then
$SERVERNAME auto-install
CONTAINER_INIT="yes"
fi
# hook for initial start
if [ -n "$CONTAINER_INIT" ]; then
container_init.sh
fi
if [ -n "$UPDATE_SERVER" ]; then
$SERVERNAME update
fi
if [ -n "$FORCE_VALIDATE" ]; then
$SERVERNAME validate
fi
# hook for mods
if [ -n "$UPDATE_MODS" ]; then
update_mods.sh
fi
# hook for every start
if [ -n "$CONTAINER_WARMUP" ]; then
container_warmup.sh
fi
# run the command
$SERVERNAME $@
# keep this process running
if [ "x$1" = "xstart" ]; then
# wait for logs to be created, then tail them (show whats happening in docker logs)
echo "--> Tailing logs and waiting for tmux session to quit..."
sleep 10
tail -F $(find -L log -mtime -0.01 -type f) &
# wait for tmux to quit - do this in this shell for trap to take effect
tmux_pid=$(tmux display-message -pF "#{pid}")
while (ps $tmux_pid >/dev/null); do sleep 2; done
fi
fi