I’m trying to figure out if its possible to have jupyter server source a script when it is launched for a user similar to have everything in /etc/profile.d is sourced when a shell instance is initiated?
If this isn’t possible, is it possible to have Jupyterhub open a terminal as soon as its launched as sort of a default startup behavior?
The JupyterHub config file is actually a Python program; hence, if it’s something you can do with Python, like run a script, then you can do it from within the JupyterHub config file. I think the JupyterLab config file may work the same way.
There are also some hooks that can be configured in the config file that might be helpful.
Definitely possible. JupyterHub’s Spawner.cmd only requires that it eventually launches jupyterhub-singleuser (or one of a few equivalents like jupyter-labhub).
The standard way to do this, and one that I think gives a nice experience, is to create a launcher script like:
#!/bin/bash -l
# set any additional environment variables / do other startup
# finally, 'become' jupyterhub-singleuser
exec jupyterhub-singleuser "$@"
The bash -l starts a login shell, so it should be fully configured with profile, etc.
Then you set c.Spawner.cmd = "/path/to/that/script.sh" in your config, instead of the default jupyterhub-singleuser.
@minrk This worked very well! We are able to generate variables in the login shell and dereference them in the .Renviron config. However, we are using jupyter-rsession-proxy to also use Rstudio within jupyterhub and Rstudio is not able to pick up on the variables generated during login. Any ideas for how we could achieve this?