From 9a554a5992f8ecef08dd2819c33c8c1e5aee5f98 Mon Sep 17 00:00:00 2001 From: tchey290 Date: Mon, 28 Oct 2024 12:46:23 -0600 Subject: [PATCH] set override hostname even if already set will set the hostname to the override value even if it's already set --- hw_diag/utilities/network.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hw_diag/utilities/network.py b/hw_diag/utilities/network.py index fc215b93..2276c5f2 100644 --- a/hw_diag/utilities/network.py +++ b/hw_diag/utilities/network.py @@ -71,19 +71,17 @@ def setup_hostname(): # We don't use boolean here because the field in the DB is a string as we have # some general key value pair table with string values. Sorry bros :-( - if hostname_set_row.value == "false": - logging.info("Hostname not set yet...") + if hostname_set_row.value == "false" or HOSTNAME_OVERRIDE: + logging.info("Hostname not set yet or override enabled...") # Set hostname via Balena supervisor... - default_password = generate_default_password() - hostname_suffix = default_password[6:] - if HOSTNAME_OVERRIDE != "false": hostname = HOSTNAME_OVERRIDE logging.info("Using hostname override from env var!") else: + default_password = generate_default_password() + hostname_suffix = default_password[6:] hostname = "nebra-%s.local" % hostname_suffix logging.info("No hostname override, using default!") - balena_supervisor = BalenaSupervisor.new_from_env() balena_supervisor.set_hostname(hostname) hostname_set_row.value = "true"