Skip to content

Commit

Permalink
Merge pull request #1 from tchey290/patch-2
Browse files Browse the repository at this point in the history
set override hostname even if already set
  • Loading branch information
tchey290 authored Oct 28, 2024
2 parents f404541 + 9a554a5 commit fc3eff1
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions hw_diag/utilities/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit fc3eff1

Please sign in to comment.