From f8a679b9c27f654e250d04cb4c63ca7080dc586d Mon Sep 17 00:00:00 2001 From: downtownallday Date: Mon, 23 Aug 2021 14:15:18 -0400 Subject: [PATCH] ensure system hostname is resolvable locally --- tests/lib/system.sh | 3 +++ tests/system-setup/setup-funcs.sh | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/lib/system.sh b/tests/lib/system.sh index 1b8cb147..10059f25 100644 --- a/tests/lib/system.sh +++ b/tests/lib/system.sh @@ -62,6 +62,9 @@ set_system_hostname() { local fqdn="${1:-$PRIMARY_HOSTNAME}" local host="$(awk -F. '{print $1}' <<< "$fqdn")" sed -i 's/^127\.0\.1\.1[ \t].*/127.0.1.1 '"$fqdn $host ip4-loopback/" /etc/hosts || return 1 + if ! /usr/bin/getent hosts "$fqdn" >/dev/null; then + return 2 + fi #hostname "$host" || return 1 #echo "$host" > /etc/hostname return 0 diff --git a/tests/system-setup/setup-funcs.sh b/tests/system-setup/setup-funcs.sh index 226c0f6a..28d35c90 100755 --- a/tests/system-setup/setup-funcs.sh +++ b/tests/system-setup/setup-funcs.sh @@ -69,7 +69,10 @@ dump_conf_files() { # init_test_system() { H2 "Update /etc/hosts" - set_system_hostname || die "Could not set hostname" + if ! set_system_hostname; then + dump_file "/etc/hosts" + die "Could not set hostname" + fi # update system time H2 "Set system time"