diff --git a/tools/addon/jellystat.sh b/tools/addon/jellystat.sh index f45745ef3..55a70174a 100644 --- a/tools/addon/jellystat.sh +++ b/tools/addon/jellystat.sh @@ -8,6 +8,10 @@ source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/core.func) source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/tools.func) +# Enable error handling +set -Eeuo pipefail +trap 'error_handler' ERR + # ============================================================================== # CONFIGURATION # ============================================================================== @@ -17,6 +21,9 @@ INSTALL_PATH="/opt/jellystat" CONFIG_PATH="/opt/jellystat/.env" DEFAULT_PORT=3000 +# Initialize STD mode from core.func +set_std_mode + # ============================================================================== # HEADER # ============================================================================== @@ -33,30 +40,10 @@ EOF } # ============================================================================== -# COLORS & FORMATTING +# HELPER FUNCTIONS # ============================================================================== -YW=$(echo "\033[33m") -GN=$(echo "\033[1;92m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -CL=$(echo "\033[m") -CM="${GN}✔️${CL}" -CROSS="${RD}✖️${CL}" -INFO="${BL}ℹ️${CL}" -TAB=" " - -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}"; } -function msg_warn() { echo -e "⚠️ ${YW}${1}${CL}"; } - -function get_ip() { - local iface ip - iface=$(ip -4 route | awk '/default/ {print $5; exit}') - ip=$(ip -4 addr show "$iface" 2>/dev/null | awk '/inet / {print $2}' | cut -d/ -f1 | head -n1) - [[ -z "$ip" ]] && ip=$(hostname -I 2>/dev/null | awk '{print $1}') - [[ -z "$ip" ]] && ip="127.0.0.1" - echo "$ip" +get_ip() { + hostname -I 2>/dev/null | awk '{print $1}' || echo "127.0.0.1" } # ==============================================================================