mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-03-28 03:29:25 +01:00
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.
This commit is contained in:
parent
8114c7c252
commit
0b4c35dc4c
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user