Upgrade/iRedMail/0.7.3-0.7.4

From iRedMail

(Difference between revisions)
Jump to: navigation, search
(Fix incorrect calculation of mailbox quota)
(Fix incorrect calculation of mailbox quota)
 
(5 intermediate revisions not shown)
Line 1: Line 1:
__TOC__
__TOC__
-
-------
 
-
'''WORKING IN PROGRESS, DO *NOT* APPLY IT.'''
 
-
-------
 
= General =
= General =
== Fix incorrect per-user sieve_dir setting in Dovecot ==
== Fix incorrect per-user sieve_dir setting in Dovecot ==
-
Note: This fix only works for Dovecot-1.x.
+
'''Note''': This fix is applicable to Dovecot-1.x, you can check Dovecot version with command "dovecot -n".
In /etc/dovecot.conf or /etc/dovecot/dovecot.conf, remove the last slash (/) in setting '''sieve_dir =''' like below:
In /etc/dovecot.conf or /etc/dovecot/dovecot.conf, remove the last slash (/) in setting '''sieve_dir =''' like below:
Line 34: Line 31:
== [Debian and Ubuntu special] Assign Apache daemon user to group "adm" ==
== [Debian and Ubuntu special] Assign Apache daemon user to group "adm" ==
-
Note: This fix is applicable to only Debian and Ubuntu.
+
'''Note''': This fix is applicable to only Debian and Ubuntu.
Assign Apache daemon user to group "adm" to avoid Awstats cron job issue.
Assign Apache daemon user to group "adm" to avoid Awstats cron job issue.
Line 46: Line 43:
There's a bug in iRedMail-0.7.3 and all earlier versions: Mailbox quota gets calculated per user and per user alias account, so both email addresses get their own mailbox quota usage. Here's the solution to fix it.
There's a bug in iRedMail-0.7.3 and all earlier versions: Mailbox quota gets calculated per user and per user alias account, so both email addresses get their own mailbox quota usage. Here's the solution to fix it.
-
* Open /etc/dovecot-ldap.conf (RHEL/CentOS/Scientific Linux) or /etc/dovecot/dovecot.conf (Debian/Ubuntu/openSUSE) or /usr/local/etc/dovecot-ldap.conf (FreeBSD), prepend '''mail=user,''' in both '''user_attrs =''' and '''pass_attrs =''' like below:
+
* Open /etc/dovecot-ldap.conf (RHEL/CentOS/Scientific Linux) or /etc/dovecot/dovecot-ldap.conf (Debian/Ubuntu/openSUSE) or /usr/local/etc/dovecot-ldap.conf (FreeBSD), prepend '''mail=user,''' in both '''user_attrs =''' and '''pass_attrs =''' like below:
{{cfg|dovecot-ldap.conf|<pre>
{{cfg|dovecot-ldap.conf|<pre>
# Original settings:
# Original settings:
Line 59: Line 56:
= MySQL backend special =
= MySQL backend special =
-
== Store mailbox quota in seperate SQL table ==
+
== Store realtime mailbox quota usage in seperate SQL table ==
-
In iRedMail-0.7.3 and some earlier versions, Dovecot stores mailbox quota in MySQL database in two columns: '''mailbox.bytes''', '''mailbox.messages''', if they have invalid values (e.g. empty value, non-integer value), Dovecot will update them with two SQL commands:
+
'''Summary''':
 +
 
 +
In iRedMail-0.7.3 and some earlier versions, Dovecot stores realtime mailbox quota usage in MySQL database in two columns: '''mailbox.bytes''', '''mailbox.messages''', if they have invalid values (e.g. empty value, non-integer value), Dovecot will update them with two SQL commands:
# First one: delete record. (DELETE FROM mailbox WHERE username='xxx@yyy.com')
# First one: delete record. (DELETE FROM mailbox WHERE username='xxx@yyy.com')
Line 67: Line 66:
First one will delete iRedMail mail user, that's the problem. User [http://www.iredmail.org/forum/topic2641-user-suddenly-gone-from-iredmail.html OviVan reports this issue] after migrated user mailboxes to iRedMail-0.7.3.
First one will delete iRedMail mail user, that's the problem. User [http://www.iredmail.org/forum/topic2641-user-suddenly-gone-from-iredmail.html OviVan reports this issue] after migrated user mailboxes to iRedMail-0.7.3.
-
So we have to store mailbox quota in a separate MySQL table to avoid similar issues.
+
So we have to store realtime mailbox quota usage in a separate MySQL table to avoid similar issues.
-
Below are steps to store mailbox quota in a separate SQL table:
+
'''Below are steps to store realtime mailbox quota usage in a separate SQL table:'''
* Create new SQL table '''vmail.used_quota''' to store mailbox quota:
* Create new SQL table '''vmail.used_quota''' to store mailbox quota:

Current revision as of 03:00, 9 January 2012

Contents


General

Fix incorrect per-user sieve_dir setting in Dovecot

Note: This fix is applicable to Dovecot-1.x, you can check Dovecot version with command "dovecot -n".

In /etc/dovecot.conf or /etc/dovecot/dovecot.conf, remove the last slash (/) in setting sieve_dir = like below:

File: dovecot.conf
# Original setting:
#sieve_dir = /var/vmail/sieve/%Ld/%Ln/

# Change to:
sieve_dir = /var/vmail/sieve/%Ld/%Ln              # <-- Remove the last slash.

Add INDEXes for Amavisd database

Terminal:
$ mysql -uroot -p
mysql> USE amavisd;
mysql> ALTER TABLE maddr ADD INDEX maddr_idx_email (email);
mysql> ALTER TABLE maddr ADD INDEX maddr_idx_domain (domain);
mysql> ALTER TABLE msgs ADD INDEX msgs_idx_content (content);
mysql> ALTER TABLE msgs ADD INDEX msgs_idx_content_time_num (content, time_num);
mysql> ALTER TABLE msgs ADD INDEX msgs_idx_mail_id (mail_id);
mysql> ALTER TABLE quarantine ADD INDEX quar_idx_mail_id (mail_id);

[Debian and Ubuntu special] Assign Apache daemon user to group "adm"

Note: This fix is applicable to only Debian and Ubuntu.

Assign Apache daemon user to group "adm" to avoid Awstats cron job issue.

Terminal:
# usermod -g adm www-data

OpenLDAP backend special

Fix incorrect calculation of mailbox quota

There's a bug in iRedMail-0.7.3 and all earlier versions: Mailbox quota gets calculated per user and per user alias account, so both email addresses get their own mailbox quota usage. Here's the solution to fix it.

  • Open /etc/dovecot-ldap.conf (RHEL/CentOS/Scientific Linux) or /etc/dovecot/dovecot-ldap.conf (Debian/Ubuntu/openSUSE) or /usr/local/etc/dovecot-ldap.conf (FreeBSD), prepend mail=user, in both user_attrs = and pass_attrs = like below:
File: dovecot-ldap.conf
# Original settings:
#pass_attrs = userPassword=password
#user_attrs = homeDirectory=home,[...OMIT OTHER SETTINGS HERE...]

# Changed:
pass_attrs = mail=user,userPassword=password
user_attrs = mail=user,homeDirectory=home,[...OMIT OTHER SETTINGS HERE...]

MySQL backend special

Store realtime mailbox quota usage in seperate SQL table

Summary:

In iRedMail-0.7.3 and some earlier versions, Dovecot stores realtime mailbox quota usage in MySQL database in two columns: mailbox.bytes, mailbox.messages, if they have invalid values (e.g. empty value, non-integer value), Dovecot will update them with two SQL commands:

  1. First one: delete record. (DELETE FROM mailbox WHERE username='xxx@yyy.com')
  2. Second: create a new record with current, correct quota info. (INSERT INTO mailbox (username, bytes, messages) VALUES ('xxx@yyy.com', xx, xx))

First one will delete iRedMail mail user, that's the problem. User OviVan reports this issue after migrated user mailboxes to iRedMail-0.7.3.

So we have to store realtime mailbox quota usage in a separate MySQL table to avoid similar issues.

Below are steps to store realtime mailbox quota usage in a separate SQL table:

  • Create new SQL table vmail.used_quota to store mailbox quota:
Terminal:
# mysql -uroot -p
mysql> USE vmail;
mysql> CREATE TABLE IF NOT EXISTS `used_quota` (
    `username` VARCHAR(255) NOT NULL,
    `bytes` BIGINT NOT NULL DEFAULT 0,
    `messages` BIGINT NOT NULL DEFAULT 0,
    PRIMARY KEY (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  • Replace table = mailbox with table = used_quota in below config file, so that Dovecot will store mailbox quota in new SQL table.
    • On RHEL/CentOS/Scientific Linux 5.x, please update /etc/dovecot-used-quota.conf, on 6.x, please update /etc/dovecot/used-quota.conf.
    • On Debian/Ubuntu, please update /etc/dovecot/dovecot-used-quota.conf.
    • On openSUSE, please update /etc/dovecot/dovecot-used-quota.conf.
    • On FreeBSD, please update /usr/local/etc/dovecot-used-quota.conf.
  • Restarting Dovecot service is required.
Personal tools