From 8324e49ed91b3e24e1c0985bb21fafae2faa19bd Mon Sep 17 00:00:00 2001 From: Simon Li Date: Thu, 16 Jun 2022 20:54:54 +0100 Subject: [PATCH] TLJH version can be specified on the command line --- bootstrap/bootstrap.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/bootstrap/bootstrap.py b/bootstrap/bootstrap.py index 07cd01c..e151289 100644 --- a/bootstrap/bootstrap.py +++ b/bootstrap/bootstrap.py @@ -38,6 +38,7 @@ Command line flags: passed, it will pass --progress-page-server-pid= to the tljh installer for later termination. """ +from argparse import ArgumentParser import os from http.server import SimpleHTTPRequestHandler, HTTPServer import multiprocessing @@ -252,8 +253,8 @@ class ProgressPageRequestHandler(SimpleHTTPRequestHandler): def main(): """ - This script intercepts the --show-progress-page flag, but all other flags - are passed through to the TLJH installer script. + This bootstrap script intercepts some command line flags, everything else is + passed through to the TLJH installer script. The --show-progress-page flag indicates that the bootstrap script should start a local webserver temporarily and report its installation progress via @@ -261,6 +262,13 @@ def main(): """ ensure_host_system_can_install_tljh() + parser = ArgumentParser() + parser.add_argument("--show-progress-page", action="store_true") + parser.add_argument( + "--version", default="main", help="TLJH version (Git reference)" + ) + args, tljh_installer_flags = parser.parse_known_args() + # Various related constants install_prefix = os.environ.get("TLJH_INSTALL_PREFIX", "/opt/tljh") hub_prefix = os.path.join(install_prefix, "hub") @@ -270,12 +278,7 @@ def main(): # Attempt to start a web server to serve a progress page reporting # installation progress. - tljh_installer_flags = sys.argv[1:] - if "--show-progress-page" in tljh_installer_flags: - # Remove the bootstrap specific flag and let all other flags pass - # through to the installer. - tljh_installer_flags.remove("--show-progress-page") - + if args.show_progress_page: # Write HTML and a favicon to be served by our webserver with open("/var/run/index.html", "w+") as f: f.write(progress_page_html) @@ -378,7 +381,9 @@ def main(): tljh_install_cmd.append( os.environ.get( "TLJH_BOOTSTRAP_PIP_SPEC", - "git+https://github.com/jupyterhub/the-littlest-jupyterhub.git", + "git+https://github.com/jupyterhub/the-littlest-jupyterhub.git@{version}".format( + version=args.version + ), ) ) if initial_setup: