Commits

Zhang Huangbin committed 172236c

Add Policyd-2 support on Ubuntu 11.10, it's completed.

  • Participants
  • Parent commits e44c89c

Comments (0)

Files changed (7)

File iRedMail/ChangeLog

 iRedMail-0.7.4:
+    * Add Policyd-2.0.x support on Ubuntu 11.10.
+    * LDA (Dovecot deliver) now will move SPAM to Junk folder by default.
+    * Add missing INDEXes for Amavisd database: msgs.mail_id, (msgs.content,
+      msgs.time_num), quarantine.mail_id.
+      Thanks rjnena <rjnena@gmail>, David <dcharbonnier@gmail>.
     * Fixed:
       + Incorrect per-user mailbox quota if loggin in with shadowAddress.
         OpenLDAP backend only. Thanks tmihalicek <tomislav.mihalicek @gmail>.
       + Incorrect per-user sieve_dir setting in Dovecot.
         Thanks cetex <oskar @cetex.se>.
-    * LDA (Dovecot deliver) now will move SPAM to Junk folder by default.
-    * Add missing INDEXes for Amavisd database: msgs.mail_id, (msgs.content,
-      msgs.time_num), quarantine.mail_id.
-      Thanks rjnena <rjnena@gmail>, David <dcharbonnier@gmail>.
     * Package update:
         + Roundcube webmail -> 0.6.0
         + phpMyAdmin -> 3.4.6

File iRedMail/conf/cluebringer

 export CLUEBRINGER_BINDHOST='127.0.0.1'
 export CLUEBRINGER_BINDPORT='10031'
 
+# Database.
+export CLUEBRINGER_DB_NAME='cluebringer'
+export CLUEBRINGER_DB_USER='cluebringer'
 export CLUEBRINGER_DB_PASSWD="$(${RANDOM_STRING})"
 
 export CLUEBRINGER_USER='cluebringer'
     export CLUEBRINGER_INIT_SCRIPT="${DIR_RC_SCRIPTS}/policyd"
     export CLUEBRINGER_PID_FILE='/var/run/cluebringer/cbpolicyd.pid'
 
-    # Database.
-    export CLUEBRINGER_DB_NAME='cluebringer'
-    export CLUEBRINGER_DB_USER='cluebringer'
-
     # Path of policyd-clean
     export CLUEBRINGER_CLEANUP_BIN='/usr/sbin/policyd-cleanup'
 
     export CLUEBRINGER_INIT_SCRIPT="${DIR_RC_SCRIPTS}/policyd"
     export CLUEBRINGER_PID_FILE='var/run/cluebringer/cbpolicyd.pid'
 
-    # Database.
-    export CLUEBRINGER_DB_NAME='cluebringer'
-    export CLUEBRINGER_DB_USER='cluebringer'
-
     # Path of policyd-clean
     export CLUEBRINGER_CLEANUP_BIN='/usr/lib/policyd/cleanup'
 
     export CLUEBRINGER_INIT_SCRIPT="${DIR_RC_SCRIPTS}/postfix-policyd"
     export CLUEBRINGER_PID_FILE='var/run/cluebringer/cbpolicyd.pid'
 
-    # Database.
-    export CLUEBRINGER_DB_NAME='postfixcluebringer'
-    export CLUEBRINGER_DB_USER='postfix-cluebringer'
-
     # Path of policyd-clean
     export CLUEBRINGER_CLEANUP_BIN='/usr/lib/postfix-policyd/cleanup'
 
     export CLUEBRINGER_INIT_SCRIPT="${DIR_RC_SCRIPTS}/policyd"
     export CLUEBRINGER_PID_FILE='var/run/cluebringer/cbpolicyd.pid'
 
-    # Database.
-    export CLUEBRINGER_DB_NAME='cluebringer'
-    export CLUEBRINGER_DB_USER='cluebringer'
-
     # Path of policyd-clean
     export CLUEBRINGER_CLEANUP_BIN='/usr/local/sbin/postfix-policyd-sf-cleanup'
 

