mirror of
https://github.com/itzg/docker-minecraft-server
synced 2024-12-12 13:22:28 +00:00
fix multiarch autopause daemon (#722)
This commit is contained in:
parent
02c8393bc6
commit
b519c43e16
2 changed files with 28 additions and 10 deletions
|
@ -15,17 +15,35 @@ autopause_error_loop() {
|
|||
logAutopause "Autopause failed to initialize. This log entry will be printed every 30 minutes."
|
||||
while :
|
||||
do
|
||||
if [[ -n $(ps -ax -o comm | grep java) ]] ; then
|
||||
break
|
||||
fi
|
||||
sleep 0.1
|
||||
sleep 1800
|
||||
logAutopause "Autopause failed to initialize."
|
||||
done
|
||||
}
|
||||
|
||||
# wait for java process to be started
|
||||
while :
|
||||
do
|
||||
if java_process_exists ; then
|
||||
break
|
||||
fi
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
# check for interface existence
|
||||
if [[ -z "$AUTOPAUSE_KNOCK_INTERFACE" ]] ; then
|
||||
logAutopause "AUTOPAUSE_KNOCK_INTERFACE variable must not be empty!"
|
||||
autopause_error_loop
|
||||
fi
|
||||
if ! [[ -d "/sys/class/net/$AUTOPAUSE_KNOCK_INTERFACE" ]] ; then
|
||||
logAutopause "Selected interface \"$AUTOPAUSE_KNOCK_INTERFACE\" does not exist!"
|
||||
autopause_error_loop
|
||||
fi
|
||||
|
||||
sudo /usr/sbin/knockd -c /tmp/knockd-config.cfg -d -i "$AUTOPAUSE_KNOCK_INTERFACE"
|
||||
if [ $? -ne 0 ] ; then
|
||||
logAutopause "Failed to start knockd daemon."
|
||||
logAutopause "Possible cause: docker's host network mode."
|
||||
logAutopause "Recreate without host mode or disable autopause functionality."
|
||||
logAutopause "Stopping server."
|
||||
pkill -SIGTERM java
|
||||
exit 1
|
||||
logAutopause "Probable cause: Unable to attach to interface \"$AUTOPAUSE_KNOCK_INTERFACE\"."
|
||||
autopause_error_loop
|
||||
fi
|
||||
|
||||
STATE=INIT
|
||||
|
|
|
@ -9,7 +9,7 @@ java_running() {
|
|||
}
|
||||
|
||||
java_process_exists() {
|
||||
[[ -n "$(ps -a -o comm | grep 'java')" ]]
|
||||
[[ -n "$(ps -ax -o comm | grep 'java')" ]]
|
||||
}
|
||||
|
||||
rcon_client_exists() {
|
||||
|
|
Loading…
Reference in a new issue