docker-minecraft-server/files/autopause/pause.sh
ErstBlack ffb50cfe28
Fixing AUTOPAUSE on Raspberry Pi 4s (#708)
* Replacing killall with pkill and ps -a to ps -ax

* Adding net-tools and removing -q from pkill

* Missed the resume.sh

* Christ there's a lot of ps calls

* Adding -x to health.sh, replacing killall with pkill in sudoers-mv, and replacing su-exec with gosu in knockd-config.cfg

Co-authored-by: sean.sullivan.ctr@progeny.net <sean.sullivan.ctr@progeny.net>
2020-12-31 13:15:44 -06:00

21 lines
467 B
Bash
Executable file

#!/bin/bash
. /start-utils
if [[ $( ps -ax -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
logAutopauseAction "Pausing Java process"
pkill -STOP java
fi