File iRedMail/conf/core

 # Create SSL certs/private files.
 gen_pem_key()
 {
+    ECHO_INFO "Create SSL certification files."
+
     # Create necessary directories.
     mkdir -p ${SSL_KEY_DIR} ${SSL_CERT_DIR} 2>/dev/null
 

File iRedMail/conf/policy_server

+#!/usr/bin/env bash
+
+# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+
+#---------------------------------------------------------------------
+# 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/>.
+#---------------------------------------------------------------------
+
+if [ X"${DISTRO_CODENAME}" == X"oneiric" ]; then
+    # Use Policyd-2.x (cluebringer).
+    export USE_CLUEBRINGER='YES'
+    export USE_POLICYD='NO'
+
+    . ${CONF_DIR}/cluebringer
+else
+    # Use Policyd-1.x.
+    export USE_CLUEBRINGER='NO'
+    export USE_POLICYD='YES'
+
+    . ${CONF_DIR}/policyd
+fi

File iRedMail/functions/cluebringer.sh

     perl -pi -e 's/^#(group=).*/${1}$ENV{CLUEBRINGER_GROUP}/' ${CLUEBRINGER_CONF}
 
     # Filename to store pid of parent process
-    perl -pi -e 's/^(pid_file=).*/${1}"$ENV{CLUEBRINGER_PID_FILE}"/' ${CLUEBRINGER_CONF}
+    perl -pi -e 's/^(pid_file=).*/${1}$ENV{CLUEBRINGER_PID_FILE}/' ${CLUEBRINGER_CONF}
 
     # Log level
     # 0 - Errors only
     #
     # Configure '[database]' section.
     #
+    # DSN
+    perl -pi -e 's/^#(DSN=DBI:mysql:).*/${1}host=$ENV{MYSQL_SERVER};database=$ENV{CLUEBRINGER_DB_NAME};user=$ENV{CLUEBRINGER_DB_USER};password=$ENV{CLUEBRINGER_DB_PASSWD}/' ${CLUEBRINGER_CONF}
+    # Database
     perl -pi -e 's/^(DB_Type=).*/${1}mysql/' ${CLUEBRINGER_CONF}
     perl -pi -e 's/^(DB_Host=).*/${1}$ENV{MYSQL_SERVER}/' ${CLUEBRINGER_CONF}
     perl -pi -e 's/^(DB_Port=).*/${1}$ENV{MYSQL_PORT}/' ${CLUEBRINGER_CONF}
 
     elif [ X"${DISTRO}" == X"DEBIAN" -o X"${DISTRO}" == X"UBUNTU" ]; then
         cat > ${tmp_sql} <<EOF
-# Reset password.
+# Reset root password.
 USE mysql;
-CREATE DATABASE ${CLUEBRINGER_DB_NAME};
 UPDATE user SET Password=password("${CLUEBRINGER_DB_PASSWD}") WHERE User="${CLUEBRINGER_DB_USER}";
 FLUSH PRIVILEGES;
+CREATE DATABASE ${CLUEBRINGER_DB_NAME};
+USE ${CLUEBRINGER_DB_NAME};
 EOF
-        gunzip -c /usr/share/doc/postfix-cluebringer/database/policyd-db.mysql.gz > ${tmp_sql}
+
+        if [ X"${BACKEND}" == X"OpenLDAP" -o X"${BACKEND}" == X"MySQL" ]; then
+            gunzip -c /usr/share/doc/postfix-cluebringer/database/policyd-db.mysql.gz >> ${tmp_sql}
+        elif [ X"${BACKEND}" == X"PostgreSQL" ]; then
+            gunzip -c /usr/share/doc/postfix-cluebringer/database/policyd-db.pgsql.gz >> ${tmp_sql}
+        fi
 
     elif [ X"${DISTRO}" == X"FREEBSD" ]; then
         # Template file will create database: policyd.
         :
     fi
 
-    cat >> ${tmp_sql} <<EOF
-USE ${CLUEBRINGER_DB_NAME};
-SOURCE ${SAMPLE_DIR}/policyd_blacklist_helo.sql;
-EOF
-
     mysql -h${MYSQL_SERVER} -P${MYSQL_PORT} -u${MYSQL_ROOT_USER} -p"${MYSQL_ROOT_PASSWD}" <<EOF
 $(cat ${tmp_sql})
 EOF

File iRedMail/functions/postfix.sh

     #
     # **** End HELO related ****
 
-    if [ X"${USE_IREDAPD}" == X"YES" ]; then
+    if [ X"${USE_CLUEBRINGER}" == X"YES" ]; then
+        postconf -e smtpd_recipient_restrictions="reject_unknown_sender_domain, reject_unknown_recipient_domain, reject_non_fqdn_sender, reject_non_fqdn_recipient, reject_unlisted_recipient, check_policy_service inet:${IREDAPD_LISTEN_ADDR}:${IREDAPD_LISTEN_PORT}, permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, reject_non_fqdn_helo_hostname, reject_invalid_helo_hostname, check_policy_service inet:${CLUEBRINGER_BINDHOST}:${CLUEBRINGER_BINDPORT}"
+        postconf -e smtpd_end_of_data_restrictions="check_policy_service inet:${CLUEBRINGER_BINDHOST}:${CLUEBRINGER_BINDPORT}"
+    else
         postconf -e smtpd_recipient_restrictions="reject_unknown_sender_domain, reject_unknown_recipient_domain, reject_non_fqdn_sender, reject_non_fqdn_recipient, reject_unlisted_recipient, check_policy_service inet:${IREDAPD_LISTEN_ADDR}:${IREDAPD_LISTEN_PORT}, permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, reject_non_fqdn_helo_hostname, reject_invalid_helo_hostname, check_policy_service inet:${POLICYD_BINDHOST}:${POLICYD_BINDPORT}"
-    else
-        postconf -e smtpd_recipient_restrictions="reject_unknown_sender_domain, reject_unknown_recipient_domain, reject_non_fqdn_sender, reject_non_fqdn_recipient, reject_unlisted_recipient, permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, reject_non_fqdn_helo_hostname, reject_invalid_helo_hostname, check_policy_service inet:${POLICYD_BINDHOST}:${POLICYD_BINDPORT}"
     fi
 
     echo 'export status_postfix_config_sasl="DONE"' >> ${STATUS_FILE}

File iRedMail/iRedMail.sh

 . ${CONF_DIR}/phpldapadmin
 . ${CONF_DIR}/mysql
 . ${CONF_DIR}/postfix
-. ${CONF_DIR}/policyd
-. ${CONF_DIR}/cluebringer
+. ${CONF_DIR}/policy_server
 . ${CONF_DIR}/iredapd
 . ${CONF_DIR}/dovecot
 . ${CONF_DIR}/managesieve
 # ************************************************************************
 
 # Install all packages.
-check_status_before_run install_all || (ECHO_INFO "Package installation error, please check the output log." && exit 255)
+check_status_before_run install_all || (ECHO_ERROR "Package installation error, please check the output log." && exit 255)
+
+ECHO_INFO "---- Start iRedMail Configurations ----"
 
 # Create SSL/TLS cert file.
 check_status_before_run gen_pem_key