mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-04-02 14:59:26 +02: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() {
|
get_local_ip() {
|
||||||
# Try hostname -I first, fall back to ip command for distros without hostname
|
# Try hostname -I first, fall back to ip command if it fails or isn't available
|
||||||
if command -v hostname &> /dev/null; then
|
local_ip_address=$(hostname -I 2>/dev/null | awk '{print $1}')
|
||||||
local_ip_address=$(hostname -I | awk '{print $1}')
|
if [[ -z "$local_ip_address" ]]; then
|
||||||
else
|
|
||||||
local_ip_address=$(ip -4 -o addr show scope global | awk '{print $4}' | cut -d/ -f1 | head -1)
|
local_ip_address=$(ip -4 -o addr show scope global | awk '{print $4}' | cut -d/ -f1 | head -1)
|
||||||
fi
|
fi
|
||||||
if [[ -z "$local_ip_address" ]]; then
|
if [[ -z "$local_ip_address" ]]; then
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user