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
This commit is contained in:
yuvipanda
2018-07-31 13:16:57 -07:00
parent 573956eb38
commit a6373200ec

View File

@@ -275,6 +275,22 @@ def ensure_jupyterhub_running(times=4):
raise Exception("Installation failed: JupyterHub did not start in {}s".format(times)) 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(): def main():
argparser = argparse.ArgumentParser() argparser = argparse.ArgumentParser()
argparser.add_argument( argparser.add_argument(
@@ -302,6 +318,7 @@ def main():
ensure_chp_package(HUB_ENV_PREFIX) ensure_chp_package(HUB_ENV_PREFIX)
ensure_jupyterhub_service(HUB_ENV_PREFIX) ensure_jupyterhub_service(HUB_ENV_PREFIX)
ensure_jupyterhub_running() ensure_jupyterhub_running()
ensure_symlinks(HUB_ENV_PREFIX)
logger.info("Done!") logger.info("Done!")