2019-07-21 23:04:00 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
if [ "${DEBUGGING}" = "true" ]; then
|
|
|
|
set -o xtrace
|
|
|
|
fi
|
|
|
|
|
|
|
|
set -o errexit
|
2019-07-29 21:53:26 +02:00
|
|
|
set -o nounset
|
2019-07-21 23:04:00 +02:00
|
|
|
set -o pipefail
|
|
|
|
|
2019-10-15 12:38:54 +02:00
|
|
|
echo "[entrypoint.sh]starting entrypoint.sh"
|
2019-07-21 23:04:00 +02:00
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# --- Install / Update ---
|
|
|
|
cd "$STEAM_PATH"
|
|
|
|
if [ -n "$SERVER_EXECUTABLE" ] && [ -e "${STEAM_PATH}/$SERVER_EXECUTABLE" ]; then
|
2019-10-15 12:38:54 +02:00
|
|
|
echo "[entrypoint.sh]updating..."
|
2019-07-21 23:04:00 +02:00
|
|
|
./"$SERVER_EXECUTABLE" update-lgsm
|
|
|
|
./"$SERVER_EXECUTABLE" update
|
|
|
|
else
|
2019-10-15 12:38:54 +02:00
|
|
|
echo "[entrypoint.sh]installing..."
|
2019-07-21 23:04:00 +02:00
|
|
|
bash linuxgsm.sh "$SERVER_GAME"
|
|
|
|
./"$SERVER_EXECUTABLE" auto-install
|
|
|
|
fi
|
2019-10-15 12:38:54 +02:00
|
|
|
echo "[entrypoint.sh]update / installation done!"
|
2019-07-21 23:04:00 +02:00
|
|
|
|
|
|
|
if [ -e "/home/prepareServer.sh" ]; then
|
|
|
|
cd /home
|
2019-07-29 21:53:26 +02:00
|
|
|
./prepareServer.sh "$@"
|
2019-07-21 23:04:00 +02:00
|
|
|
cd "$STEAM_PATH"
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# --- Start Server ---
|
|
|
|
#start server
|
|
|
|
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"
|
2019-07-29 21:53:26 +02:00
|
|
|
echo "done!"
|
2019-07-21 23:04:00 +02:00
|
|
|
}
|
2019-07-29 21:53:26 +02:00
|
|
|
./"$SERVER_EXECUTABLE" start &
|
2019-07-21 23:04:00 +02:00
|
|
|
trap stopServer SIGTERM
|
|
|
|
|
|
|
|
#start cron
|
|
|
|
bash "/home/initCron.sh"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# --- Wait for Shutdown ---
|
|
|
|
echo "Server is running, waiting for SIGTERM"
|
|
|
|
while [ "$IS_RUNNING" = "true" ]
|
|
|
|
do
|
|
|
|
sleep 1s
|
|
|
|
done
|
|
|
|
echo "entrypoint stopped"
|
|
|
|
exit 0
|