From 0b4c35dc4cbcbbdd08168dff8a5d991539bc9aa8 Mon Sep 17 00:00:00 2001 From: Ben Gauger Date: Thu, 12 Mar 2026 20:53:41 -0600 Subject: [PATCH] fix(install): handle hostname -I not supported on all distros Some distros ship a hostname that doesn't support -I (like Arch's coreutils version). Try it first and fall back to the ip command if it fails, rather than only checking if hostname exists. --- install/install_nomad.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/install/install_nomad.sh b/install/install_nomad.sh index f77bfa5..7b7c3ea 100644 --- a/install/install_nomad.sh +++ b/install/install_nomad.sh @@ -588,10 +588,9 @@ start_management_containers() { } get_local_ip() { - # Try hostname -I first, fall back to ip command for distros without hostname - if command -v hostname &> /dev/null; then - local_ip_address=$(hostname -I | awk '{print $1}') - else + # Try hostname -I first, fall back to ip command if it fails or isn't available + local_ip_address=$(hostname -I 2>/dev/null | awk '{print $1}') + if [[ -z "$local_ip_address" ]]; then local_ip_address=$(ip -4 -o addr show scope global | awk '{print $4}' | cut -d/ -f1 | head -1) fi if [[ -z "$local_ip_address" ]]; then