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>
This commit is contained in:
ErstBlack 2020-12-31 14:15:44 -05:00 committed by GitHub
parent 51e6d5dfbd
commit ffb50cfe28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 13 additions and 12 deletions

View file

@ -9,6 +9,7 @@ RUN apt-get update \
imagemagick \
gosu \
sudo \
net-tools \
curl wget \
jq \
dos2unix \

View file

@ -8,7 +8,7 @@ sudo /usr/sbin/knockd -c /tmp/knockd-config.cfg -d
if [ $? -ne 0 ] ; then
while :
do
if [[ -n $(ps -o comm | grep java) ]] ; then
if [[ -n $(ps -ax -o comm | grep java) ]] ; then
break
fi
sleep 0.1
@ -17,7 +17,7 @@ if [ $? -ne 0 ] ; then
logAutopause "Possible cause: docker's host network mode."
logAutopause "Recreate without host mode or disable autopause functionality."
logAutopause "Stopping server."
killall -SIGTERM java
pkill -SIGTERM java
exit 1
fi

View file

@ -5,11 +5,11 @@ current_uptime() {
}
java_running() {
[[ $( ps -a -o stat,comm | grep 'java' | awk '{ print $1 }') =~ ^S.*$ ]]
[[ $( ps -ax -o stat,comm | grep 'java' | awk '{ print $1 }') =~ ^S.*$ ]]
}
rcon_client_exists() {
[[ -n "$(ps -a -o comm | grep 'rcon-cli')" ]]
[[ -n "$(ps -ax -o comm | grep 'rcon-cli')" ]]
}
mc_server_listening() {

View file

@ -3,10 +3,10 @@
[unpauseMCServer-server]
sequence = 25565
seq_timeout = 1
command = /sbin/su-exec minecraft:minecraft /autopause/resume.sh
command = /usr/sbin/gosu minecraft:minecraft /autopause/resume.sh
tcpflags = syn
[unpauseMCServer-rcon]
sequence = 25575
seq_timeout = 1
command = /sbin/su-exec minecraft:minecraft /autopause/resume.sh
command = /usr/sbin/gosu minecraft:minecraft /autopause/resume.sh
tcpflags = syn

View file

@ -2,7 +2,7 @@
. /start-utils
if [[ $( ps -a -o stat,comm | grep 'java' | awk '{ print $1 }') =~ ^S.*$ ]] ; then
if [[ $( ps -ax -o stat,comm | grep 'java' | awk '{ print $1 }') =~ ^S.*$ ]] ; then
# save world
rcon-cli save-all >/dev/null
@ -17,5 +17,5 @@ if [[ $( ps -a -o stat,comm | grep 'java' | awk '{ print $1 }') =~ ^S.*$ ]] ; th
# finally pause the process
logAutopauseAction "Pausing Java process"
killall -q -STOP java
pkill -STOP java
fi

View file

@ -2,7 +2,7 @@
. /start-utils
if [[ $( ps -a -o stat,comm | grep 'java' | awk '{ print $1 }') =~ ^T.*$ ]] ; then
if [[ $( ps -ax -o stat,comm | grep 'java' | awk '{ print $1 }') =~ ^T.*$ ]] ; then
logAutopauseAction "Knocked, resuming Java process"
killall -q -CONT java
pkill -CONT java
fi

View file

@ -1,2 +1,2 @@
%minecraft ALL=(ALL) NOPASSWD:/usr/bin/killall
%minecraft ALL=(ALL) NOPASSWD:/usr/bin/pkill
%minecraft ALL=(ALL) NOPASSWD:/usr/sbin/knockd

View file

@ -5,7 +5,7 @@
if isTrue "${DISABLE_HEALTHCHECK}"; then
echo "Healthcheck disabled"
exit 0
elif isTrue "${ENABLE_AUTOPAUSE}" && [[ "$( ps -a -o stat,comm | grep 'java' | awk '{ print $1 }')" =~ ^T.*$ ]]; then
elif isTrue "${ENABLE_AUTOPAUSE}" && [[ "$( ps -ax -o stat,comm | grep 'java' | awk '{ print $1 }')" =~ ^T.*$ ]]; then
echo "Java process suspended by Autopause function"
exit 0
else