From a6373200ec974e5240d6ff08fae1deea3940666e Mon Sep 17 00:00:00 2001 From: yuvipanda Date: Tue, 31 Jul 2018 13:16:57 -0700 Subject: [PATCH] Symlink tljh-config to /usr/local/bin This lets `sudo -E` work when calling tljh-config. It currently does not, since we do not add the hub venv to PATH --- tljh/installer.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tljh/installer.py b/tljh/installer.py index a137fa6..c8a99c3 100644 --- a/tljh/installer.py +++ b/tljh/installer.py @@ -275,6 +275,22 @@ def ensure_jupyterhub_running(times=4): raise Exception("Installation failed: JupyterHub did not start in {}s".format(times)) +def ensure_symlinks(prefix): + """ + Ensure we symlink appropriate things into /usr/local/bin + + We add the user conda environment to PATH for notebook terminals, + but not the hub venv. This means tljh-config is not actually accessible. + + We symlink to /usr/local/bin to 'fix' this. /usr/local/bin is the appropriate + place, and works with sudo -E + """ + tljh_config_src = os.path.join(prefix, 'bin', 'tljh-config') + tljh_config_dest = '/usr/local/bin/tljh-config' + if not os.is_symlink(tljh_config_dest): + os.symlink(tljh_config_src, tljh_config_dest) + + def main(): argparser = argparse.ArgumentParser() argparser.add_argument( @@ -302,6 +318,7 @@ def main(): ensure_chp_package(HUB_ENV_PREFIX) ensure_jupyterhub_service(HUB_ENV_PREFIX) ensure_jupyterhub_running() + ensure_symlinks(HUB_ENV_PREFIX) logger.info("Done!")