mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2024-06-07 19:40:43 +00:00
20 lines
491 B
Bash
20 lines
491 B
Bash
|
#!/bin/bash
|
||
|
|
||
|
if [[ $( ps -a -o stat,comm | grep 'java' | awk '{ print $1 }') =~ ^S.*$ ]] ; then
|
||
|
# save world
|
||
|
rcon-cli save-all >/dev/null
|
||
|
|
||
|
# wait until mc-monitor is no longer connected to the server
|
||
|
while :
|
||
|
do
|
||
|
if [[ -z "$(netstat -nt | grep "127.0.0.1:$SERVER_PORT" | grep 'ESTABLISHED')" ]]; then
|
||
|
break
|
||
|
fi
|
||
|
sleep 0.1
|
||
|
done
|
||
|
|
||
|
# finally pause the process
|
||
|
echo "[$(date -Iseconds)] [Autopause] Pausing Java process" >/tmp/terminal-mc
|
||
|
killall -q -STOP java
|
||
|
fi
|