add cleanup function, server memory variable

This commit is contained in:
Bryson Steck 2025-08-10 12:15:03 -06:00
parent 9c87494776
commit 878c146203
Signed by: bryson
SSH key fingerprint: SHA256:XpKABw/nP4z8UVaH+weLaBnEOD86+cVwif+QjuYLGT4
2 changed files with 13 additions and 7 deletions

View file

@ -1,14 +1,17 @@
#!/bin/sh
export TERM=xterm-256color
cd /spigot
cleanup() {
rcon -m -p 25575 --host localhost --password "${MC_RCON_PASSWORD}" say Warning! Server is shutting down in 5 seconds...
sleep 5
rcon -m -p 25575 --host localhost --password "${MC_RCON_PASSWORD}" stop
}
cd /server
envsubst < /spigot/server.properties.in > /server/server.properties
[ "$ACCEPT_EULA" = "true" ] && echo eula=true > /server/eula.txt
java -Xmx6G -jar /spigot/spigot-VERSION.jar nogui &
JAVA_PID=$!
trap "rcon -m -p 25575 --host localhost --password '${MC_RCON_PASSWORD}' stop" INT
java -Xmx${SERVER_MEMORY:-6G} -jar /spigot/spigot-VERSION.jar nogui &
trap "cleanup" INT
wait
wait
# wait twice in the event sigint (docker stop) is received
wait; wait

View file

@ -13,7 +13,10 @@ services:
ports:
- 25565:25565
environment:
# Entrypoint variables
- "ACCEPT_EULA=false"
- "SERVER_MEMORY=6G"
# server.properties Values
- "MC_ACCEPTS_TRANSFERS=false"
- "MC_ALLOW_FLIGHT=false"
- "MC_ALLOW_NETHER=true"