From a8bb9e64bbadcd963f67f54d96262d44723956a2 Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Wed, 26 Jun 2019 14:33:14 +1200 Subject: [PATCH] dockersetup: handle http/https port properly * Use the port number in the domain so that emails have working URLs * Don't include the port in the URL printed at the end of installation if it's the default Signed-off-by: Paul Eggleton --- dockersetup.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/dockersetup.py b/dockersetup.py index b96156a..55d3cb8 100755 --- a/dockersetup.py +++ b/dockersetup.py @@ -708,10 +708,23 @@ if return_code != 0: print("Collecting static files failed") sys.exit(1) +if https_port and not no_https: + protocol = 'https' + port = https_port + defport == '443' +else: + protocol = 'http' + port = http_port + defport = '80' +if port == defport: + host = hostname +else: + host = '%s:%s' % (hostname, port) + if not updatemode: if not dbfile: ## Set site name - return_code = subprocess.call(['docker-compose', 'run', '--rm', 'layersapp', '/opt/layerindex/layerindex/tools/site_name.py', hostname, 'OpenEmbedded Layer Index'], shell=False) + return_code = subprocess.call(['docker-compose', 'run', '--rm', 'layersapp', '/opt/layerindex/layerindex/tools/site_name.py', host, 'OpenEmbedded Layer Index'], shell=False) if not no_admin_user: ## For a fresh database, create an admin account @@ -729,11 +742,5 @@ else: print("") print("NOTE: you may need to use -p %s (or set COMPOSE_PROJECT_NAME=\"%s\" ) if running docker-compose directly in future" % (project_name, project_name)) print("") - if https_port and not no_https: - protocol = 'https' - port = https_port - else: - protocol = 'http' - port = http_port - print("The application should now be accessible at %s://%s:%s" % (protocol, hostname, port)) + print("The application should now be accessible at %s://%s" % (protocol, host)) print("")