mirror of
https://github.com/itzg/docker-minecraft-server
synced 2025-03-04 07:07:12 +00:00
autopause: improve network interface lookup (#1949)
This commit is contained in:
parent
1c670815d2
commit
b400dfbb74
2 changed files with 9 additions and 5 deletions
|
@ -10,9 +10,7 @@ fi
|
|||
|
||||
autopause_error_loop() {
|
||||
logAutopause "Available interfaces within the docker container:"
|
||||
INTERFACES=$(echo /sys/class/net/*)
|
||||
INTERFACES=${INTERFACES//\/sys\/class\/net\//}
|
||||
logAutopause " $INTERFACES"
|
||||
logAutopause " $(available_interfaces)"
|
||||
logAutopause "Please set the environment variable AUTOPAUSE_KNOCK_INTERFACE to the interface that handles incoming connections."
|
||||
logAutopause "If unsure which interface to choose, run the ifconfig command in the container."
|
||||
logAutopause "Autopause failed to initialize. This log entry will be printed every 30 minutes."
|
||||
|
@ -37,7 +35,7 @@ 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
|
||||
if ! available_interfaces | grep -q "$AUTOPAUSE_KNOCK_INTERFACE" ; then
|
||||
logAutopause "Selected interface \"$AUTOPAUSE_KNOCK_INTERFACE\" does not exist!"
|
||||
autopause_error_loop
|
||||
fi
|
||||
|
|
|
@ -23,7 +23,9 @@ mc_server_listening() {
|
|||
java_clients_connections() {
|
||||
local connections
|
||||
if java_running ; then
|
||||
connections=$(mc-monitor status --host localhost --port "$SERVER_PORT" --show-player-count)
|
||||
if ! connections=$(mc-monitor status --host localhost --port "$SERVER_PORT" --show-player-count); then
|
||||
connections=0
|
||||
fi
|
||||
else
|
||||
connections=0
|
||||
fi
|
||||
|
@ -33,3 +35,7 @@ java_clients_connections() {
|
|||
java_clients_connected() {
|
||||
(( $(java_clients_connections) > 0 ))
|
||||
}
|
||||
|
||||
available_interfaces() {
|
||||
ifconfig -s | tail +2 | cut -f1 -d ' '
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue