Commits

Zhang Huangbin committed 1de8d83

Code cleanup.

Comments (0)

Files changed (8)

iRedMail/conf/mysql

 
 # MySQL database to store virtual hosts.
 export VMAIL_DB='vmail'
-export SAMPLE_SQL="${SAMPLE_DIR}/iredmail.sql"
+export MYSQL_VMAIL_STRUCTURE_SAMPLE="${SAMPLE_DIR}/iredmail.mysql"
 
 export BACKUP_DATABASES="${BACKUP_DATABASES} mysql"
 if [ X"${BACKEND}" == X"MYSQL" ]; then

iRedMail/conf/postgresql

 
 # Variables for PostgreSQL database server and related.
 
-export PGSQL_SYS_USER='postgre'
-export PGSQL_SYS_GROUP='postgre'
+export PGSQL_SYS_USER='postgres'
+export PGSQL_SYS_GROUP='postgres'
+export PGSQL_ROOT_USER='postgres'
 export PGSQL_INIT_SCRIPT="${DIR_RC_SCRIPTS}/postgresql"
+export PGSQL_VMAIL_STRUCTURE_SAMPLE="${SAMPLE_DIR}/iredmail.pgsql"
 
 if [ X"${DISTRO}" == X"UBUNTU" ]; then
     export PGSQL_SYS_USER='postgres'

iRedMail/dialog/mysql_config.sh

 # MySQL root password.
 while : ; do
     ${DIALOG} \
-    --title "Password for MySQL administrator: root" \
+    --title "Password for MySQL administrator: ${MYSQL_ROOT_USER}" \
     ${PASSWORDBOX} "\
-Please specify password for MySQL administrator: root
+Please specify password for MySQL administrator: ${MYSQL_ROOT_USER}
 
 WARNING:
 

iRedMail/dialog/pgsql_config.sh

 # Root password.
 while : ; do
     ${DIALOG} \
-    --title "Password for PostgreSQL administrator: root" \
+    --title "Password for PostgreSQL administrator: ${PGSQL_ROOT_USER}" \
     ${PASSWORDBOX} "\
-Please specify password for PostgreSQL administrator: root
+Please specify password for PostgreSQL administrator: ${PGSQL_ROOT_USER}
 
 WARNING:
 
     * EMPTY password is *NOT* permitted.
-" 20 76 2>/tmp/mysql_rootpw
+" 20 76 2>/tmp/pgsql_rootpw
 
-    PGSQL_ROOT_PASSWD="$(cat /tmp/mysql_rootpw)"
+    PGSQL_ROOT_PASSWD="$(cat /tmp/pgsql_rootpw)"
     [ X"${PGSQL_ROOT_PASSWD}" != X"" ] && break
 done
 
 echo "export PGSQL_ROOT_PASSWD='${PGSQL_ROOT_PASSWD}'" >>${CONFIG_FILE}
-rm -f /tmp/mysql_rootpw
+rm -f /tmp/pgsql_rootpw

iRedMail/functions/mysql.sh

 
     # Generate SQL.
     # Modify default SQL template, set storagebasedirectory.
-    perl -pi -e 's#(.*storagebasedirectory.*DEFAULT).*#${1} "$ENV{STORAGE_BASE_DIR}",#' ${SAMPLE_SQL}
-    perl -pi -e 's#(.*storagenode.*DEFAULT).*#${1} "$ENV{STORAGE_NODE}",#' ${SAMPLE_SQL}
+    perl -pi -e 's#(.*storagebasedirectory.*DEFAULT).*#${1} "$ENV{STORAGE_BASE_DIR}",#' ${MYSQL_VMAIL_STRUCTURE_SAMPLE}
+    perl -pi -e 's#(.*storagenode.*DEFAULT).*#${1} "$ENV{STORAGE_NODE}",#' ${MYSQL_VMAIL_STRUCTURE_SAMPLE}
 
     # Mailbox format is 'Maildir/' by default.
     cat >> ${MYSQL_VMAIL_SQL} <<EOF
 
 /* Initialize the database. */
 USE ${VMAIL_DB};
-SOURCE ${SAMPLE_SQL};
+SOURCE ${MYSQL_VMAIL_STRUCTURE_SAMPLE};
 
 /* Add your first domain. */
 INSERT INTO domain (domain,transport,created) VALUES ("${FIRST_DOMAIN}", "${TRANSPORT}", NOW());
     cat >> ${TIP_FILE} <<EOF
 Virtual Users:
     - ${MYSQL_VMAIL_SQL}
-    - ${SAMPLE_SQL}
+    - ${MYSQL_VMAIL_STRUCTURE_SAMPLE}
 
 EOF
 

iRedMail/functions/postgresql.sh

 
     # Generate SQL.
     # Modify default SQL template, set storagebasedirectory.
-    perl -pi -e 's#(.*storagebasedirectory.*DEFAULT).*#${1} "$ENV{STORAGE_BASE_DIR}",#' ${SAMPLE_SQL}
-    perl -pi -e 's#(.*storagenode.*DEFAULT).*#${1} "$ENV{STORAGE_NODE}",#' ${SAMPLE_SQL}
+    #perl -pi -e 's#(.*storagebasedirectory.*DEFAULT).*#${1} "$ENV{STORAGE_BASE_DIR}",#' ${SAMPLE_SQL}
+    #perl -pi -e 's#(.*storagenode.*DEFAULT).*#${1} "$ENV{STORAGE_NODE}",#' ${SAMPLE_SQL}
 
     # Mailbox format is 'Maildir/' by default.
+    # TODO:
+    # - Create database to store mail accounts
+    # - Set correct privilege for both ROLEs: vmail, vmailadmin
+    # - Initialize database
+    # - Add first mail domain
+    # - Add first domain admin
+    # - Assign mail domain to admin
+    # - Add first mail user
     cat >> ${PGSQL_VMAIL_SQL} <<EOF
-/* Create database for virtual hosts. */
-CREATE DATABASE IF NOT EXISTS ${VMAIL_DB} CHARACTER SET utf8;
-
-/* Permissions. */
-GRANT SELECT ON ${VMAIL_DB}.* TO "${PGSQL_BIND_USER}"@localhost IDENTIFIED BY "${PGSQL_BIND_PW}";
-GRANT SELECT,INSERT,DELETE,UPDATE ON ${VMAIL_DB}.* TO "${PGSQL_ADMIN_USER}"@localhost IDENTIFIED BY "${PGSQL_ADMIN_PW}";
-
-/* Initialize the database. */
-USE ${VMAIL_DB};
-SOURCE ${SAMPLE_SQL};
-
-/* Add your first domain. */
-INSERT INTO domain (domain,transport,created) VALUES ("${FIRST_DOMAIN}", "${TRANSPORT}", NOW());
-
-/* Add your first domain admin. */
-INSERT INTO admin (username,password,created) VALUES ("${DOMAIN_ADMIN_NAME}@${FIRST_DOMAIN}","${DOMAIN_ADMIN_PASSWD}", NOW());
-INSERT INTO domain_admins (username,domain,created) VALUES ("${DOMAIN_ADMIN_NAME}@${FIRST_DOMAIN}","ALL", NOW());
-
-/* Add domain admin. */
-/*
-INSERT INTO mailbox (username,password,name,maildir,quota,domain,created) VALUES ("${DOMAIN_ADMIN_NAME}@${FIRST_DOMAIN}","${DOMAIN_ADMIN_PASSWD}","${DOMAIN_ADMIN_NAME}","${FIRST_DOMAIN}/${DOMAIN_ADMIN_NAME}/",0, "${FIRST_DOMAIN}",NOW());
-INSERT INTO alias (address,goto,domain,created) VALUES ("${DOMAIN_ADMIN_NAME}@${FIRST_DOMAIN}", "${DOMAIN_ADMIN_NAME}@${FIRST_DOMAIN}", "${FIRST_DOMAIN}", NOW());
-*/
-
-/* Add your first normal user. */
-INSERT INTO mailbox (username,password,name,maildir,quota,domain,created) VALUES ("${FIRST_USER}@${FIRST_DOMAIN}","${FIRST_USER_PASSWD}","${FIRST_USER}","$( hash_domain ${FIRST_DOMAIN})/$( hash_maildir ${FIRST_USER} )",100, "${FIRST_DOMAIN}", NOW());
-INSERT INTO alias (address,goto,domain,created) VALUES ("${FIRST_USER}@${FIRST_DOMAIN}", "${FIRST_USER}@${FIRST_DOMAIN}", "${FIRST_DOMAIN}", NOW());
 EOF
 
     ECHO_DEBUG "Import postfix virtual hosts/users: ${PGSQL_VMAIL_SQL}."
     cat >> ${TIP_FILE} <<EOF
 Virtual Users:
     - ${PGSQL_VMAIL_SQL}
