From 134e86bf63d940f8f40981eb093be23b183e0bb6 Mon Sep 17 00:00:00 2001 From: Lucas Briese Date: Fri, 2 Nov 2018 22:24:16 +0100 Subject: [PATCH] + server stops safely --- README.md | 3 +++ entrypoint.sh | 23 ++++++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 28fc946..05b163b 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,9 @@ docker run -d -p 27015:27015/tcp -p 27015:27015/udp -e WORKSHOP_COLLECTION_ID=12 tcp port for rcon, if you want to use it start with -usercon +rcon_password "yourPW" udp port for game traffic +## access console +docker exec -it CONTAINER ./home/steam/gmodserver console + ## environment variables If set every workshop item at the collection is added as forced, that means its automatically downloaded on connecting. Don't add collections with maps here just like weapons aso. WORKSHOP_COLLECTION_ID= diff --git a/entrypoint.sh b/entrypoint.sh index d2d688c..12712af 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -45,9 +45,22 @@ fi sed -i 's/! fn_prompt_yn "Continue?" Y/[ "1" != "1" ]/' "${STEAM_PATH}/lgsm/functions/command_console.sh" #start server +IS_RUNNING="true" +function stopServer { + echo "stopping server..." + cd "${STEAM_PATH}" + pkill -2 srcds_linux + pkill -2 srcds_run + echo "server stopped!" + echo "stopping entrypoint..." + IS_RUNNING="false" +} ./gmodserver start - -#trap & show console -trap 'pkill -15 srcds_run' SIGTERM -./gmodserver console -# If in background created and wait "$!" => terminal never started -> container exit right after +trap stopServer SIGTERM +echo "Server is running, waiting for SIGTERM" +while [ "$IS_RUNNING" = "true" ] +do + sleep 1s +done +echo "entrypoint stopped" +exit 0 \ No newline at end of file