TLJH version can be specified on the command line

This commit is contained in:
Simon Li
2022-06-16 20:54:54 +01:00
parent 121b4c7d8d
commit 8324e49ed9

View File

@@ -38,6 +38,7 @@ Command line flags:
passed, it will pass --progress-page-server-pid=<pid> passed, it will pass --progress-page-server-pid=<pid>
to the tljh installer for later termination. to the tljh installer for later termination.
""" """
from argparse import ArgumentParser
import os import os
from http.server import SimpleHTTPRequestHandler, HTTPServer from http.server import SimpleHTTPRequestHandler, HTTPServer
import multiprocessing import multiprocessing
@@ -252,8 +253,8 @@ class ProgressPageRequestHandler(SimpleHTTPRequestHandler):
def main(): def main():
""" """
This script intercepts the --show-progress-page flag, but all other flags This bootstrap script intercepts some command line flags, everything else is
are passed through to the TLJH installer script. passed through to the TLJH installer script.
The --show-progress-page flag indicates that the bootstrap script should The --show-progress-page flag indicates that the bootstrap script should
start a local webserver temporarily and report its installation progress via start a local webserver temporarily and report its installation progress via
@@ -261,6 +262,13 @@ def main():
""" """
ensure_host_system_can_install_tljh() 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 # Various related constants
install_prefix = os.environ.get("TLJH_INSTALL_PREFIX", "/opt/tljh") install_prefix = os.environ.get("TLJH_INSTALL_PREFIX", "/opt/tljh")
hub_prefix = os.path.join(install_prefix, "hub") 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 # Attempt to start a web server to serve a progress page reporting
# installation progress. # installation progress.
tljh_installer_flags = sys.argv[1:] if args.show_progress_page:
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")
# Write HTML and a favicon to be served by our webserver # Write HTML and a favicon to be served by our webserver
with open("/var/run/index.html", "w+") as f: with open("/var/run/index.html", "w+") as f:
f.write(progress_page_html) f.write(progress_page_html)
@@ -378,7 +381,9 @@ def main():
tljh_install_cmd.append( tljh_install_cmd.append(
os.environ.get( os.environ.get(
"TLJH_BOOTSTRAP_PIP_SPEC", "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: if initial_setup: