You can alternatively add the below piece of code in you 
jupyterhub_config.py file so it can add the new directory for each logged 
in user asynchronously .

*def create_dir_hook(spawner):*
 
*     spawned_user = spawner.user.name # get the spawned user*
*     volume_path = os.path.join('/home/jupyter-hubadmin', spawned_user)*
*    uid = pwd.getpwnam('jupyter').pw_uid*
*    spawner.port = random_port()*
*    if not os.path.exists(volume_path):*
*        # create a directory with umask 0755 *
*        # hub and container user must have the same UID to be writeable*
*        # still readable by other users on the system*
*        os.makedirs(volume_path, 0o755)*
*        #subprocess.Popen ("git init" , shell=True , 
cwd=volume_path).communicate()*
*        pass*
*    # the user folder should be owner by the user configured in the docker 
container*
*    # if not, the end user will be not able to create any notebook*
*    os.chown(volume_path, uid, uid)*


*# attach the hook function to the spawner*
*c.Spawner.pre_spawn_hook = create_dir_hook*



On Tuesday, April 28, 2020 at 3:45:03 PM UTC+5:30, Valdis S Coding wrote:
>
> How would one add a common set(folder) of notebooks to be used and  by all 
> new users upon first login?
>
> The idea is that there would be some shared folder containing notebooks 
> for the admin.  
>
>
> *Contents of this folder would be copied(not linked) upon creation of a 
> new user account.*
>
>
> Ideally there would two folders for all new users:
>
> One shared (with possibly some notebooks,datasets being write protected)
>
> This is possible:
>
> http://tljh.jupyter.org/en/latest/howto/content/share-data.html#add-a-link-to-the-shared-folder-in-the-user-home-directory
>
> My question is about 
> second folder which  would be notebooks which would be individual to the 
> user and they could modify at will.
>
> Currently the only way to get new users up to speed is to provide a 
> nbgitpuller link.
> http://tljh.jupyter.org/en/latest/howto/content/nbgitpuller.html
>
> This is not ideal when people are starting their new 
> accounts asynchronously.
>
>
> As a last resort, I am looking into writing a little script to just copy 
> something to individual users.
>
> That is automating something like this: sudo cp 
> /home/jupyter-hubadmin/MyNotebook.ipynb /home/jupyter-newuseraccount_foo
> The above works but seems very hacky..
>
> Any ideas on what to try ?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jupyter/3bb3f8ae-06cc-4fe6-ac00-1da0aab5c348o%40googlegroups.com.

Reply via email to