From c486b7b0354ab971fd84c039f615cbe513d9d1a5 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 19 Aug 2025 13:18:21 +0200 Subject: [PATCH] Update glances.sh --- tools/addon/glances.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tools/addon/glances.sh b/tools/addon/glances.sh index bd735e34..0f1b76f1 100644 --- a/tools/addon/glances.sh +++ b/tools/addon/glances.sh @@ -17,8 +17,6 @@ EOF } APP="Glances" -IP=$(hostname -I | awk '{print $1}') -hostname="$(hostname)" YW=$(echo "\033[33m") GN=$(echo "\033[1;92m") RD=$(echo "\033[01;31m") @@ -32,6 +30,17 @@ function msg_info() { echo -e "${INFO} ${YW}$1...${CL}"; } function msg_ok() { echo -e "${CM} ${GN}$1${CL}"; } function msg_error() { echo -e "${CROSS} ${RD}$1${CL}"; } +get_local_ip() { + if command -v hostname >/dev/null 2>&1 && hostname -I 2>/dev/null; then + hostname -I | awk '{print $1}' + elif command -v ip >/dev/null 2>&1; then + ip -4 addr show scope global | awk '/inet / {print $2}' | cut -d/ -f1 | head -n1 + else + echo "127.0.0.1" + fi +} +IP=$(get_local_ip) + install_glances_debian() { msg_info "Installing dependencies" apt-get update >/dev/null 2>&1 @@ -103,7 +112,9 @@ uninstall_glances_debian() { install_glances_alpine() { msg_info "Installing dependencies" apk update >/dev/null 2>&1 - apk add --no-cache gcc musl-dev python3 py3-pip py3-virtualenv lm-sensors wireless-tools >/dev/null 2>&1 + $STD apk add --no-cache \ + gcc musl-dev linux-headers python3-dev \ + python3 py3-pip py3-virtualenv lm-sensors wireless-tools >/dev/null 2>&1 msg_ok "Installed dependencies" msg_info "Setting up Python + uv"