diff --git a/files/auto/autopause-daemon.sh b/files/auto/autopause-daemon.sh index 8fe4a06a..3e30f18d 100644 --- a/files/auto/autopause-daemon.sh +++ b/files/auto/autopause-daemon.sh @@ -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 diff --git a/files/auto/autopause-fcns.sh b/files/auto/autopause-fcns.sh index 75411adb..7e5d1ea9 100644 --- a/files/auto/autopause-fcns.sh +++ b/files/auto/autopause-fcns.sh @@ -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 ' ' +}