fix multiarch autopause daemon (#722)

This commit is contained in:
Michael Kirsch 2021-01-12 23:05:12 +01:00 committed by GitHub
parent 02c8393bc6
commit b519c43e16
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 10 deletions

View file

@ -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

View file

@ -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() {