-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option to create user home if it is not present on login? #38
Comments
This might be more appropriately a job for the authenticator instead of the spawner. Maybe both, though. |
This already works (also with systemdspawner) as described here: https://github.com/jupyterhub/jupyterhub/tree/master/examples/bootstrap-script In short: add |
@JanBobolz Would you possibly have a working example? Im running into issues with home directories not getting created (using SSSD Auth wit hPAM) |
Our example is pretty much the same as in the link provided: jupyterhub_config.py:
init_user.sh:
sudoers file:
where jhubrunner is the linux user running jupyterhub. If jhubrunner is not supposed to have sudo access for other stuff, make sure to make the init_user.sh non-writable to jhubrunner. DebuggingIf anything goes wrong, you should see something helpful in the journal ( DisclaimerThere may also be a solution where you don't have to run the init_user.sh script as sudo, it's just that we have a bunch of other stuff we're doing in that script (that I've cut out for this example) that needs sudo. |
Thanks for this, this helps a lot.
Brian
Our example is pretty much the same as in the link provided:
jupyterhub_config.py:
#see https://github.com/jupyterhub/jupyterhub/tree/master/examples/bootstrap-script for reference
from subprocess import check_call
import os
def init_user(spawner):
username = spawner.user.name.strip().lower() # get the username
script = "/home/jhubrunner/init_user.sh"
check_call(["sudo", script, username])
# attach the hook function to the spawner
c.Spawner.pre_spawn_hook = init_user #called before any singleuser instance is instantiated (will run repeatedly)
init_user.sh:
#!/bin/bash
USER=$1
if [ "$USER" == "" ]; then
exit 1
fi
# ----------------------------------------------------------------------------
echo "initializing $USER ..."
# User Directory: That's the private directory for the user to be created, if none exists
USER_DIRECTORY=/home/$USER
if [ -d "$USER_DIRECTORY/jupyter-notebooks" ]; then
echo "...directory for user already exists. done."
exit 0 # all good. nothing to do.
else
echo "...creating home dir"
install -d -m 0700 -o $USER $USER_DIRECTORY $USER_DIRECTORY/jupyter-notebooks
fi
exit 0
sudoers file:
jhubrunner ALL=(ALL:ALL) NOPASSWD:/home/jhubrunner/init_user.sh
where jhubrunner is the linux user running jupyterhub. If jhubrunner is not supposed to have sudo access for other stuff, make sure to make the init_user.sh non-writable to jhubrunner.
Debugging
If anything goes wrong, you should see something helpful in the journal (sudo journalctl -r should show some sort of error towards the top if there's a problem running the script)
Disclaimer
There may also be a solution where you don't have to run the init_user.sh script as sudo, it's just that we have a bunch of other stuff we're doing in that script (that I've cut out for this example) that needs sudo.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<#38 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AFII5HHFLEAYT5TTZ7N3SJLRZ3WFFANCNFSM4FTECHAQ>.
|
There are some cases when a user can login, have a user home directory path, but the directory itself is not present in the system. This is very common if the system is set up to use centralized auth (i.e. kerberos). Is it possible for systemdspawner to create the user home directory on login, so we don't need an admin to provision every new user manually?
The text was updated successfully, but these errors were encountered: