Home Directory Creation

Asai asai at globalchangemusic.org
Sun Oct 6 03:44:38 EEST 2019


On 10/4/2019 10:31 PM, Aki Tuomi via dovecot wrote:
>>> As experiment, you could maybe use mail_lua plugin to create the 
>>> user directory on demand,
>>> make a lua script with
>>> function mail_user_created(user)
>>> -- create directory for user:home
>>> end
>>> See https://doc.dovecot.org/plugin-settings/mail-lua-plugin/ and 
>>> https://wiki.dovecot.org/Design/Lua
>>> Aki

Success.

Using the mail_lua plugin, and configuring the lua script location in 
the dovecot configs I used this script to create the home folder under 
the user's mail directory.  Hopefully this will help somebody else.

require 'lfs'

function mail_user_created(user)
         path = "/vmail"
         domain = user:var_expand("%d")
         username = user:var_expand("%n")

         lfs.mkdir(path .. domain )
         lfs.mkdir(path .. "/" .. domain .. "/" .. username )
         lfs.mkdir(path .. "/" .. domain .. "/" .. username .. "/home")
         lfs.mkdir(path .. "/" .. domain .. "/" .. username .. 
"/home/sieve")

         --file = io.open("/etc/dovecot/lualog.log", "w")
         --file:write(path .. "/" .. domain .. "/" .. username .. 
"/home/sieve",  "\n")

end




More information about the dovecot mailing list