+ server stops safely
This commit is contained in:
		@@ -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=
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
		Reference in New Issue
	
	Block a user