Auto create home dirs with Samba

If you’re using Samba to provide network shares to your users, it might be usefull to autmatically create the their homedir when they access it the first time. This can be done by adding this line to the [homes] directive :

root preexec = /usr/local/sbin/ %U

This is the script itself :


if [ ! -e /storage_users/DOMAIN/$1 ]; then
mkdir /storage_users/DOMAIN/$1
chown $1:"DOMAIN+Domain Admins" /storage_users/DOMAIN/$1
exit 0