-    - ${SAMPLE_SQL}
+    - ${PGSQL_VMAIL_STRUCTURE_SAMPLE}
 
 EOF
 

iRedMail/samples/iredmail.mysql

+#---------------------------------------------------------------------
+# This file is part of iRedMail, which is an open source mail server
+# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
+#
+# iRedMail is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# iRedMail is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with iRedMail.  If not, see <http://www.gnu.org/licenses/>.
+#---------------------------------------------------------------------
+
+#
+# Based on original postfixadmin template.
+# http://postfixadmin.sf.net
+#
+
+#
+# Table structure for table admin
+#
+CREATE TABLE IF NOT EXISTS admin (
+    username VARCHAR(255) NOT NULL DEFAULT '',
+    password VARCHAR(255) NOT NULL DEFAULT '',
+    name VARCHAR(255) NOT NULL DEFAULT '',
+    language VARCHAR(5) NOT NULL DEFAULT 'en_US',
+    passwordlastchange DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+    created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+    modified DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+    expired DATETIME NOT NULL DEFAULT '9999-12-31 00:00:00',
+    active TINYINT(1) NOT NULL DEFAULT 1,
+    PRIMARY KEY (username),
+    INDEX (passwordlastchange),
+    INDEX (expired),
+    INDEX (active)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table alias
+#
+CREATE TABLE IF NOT EXISTS alias (
+    address VARCHAR(255) NOT NULL DEFAULT '',
+    goto TEXT NOT NULL DEFAULT '',
+    name VARCHAR(255) NOT NULL DEFAULT '',
+    moderators TEXT NOT NULL DEFAULT '',
+    accesspolicy VARCHAR(30) NOT NULL DEFAULT '',
+    domain VARCHAR(255) NOT NULL DEFAULT '',
+    created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+    modified DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+    expired DATETIME NOT NULL DEFAULT '9999-12-31 00:00:00',
+    active TINYINT(1) NOT NULL DEFAULT 1,
+    PRIMARY KEY (address),
+    INDEX (domain),
+    INDEX (expired),
+    INDEX (active)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table domain
+#
+CREATE TABLE IF NOT EXISTS domain (
+    -- mail domain name. e.g. iredmail.org.
+    domain VARCHAR(255) NOT NULL DEFAULT '',
+    description TEXT NOT NULL DEFAULT '',
+    -- Disclaimer text. Used by Amavisd + AlterMIME.
+    disclaimer TEXT NOT NULL DEFAULT '',
+    -- Max alias accounts in this domain. e.g. 10.
+    aliases INT(10) NOT NULL DEFAULT 0,
+    -- Max mail accounts in this domain. e.g. 100.
+    mailboxes INT(10) NOT NULL DEFAULT 0,
+    -- Max mailbox quota in this domain. e.g. 1073741824 (1GB).
+    maxquota BIGINT(20) NOT NULL DEFAULT 0,
+    quota BIGINT(20) NOT NULL DEFAULT 0,
+    -- Per-domain transport. e.g. dovecot, smtp:[192.168.1.1]:25
+    transport VARCHAR(255) NOT NULL DEFAULT 'dovecot',
+    backupmx TINYINT(1) NOT NULL DEFAULT 0,
+    -- Default quota size for newly created mail account.
+    defaultuserquota BIGINT(20) NOT NULL DEFAULT '1024',
+    -- List of mail alias addresses, Newly created user will be
+    -- assigned to them.
+    defaultuseraliases TEXT NOT NULL DEFAULT '',
+    -- Default password scheme. e.g. md5, plain.
+    defaultpasswordscheme VARCHAR(10) NOT NULL DEFAULT '',
+    -- Minimal password length, per-domain setting.
+    minpasswordlength INT(10) NOT NULL DEFAULT 0,
+    -- Max password length, per-domain setting.
+    maxpasswordlength INT(10) NOT NULL DEFAULT 0,
+    created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+    modified DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+    expired DATETIME NOT NULL DEFAULT '9999-12-31 00:00:00',
+    active TINYINT(1) NOT NULL DEFAULT 1,
+    PRIMARY KEY (domain),
+    INDEX (backupmx),
+    INDEX (expired),
+    INDEX (active)
+) ENGINE=MyISAM;
+
+CREATE TABLE IF NOT EXISTS `alias_domain` (
+    alias_domain VARCHAR(255) NOT NULL,
+    target_domain VARCHAR(255) NOT NULL,
+    created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+    modified DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+    active TINYINT(1) NOT NULL DEFAULT 1,
+    PRIMARY KEY (alias_domain),
+    INDEX (target_domain),
+    INDEX (active)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table domain_admins
+#
+CREATE TABLE IF NOT EXISTS domain_admins (
+    username VARCHAR(255) CHARACTER SET ascii NOT NULL DEFAULT '',
+    domain VARCHAR(255) CHARACTER SET ascii NOT NULL DEFAULT '',
+    created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+    modified DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+    expired DATETIME NOT NULL DEFAULT '9999-12-31 00:00:00',
+    active TINYINT(1) NOT NULL DEFAULT 1,
+    PRIMARY KEY (username,domain),
+    INDEX (username),
+    INDEX (domain),
+    INDEX (active)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table mailbox
+#
+CREATE TABLE IF NOT EXISTS mailbox (
+    username VARCHAR(255) NOT NULL,
+    password VARCHAR(255) NOT NULL DEFAULT '',
+    name VARCHAR(255) NOT NULL DEFAULT '',
+    storagebasedirectory VARCHAR(255) NOT NULL DEFAULT '',
+    storagenode VARCHAR(255) NOT NULL DEFAULT '',
+    maildir VARCHAR(255) NOT NULL DEFAULT '',
+    quota BIGINT(20) NOT NULL DEFAULT 0, -- Total mail quota size
+    domain VARCHAR(255) NOT NULL DEFAULT '',
+    transport VARCHAR(255) NOT NULL DEFAULT '',
+    department VARCHAR(255) NOT NULL DEFAULT '',
+    rank VARCHAR(255) NOT NULL DEFAULT 'normal',
+    employeeid VARCHAR(255) DEFAULT '',
+    enablesmtp TINYINT(1) NOT NULL DEFAULT 1,
+    enablesmtpsecured TINYINT(1) NOT NULL DEFAULT 1,
+    enablepop3 TINYINT(1) NOT NULL DEFAULT 1,
+    enablepop3secured TINYINT(1) NOT NULL DEFAULT 1,
+    enableimap TINYINT(1) NOT NULL DEFAULT 1,
+    enableimapsecured TINYINT(1) NOT NULL DEFAULT 1,
+    enabledeliver TINYINT(1) NOT NULL DEFAULT 1,
+    enablelda TINYINT(1) NOT NULL DEFAULT 1,
+    enablemanagesieve TINYINT(1) NOT NULL DEFAULT 1,
+    enablemanagesievesecured TINYINT(1) NOT NULL DEFAULT 1,
+    enablesieve TINYINT(1) NOT NULL DEFAULT 1,
+    enablesievesecured TINYINT(1) NOT NULL DEFAULT 1,
+    enableinternal TINYINT(1) NOT NULL DEFAULT 1,
+    lastlogindate DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+    lastloginipv4 INT(4) UNSIGNED NOT NULL DEFAULT 0,
+    lastloginprotocol CHAR(255) NOT NULL DEFAULT '',
+    disclaimer TEXT NOT NULL DEFAULT '',
+    passwordlastchange DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+    created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+    modified DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+    expired DATETIME NOT NULL DEFAULT '9999-12-31 00:00:00',
+    active TINYINT(1) NOT NULL DEFAULT 1,
+    -- Required by PostfixAdmin
+    local_part VARCHAR(255) NOT NULL DEFAULT '',
+    -- `bytes` and `messages` is obsoleting since iRedMail-0.7.4.
+    -- Use table `used_quota` instead.
+    bytes BIGINT(20) NOT NULL DEFAULT 0,
+    messages BIGINT(20) NOT NULL DEFAULT 0,
+    PRIMARY KEY (username),
+    INDEX (domain),
+    INDEX (department),
+    INDEX (employeeid),
+    INDEX (enablesmtp),
+    INDEX (enablesmtpsecured),
+    INDEX (enablepop3),
+    INDEX (enablepop3secured),
+    INDEX (enableimap),
+    INDEX (enableimapsecured),
+    INDEX (enabledeliver),
+    INDEX (enablelda),
+    INDEX (enablemanagesieve),
+    INDEX (enablemanagesievesecured),
+    INDEX (enablesieve),
+    INDEX (enablesievesecured),
+    INDEX (enableinternal),
+    INDEX (passwordlastchange),
+    INDEX (expired),
+    INDEX (active)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table sender_bcc_domain
+#
+CREATE TABLE IF NOT EXISTS sender_bcc_domain (
+    domain VARCHAR(255) NOT NULL DEFAULT '',
+    bcc_address VARCHAR(255) NOT NULL DEFAULT '',
+    created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+    modified DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+    expired DATETIME NOT NULL DEFAULT '9999-12-31 00:00:00',
+    active TINYINT(1) NOT NULL DEFAULT 1,
+    PRIMARY KEY (domain),
+    INDEX (bcc_address),
+    INDEX (expired),
+    INDEX (active)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table sender_bcc_user
+#
+CREATE TABLE IF NOT EXISTS sender_bcc_user (
+    username VARCHAR(255) NOT NULL DEFAULT '',
+    bcc_address VARCHAR(255) NOT NULL DEFAULT '',
+    domain VARCHAR(255) NOT NULL DEFAULT '',
+    created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+    modified DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+    expired DATETIME NOT NULL DEFAULT '9999-12-31 00:00:00',
+    active TINYINT(1) NOT NULL DEFAULT 1,
+    PRIMARY KEY (username),
+    INDEX (bcc_address),
+    INDEX (domain),
+    INDEX (expired),
+    INDEX (active)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table recipient_bcc_domain
+#
+CREATE TABLE IF NOT EXISTS recipient_bcc_domain (
+    domain VARCHAR(255) NOT NULL DEFAULT '',
+    bcc_address VARCHAR(255) NOT NULL DEFAULT '',
+    created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+    modified DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+    expired DATETIME NOT NULL DEFAULT '9999-12-31 00:00:00',
+    active TINYINT(1) NOT NULL DEFAULT 1,
+    PRIMARY KEY (domain),
+    INDEX (bcc_address),
+    INDEX (expired),
+    INDEX (active)
+) ENGINE=MyISAM;
+
+#
+# Table structure for table recipient_bcc_user
+#
+CREATE TABLE IF NOT EXISTS recipient_bcc_user (
+    username VARCHAR(255) NOT NULL DEFAULT '',
+    bcc_address VARCHAR(255) NOT NULL DEFAULT '',
+    domain VARCHAR(255) NOT NULL DEFAULT '',
+    created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+    modified DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+    expired DATETIME NOT NULL DEFAULT '9999-12-31 00:00:00',
+    active TINYINT(1) NOT NULL DEFAULT 1,
+    PRIMARY KEY (username),
+    INDEX (bcc_address),
+    INDEX (expired),
+    INDEX (active)
+) ENGINE=MyISAM;
+
+#
+# IMAP shared folders. User 'from_user' shares folders to user 'to_user'.
+# WARNING: Works only with Dovecot 1.2+.
+#
+CREATE TABLE IF NOT EXISTS share_folder (
+    from_user VARCHAR(255) CHARACTER SET ascii NOT NULL,
+    to_user VARCHAR(255) CHARACTER SET ascii NOT NULL,
+    dummy CHAR(1),
+    PRIMARY KEY (from_user, to_user),
+    INDEX (from_user),
+    INDEX (to_user)
+);
+
+#
+# Table `used_quota`. Used to store realtime mailbox quota in Dovecot.
+# WARNING: Works only with Dovecot 1.2+.
+#
+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;

iRedMail/samples/iredmail.sql

-#---------------------------------------------------------------------
-# This file is part of iRedMail, which is an open source mail server
-# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
-#
-# iRedMail is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# iRedMail is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with iRedMail.  If not, see <http://www.gnu.org/licenses/>.
-#---------------------------------------------------------------------
-
-#
-# Based on original postfixadmin template.
-# http://postfixadmin.sf.net
-#
-
-#
-# Table structure for table admin
-#
-CREATE TABLE IF NOT EXISTS admin (
-    username VARCHAR(255) NOT NULL DEFAULT '',
-    password VARCHAR(255) NOT NULL DEFAULT '',
-    name VARCHAR(255) NOT NULL DEFAULT '',
-    language VARCHAR(5) NOT NULL DEFAULT 'en_US',
-    passwordlastchange DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
-    created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
-    modified DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
-    expired DATETIME NOT NULL DEFAULT '9999-12-31 00:00:00',
-    active TINYINT(1) NOT NULL DEFAULT 1,
-    PRIMARY KEY (username),
-    INDEX (passwordlastchange),
-    INDEX (expired),
-    INDEX (active)
-) ENGINE=MyISAM;
-
-#
-# Table structure for table alias
-#
-CREATE TABLE IF NOT EXISTS alias (
-    address VARCHAR(255) NOT NULL DEFAULT '',
-    goto TEXT NOT NULL DEFAULT '',
-    name VARCHAR(255) NOT NULL DEFAULT '',
-    moderators TEXT NOT NULL DEFAULT '',
-    accesspolicy VARCHAR(30) NOT NULL DEFAULT '',
-    domain VARCHAR(255) NOT NULL DEFAULT '',
-    created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
-    modified DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
-    expired DATETIME NOT NULL DEFAULT '9999-12-31 00:00:00',
-    active TINYINT(1) NOT NULL DEFAULT 1,
-    PRIMARY KEY (address),
-    INDEX (domain),
-    INDEX (expired),
-    INDEX (active)
-) ENGINE=MyISAM;
-
-#
-# Table structure for table domain
-#
-CREATE TABLE IF NOT EXISTS domain (
-    -- mail domain name. e.g. iredmail.org.
-    domain VARCHAR(255) NOT NULL DEFAULT '',
-    description TEXT NOT NULL DEFAULT '',
-    -- Disclaimer text. Used by Amavisd + AlterMIME.
-    disclaimer TEXT NOT NULL DEFAULT '',
-    -- Max alias accounts in this domain. e.g. 10.
-    aliases INT(10) NOT NULL DEFAULT 0,
-    -- Max mail accounts in this domain. e.g. 100.
-    mailboxes INT(10) NOT NULL DEFAULT 0,
-    -- Max mailbox quota in this domain. e.g. 1073741824 (1GB).
-    maxquota BIGINT(20) NOT NULL DEFAULT 0,
-    quota BIGINT(20) NOT NULL DEFAULT 0,
-    -- Per-domain transport. e.g. dovecot, smtp:[192.168.1.1]:25
-    transport VARCHAR(255) NOT NULL DEFAULT 'dovecot',
-    backupmx TINYINT(1) NOT NULL DEFAULT 0,
-    -- Default quota size for newly created mail account.
-    defaultuserquota BIGINT(20) NOT NULL DEFAULT '1024',
-    -- List of mail alias addresses, Newly created user will be
-    -- assigned to them.
-    defaultuseraliases TEXT NOT NULL DEFAULT '',
-    -- Default password scheme. e.g. md5, plain.
-    defaultpasswordscheme VARCHAR(10) NOT NULL DEFAULT '',
-    -- Minimal password length, per-domain setting.
-    minpasswordlength INT(10) NOT NULL DEFAULT 0,
-    -- Max password length, per-domain setting.
-    maxpasswordlength INT(10) NOT NULL DEFAULT 0,
-    created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
-    modified DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
-    expired DATETIME NOT NULL DEFAULT '9999-12-31 00:00:00',
-    active TINYINT(1) NOT NULL DEFAULT 1,
-    PRIMARY KEY (domain),
-    INDEX (backupmx),
-    INDEX (expired),
-    INDEX (active)
-) ENGINE=MyISAM;
-
-CREATE TABLE IF NOT EXISTS `alias_domain` (
-    alias_domain VARCHAR(255) NOT NULL,
-    target_domain VARCHAR(255) NOT NULL,
-    created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
-    modified DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
-    active TINYINT(1) NOT NULL DEFAULT 1,
-    PRIMARY KEY (alias_domain),
-    INDEX (target_domain),
-    INDEX (active)
-) ENGINE=MyISAM;
-
-#
-# Table structure for table domain_admins
-#
-CREATE TABLE IF NOT EXISTS domain_admins (
-    username VARCHAR(255) CHARACTER SET ascii NOT NULL DEFAULT '',
-    domain VARCHAR(255) CHARACTER SET ascii NOT NULL DEFAULT '',
-    created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
-    modified DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
-    expired DATETIME NOT NULL DEFAULT '9999-12-31 00:00:00',
-    active TINYINT(1) NOT NULL DEFAULT 1,
-    PRIMARY KEY (username,domain),
-    INDEX (username),
-    INDEX (domain),
-    INDEX (active)
-) ENGINE=MyISAM;
-
-#
-# Table structure for table mailbox
-#
-CREATE TABLE IF NOT EXISTS mailbox (
-    username VARCHAR(255) NOT NULL,
-    password VARCHAR(255) NOT NULL DEFAULT '',
-    name VARCHAR(255) NOT NULL DEFAULT '',
-    storagebasedirectory VARCHAR(255) NOT NULL DEFAULT '',
-    storagenode VARCHAR(255) NOT NULL DEFAULT '',
-    maildir VARCHAR(255) NOT NULL DEFAULT '',
-    quota BIGINT(20) NOT NULL DEFAULT 0, -- Total mail quota size
-    domain VARCHAR(255) NOT NULL DEFAULT '',
-    transport VARCHAR(255) NOT NULL DEFAULT '',
-    department VARCHAR(255) NOT NULL DEFAULT '',
-    rank VARCHAR(255) NOT NULL DEFAULT 'normal',
-    employeeid VARCHAR(255) DEFAULT '',
-    enablesmtp TINYINT(1) NOT NULL DEFAULT 1,
-    enablesmtpsecured TINYINT(1) NOT NULL DEFAULT 1,
-    enablepop3 TINYINT(1) NOT NULL DEFAULT 1,
-    enablepop3secured TINYINT(1) NOT NULL DEFAULT 1,
-    enableimap TINYINT(1) NOT NULL DEFAULT 1,
-    enableimapsecured TINYINT(1) NOT NULL DEFAULT 1,
-    enabledeliver TINYINT(1) NOT NULL DEFAULT 1,
-    enablelda TINYINT(1) NOT NULL DEFAULT 1,
-    enablemanagesieve TINYINT(1) NOT NULL DEFAULT 1,
-    enablemanagesievesecured TINYINT(1) NOT NULL DEFAULT 1,
-    enablesieve TINYINT(1) NOT NULL DEFAULT 1,
-    enablesievesecured TINYINT(1) NOT NULL DEFAULT 1,
-    enableinternal TINYINT(1) NOT NULL DEFAULT 1,
-    lastlogindate DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
-    lastloginipv4 INT(4) UNSIGNED NOT NULL DEFAULT 0,
-    lastloginprotocol CHAR(255) NOT NULL DEFAULT '',
-    disclaimer TEXT NOT NULL DEFAULT '',
-    passwordlastchange DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
-    created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
-    modified DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
-    expired DATETIME NOT NULL DEFAULT '9999-12-31 00:00:00',
-    active TINYINT(1) NOT NULL DEFAULT 1,
-    -- Required by PostfixAdmin
-    local_part VARCHAR(255) NOT NULL DEFAULT '',
-    -- `bytes` and `messages` is obsoleting since iRedMail-0.7.4.
-    -- Use table `used_quota` instead.
-    bytes BIGINT(20) NOT NULL DEFAULT 0,
-    messages BIGINT(20) NOT NULL DEFAULT 0,
-    PRIMARY KEY (username),
-    INDEX (domain),
-    INDEX (department),
-    INDEX (employeeid),
-    INDEX (enablesmtp),
-    INDEX (enablesmtpsecured),
-    INDEX (enablepop3),
-    INDEX (enablepop3secured),
-    INDEX (enableimap),
-    INDEX (enableimapsecured),
-    INDEX (enabledeliver),
-    INDEX (enablelda),
-    INDEX (enablemanagesieve),
-    INDEX (enablemanagesievesecured),
-    INDEX (enablesieve),
-    INDEX (enablesievesecured),
-    INDEX (enableinternal),
-    INDEX (passwordlastchange),
-    INDEX (expired),
-    INDEX (active)
-) ENGINE=MyISAM;
-
-#
-# Table structure for table sender_bcc_domain
-#
-CREATE TABLE IF NOT EXISTS sender_bcc_domain (
-    domain VARCHAR(255) NOT NULL DEFAULT '',
-    bcc_address VARCHAR(255) NOT NULL DEFAULT '',
-    created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
-    modified DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
-    expired DATETIME NOT NULL DEFAULT '9999-12-31 00:00:00',
-    active TINYINT(1) NOT NULL DEFAULT 1,
-    PRIMARY KEY (domain),
-    INDEX (bcc_address),
-    INDEX (expired),
-    INDEX (active)
-) ENGINE=MyISAM;
-
-#
-# Table structure for table sender_bcc_user
-#
-CREATE TABLE IF NOT EXISTS sender_bcc_user (
-    username VARCHAR(255) NOT NULL DEFAULT '',
-    bcc_address VARCHAR(255) NOT NULL DEFAULT '',
-    domain VARCHAR(255) NOT NULL DEFAULT '',
-    created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
-    modified DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
-    expired DATETIME NOT NULL DEFAULT '9999-12-31 00:00:00',
-    active TINYINT(1) NOT NULL DEFAULT 1,
-    PRIMARY KEY (username),
-    INDEX (bcc_address),
-    INDEX (domain),
-    INDEX (expired),
-    INDEX (active)
-) ENGINE=MyISAM;
-
-#
-# Table structure for table recipient_bcc_domain
-#
-CREATE TABLE IF NOT EXISTS recipient_bcc_domain (
-    domain VARCHAR(255) NOT NULL DEFAULT '',
-    bcc_address VARCHAR(255) NOT NULL DEFAULT '',
-    created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
-    modified DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
-    expired DATETIME NOT NULL DEFAULT '9999-12-31 00:00:00',
-    active TINYINT(1) NOT NULL DEFAULT 1,
-    PRIMARY KEY (domain),
-    INDEX (bcc_address),
-    INDEX (expired),
-    INDEX (active)
-) ENGINE=MyISAM;
-
-#
-# Table structure for table recipient_bcc_user
-#
-CREATE TABLE IF NOT EXISTS recipient_bcc_user (
-    username VARCHAR(255) NOT NULL DEFAULT '',
-    bcc_address VARCHAR(255) NOT NULL DEFAULT '',
-    domain VARCHAR(255) NOT NULL DEFAULT '',
-    created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
-    modified DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
-    expired DATETIME NOT NULL DEFAULT '9999-12-31 00:00:00',
-    active TINYINT(1) NOT NULL DEFAULT 1,
-    PRIMARY KEY (username),
-    INDEX (bcc_address),
-    INDEX (expired),
-    INDEX (active)
-) ENGINE=MyISAM;
-
-#
-# IMAP shared folders. User 'from_user' shares folders to user 'to_user'.
-# WARNING: Works only with Dovecot 1.2+.
-#
-CREATE TABLE IF NOT EXISTS share_folder (
-    from_user VARCHAR(255) CHARACTER SET ascii NOT NULL,
-    to_user VARCHAR(255) CHARACTER SET ascii NOT NULL,
-    dummy CHAR(1),
-    PRIMARY KEY (from_user, to_user),
-    INDEX (from_user),
-    INDEX (to_user)
-);
-
-#
-# Table `used_quota`. Used to store realtime mailbox quota in Dovecot.
-# WARNING: Works only with Dovecot 1.2+.
-#
-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;