Skip to content

Commit

Permalink
Allow hostname override
Browse files Browse the repository at this point in the history
Relates to #679
  • Loading branch information
shawaj authored Oct 16, 2024
1 parent 44facbe commit b2b2d4b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion hw_diag/utilities/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def setup_hostname():
# This runs before the Flask app is really fully running, so we do not have the
# global "g" object with the db session, so we must spawn our own.
db = get_db_session()
INITIAL_HOSTNAME_OVERRIDE = os.getenv('INITIAL_HOSTNAME_OVERRIDE', 'false')
HOSTNAME_SET_KEY = "hostname_set"
try:
try:
Expand All @@ -74,7 +75,12 @@ def setup_hostname():
# Set hostname via Balena supervisor...
default_password = generate_default_password()
hostname_suffix = default_password[6:]
hostname = "nebra-%s.local" % hostname_suffix

if INITIAL_HOSTNAME_OVERRIDE != "false":
hostname = INITIAL_HOSTNAME_OVERRIDE
else:
hostname = "nebra-%s.local" % hostname_suffix

balena_supervisor = BalenaSupervisor.new_from_env()
balena_supervisor.set_hostname(hostname)
hostname_set_row.value = "true"
Expand Down

0 comments on commit b2b2d4b

Please sign in to comment.