Creating NFSv4 homedirs on request

On the client, in /etc/profile, put something like

# Request a home directory
if ! [ -e ${HOME} ] ; then
   touch /home/homedir-request/${USER}.req
   sleep 30
   ls ${HOME}
   sleep 30 #Is this too much?
   cd ${HOME}
fi
	  

On the server, run


    
sudo inoticoming --logfile /tmp/inoti.log --pid-file /var/run/inoticoming-homedirreq /lwphome/homedir-request --suffix .req --stderr-to-log /bin/sh /usr/local/sbin/create-lwp-homedir /lwphome/homedir-request1/{} \;
    

  

1

Note that the directory being watched must be repeated as the path to the request file being handled

... and have a script /usr/local/sbin/create-lwp-homedir (run as root) that creates the home directory.

[Note]Note

I 've created a package that will this, with and init script for the inoticoming instance and log rotation. You can request it by mail if your're interested.

[Note]Note

Maybe it is better to do this from a PAM module instead of from the .profile. But PAM runs with root permission, and root doesn't have access to the NFSv4 share (rootsquash is on). /etc/profile is sourced from bash, ssh and xsession and runs with user's id, so touching a file from here comes naturally. Of course, extra measures have to be taken to support csh, zsh and whatnot.