From 0819e5f5a7e78741debab2e437dd22a2836f90e8 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 11 Mar 2025 09:04:31 +0100 Subject: [PATCH] Detect Network Interface --- misc/filebrowser.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/misc/filebrowser.sh b/misc/filebrowser.sh index 9c66b0b..f98cd4f 100644 --- a/misc/filebrowser.sh +++ b/misc/filebrowser.sh @@ -29,9 +29,13 @@ INSTALL_PATH="/usr/local/bin/filebrowser" DB_PATH="/usr/local/community-scripts/filebrowser.db" DEFAULT_PORT=8080 -# Get first non-loopback IP -IP=$(hostname -I | awk '{print $1}') -[[ -z "$IP" ]] && IP="127.0.0.1" # Fallback auf localhost, falls keine IP gefunden wird +# Get first non-loopback IP & Detect primary network interface dynamically +IFACE=$(ip -4 route | awk '/default/ {print $5; exit}') +IP=$(ip -4 addr show "$IFACE" | awk '/inet / {print $2}' | cut -d/ -f1 | head -n 1) + +[[ -z "$IP" ]] && IP=$(hostname -I | awk '{print $1}') +[[ -z "$IP" ]] && IP="127.0.0.1" + # Detect OS if [[ -f "/etc/alpine-release" ]]; then