-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
48 lines (41 loc) · 1.16 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
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
readonly SERVER_EXECUTABLE="vhserver"
readonly SERVER_GAME="vhserver"
if [ -n "$SERVER_EXECUTABLE" ] && [ -e "${STEAM_PATH}/$SERVER_EXECUTABLE" ]; then
echo "[entrypoint.sh]updating..."
./"$SERVER_EXECUTABLE" update-lgsm
./"$SERVER_EXECUTABLE" update
else
echo "[entrypoint.sh]installing..."
bash linuxgsm.sh "$SERVER_GAME"
./"$SERVER_EXECUTABLE" auto-install
fi
# server is installed
# apply custom configuration
mkdir -p "$STEAM_PATH/lgsm/config-lgsm/vhserver" || true
echo "servername=\"$SERVER_NAME\"" > "$STEAM_PATH/lgsm/config-lgsm/vhserver/vhserver.cfg"
echo "serverpassword=\"$SERVER_PASSWORD\"" >> "$STEAM_PATH/lgsm/config-lgsm/vhserver/vhserver.cfg"
IS_RUNNING="true"
function stopServer() {
echo "stopping server..."
cd "${STEAM_PATH}"
pid=$(pidof "$SERVER_EXECUTABLE")
kill -2 "$pid" || true
echo "server stopped!"
echo "stopping entrypoint..."
IS_RUNNING="false"
echo "done!"
}
./"$SERVER_EXECUTABLE" start &
trap stopServer SIGTERM
# --- Wait for Shutdown ---
echo "Server is running, waiting for SIGTERM"
while [ "$IS_RUNNING" = "true" ]
do
sleep 1s
done
echo "entrypoint stopped"
exit 0