diff --git a/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh b/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh index f9d684da..fdf4cf3e 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh @@ -1,7 +1,35 @@ -# Setup Postfix +# Setup Dovecot function ee_mod_setup_dovecot() { + ee_lib_echo "Configuring Dovecot, please wait..." + # Adding mail user with GID 5000 and UID 5000 groupadd -g 5000 vmail useradd -g vmail -u 5000 vmail -d /var/vmail -m + + # Configuring dovecot.conf + sed -i "s/*.protocol/*.protocol\\nprotocols = imap pop3 lmtp sieve/" /etc/dovecot/dovecot.conf + + # Configuring 10-mail.conf + sed -i "s/mail_location = mbox:~\/mail:INBOX=\/var\/mail\/%u/mail_location = maildir:\/var\/vmail\/%d\/%n/" /etc/dovecot/conf.d/10-mail.conf + + # Configuring 10-auth.conf + sed -i "s/auth_mechanisms = plain/auth_mechanisms = plain login/" /etc/dovecot/conf.d/10-auth.conf + sed -i "s/\!include auth-system.conf.ext/#\!include auth-system.conf.ext/" /etc/dovecot/conf.d/10-auth.conf + sed -i "s/#\!include auth-sql.conf.ext/\!include auth-sql.conf.ext/" /etc/dovecot/conf.d/10-auth.conf + + # Configuring dovecot-sql.conf.ext + cat /usr/share/easyengine/mail/dovecot-sql.conf.ext >> /etc/dovecot/dovecot-sql.conf.ext + + # Configuring auth-sql.conf.ext + sed -i "s/#userdb {/userdb {/" /etc/dovecot/conf.d/auth-sql.conf.ext + sed -i "s/# driver = prefetch/ driver = prefetch\n}/" /etc/dovecot/conf.d/auth-sql.conf.ext + + + # Configuring 10-master.conf + cp -av /etc/dovecot/conf.d/10-master.conf /etc/dovecot/conf.d/10-master.conf.bak + cp -av /usr/share/easyengine/mail/10-master.conf /etc/dovecot/conf.d/10-master.conf + + # Change Dovecot log location + sed -i "s/#log_path = syslog/log_path = \/var\/log\/dovecot.log/" /etc/dovecot/conf.d/10-logging.conf } diff --git a/src/modules/stack/install/mail/ee_mod_setup_postfix.sh b/src/modules/stack/install/mail/ee_mod_setup_postfix.sh index 107911aa..ef0e5091 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_postfix.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_postfix.sh @@ -2,6 +2,7 @@ function ee_mod_setup_postfix() { + ee_lib_echo "Configuring Postfix, please wait..." #Configure Master.cf sed -i 's/#submission/submission/' /etc/postfix/master.cf sed -i 's/#smtps/smtps/' /etc/postfix/master.cf @@ -32,4 +33,11 @@ function ee_mod_setup_postfix() postconf "virtual_mailbox_domains = mysql:/etc/postfix/mysql/virtual_domains_maps.cf" postconf "virtual_mailbox_maps = mysql:/etc/postfix/mysql/virtual_mailbox_maps.cf" #postconf "message_size_limit = 20971520" + + + # Setting up Postfix MySQL configuration + mkdir -p /etc/postfix/mysql + cp -av /usr/share/easyengine/mail/virtual_alias_maps.cf /etc/postfix/mysql/virtual_alias_maps.cf + cp -av /usr/share/easyengine/mail/virtual_domains_maps.cf /etc/postfix/mysql/virtual_domains_maps.cf + cp -av /usr/share/easyengine/mail/virtual_mailbox_maps.cf /etc/postfix/mysql/virtual_mailbox_maps.cf } diff --git a/templates/mail/10-master.conf b/templates/mail/10-master.conf new file mode 100644 index 00000000..1c46e384 --- /dev/null +++ b/templates/mail/10-master.conf @@ -0,0 +1,26 @@ +service lmtp { + unix_listener /var/spool/postfix/private/dovecot-lmtp { + mode = 0600 + user = postfix + group = postfix + } +} + +service auth { + unix_listener /var/spool/postfix/private/auth { + mode = 0666 + user = postfix + group = postfix + } + + unix_listener auth-userdb { + mode = 0600 + user = vmail + } + + user = dovecot +} + +service auth-worker { + user = vmail +} diff --git a/templates/mail/dovecot-sql.conf.ext b/templates/mail/dovecot-sql.conf.ext new file mode 100644 index 00000000..03d413fb --- /dev/null +++ b/templates/mail/dovecot-sql.conf.ext @@ -0,0 +1,15 @@ +driver = mysql + +connect = host=localhost user=vimbadmin password=password dbname=vimbadmin +default_pass_scheme = MD5 + +password_query = SELECT username as user, password as password, \ +homedir AS home, maildir AS mail, \ +concat('*:bytes=', quota) as quota_rule, uid, gid \ +FROM mailbox \ +WHERE username = '%Lu' AND active = '1' \ +AND ( access_restriction = 'ALL' OR LOCATE( access_restriction, '%Us' ) > 0 ) + +user_query = SELECT homedir AS home, maildir AS mail, \ +concat('*:bytes=', quota) as quota_rule, uid, gid \ +FROM mailbox WHERE username = '%u' diff --git a/templates/mail/virtual_alias_maps.cf b/templates/mail/virtual_alias_maps.cf index 92d179ef..2b312477 100644 --- a/templates/mail/virtual_alias_maps.cf +++ b/templates/mail/virtual_alias_maps.cf @@ -2,4 +2,4 @@ user = vimbadmin password = password hosts = 127.0.0.1 dbname = vimbadmin -query = SELECT goto FROM alias WHERE address = '%s' AND active = '1' \ No newline at end of file +query = SELECT goto FROM alias WHERE address = '%s' AND active = '1' diff --git a/templates/mail/virtual_domains_maps.cf b/templates/mail/virtual_domains_maps.cf index 0efd5e41..a7c11133 100644 --- a/templates/mail/virtual_domains_maps.cf +++ b/templates/mail/virtual_domains_maps.cf @@ -2,4 +2,4 @@ user = vimbadmin password = password hosts = 127.0.0.1 dbname = vimbadmin -query = SELECT domain FROM domain WHERE domain = '%s' AND backupmx = '0' AND active = '1' \ No newline at end of file +query = SELECT domain FROM domain WHERE domain = '%s' AND backupmx = '0' AND active = '1' diff --git a/templates/mail/virtual_mailbox_maps.cf b/templates/mail/virtual_mailbox_maps.cf index 623e1d67..e777f79d 100644 --- a/templates/mail/virtual_mailbox_maps.cf +++ b/templates/mail/virtual_mailbox_maps.cf @@ -4,4 +4,4 @@ hosts = 127.0.0.1 dbname = vimbadmin table = mailbox select_field = maildir -where_field = username \ No newline at end of file +where_field = username