Commits

Zhang Huangbin committed a2a79f8

Improve Gentoo support:
* Fix incorrect file location of Apache config files
* Use group name 'mail' instead of 'vmail'
* Set correct permission on Apache DocumentRoot
* Disable unused modules
* Set correct file location of SSL cert/key
* Execute sa-update and sa-compile after installation finished
* Install portage 'gentoolkit' if command 'equery' doesn't exist

Comments (0)

Files changed (7)

iRedMail/conf/apache_php

 elif [ X"${DISTRO}" == X"GENTOO" ]; then
     # Apache configuration files.
     export HTTPD_CONF_ROOT="/etc/apache2"
-    export HTTPD_CONF="${HTTPD_CONF_ROOT}/httpd.conf"
+    export HTTPD_CONF="${HTTPD_CONF_ROOT}/modules.d/00_default_settings.conf"
     export HTTPD_CONF_DIR="${HTTPD_CONF_ROOT}/modules.d"
     export HTTPD_SSL_CONF="${HTTPD_CONF_ROOT}/vhosts.d/00_default_ssl_vhost.conf"
-    export HTTPD_WSGI_CONF="${HTTPD_CONF_DIR}/wsgi.conf"
+    export HTTPD_WSGI_CONF="${HTTPD_CONF_DIR}/70_mod_wsgi.conf"
     export HTTPD_SYSCONFIG_CONF="${ETC_SYSCONFIG_DIR}/apache2"
 
     # Web data.

iRedMail/conf/dovecot

     export DOVECOT_PGSQL_CONF='/etc/dovecot/dovecot-pgsql.conf'
     export DOVECOT_REALTIME_QUOTA_CONF='/etc/dovecot/dovecot-used-quota.conf'
     export DOVECOT_SHARE_FOLDER_CONF='/etc/dovecot/dovecot-share-folder.conf'
+    export DOVECOT_DELIVER='/usr/libexec/dovecot/deliver'
 
 elif [ X"${DISTRO}" == X"FREEBSD" ]; then
     export DOVECOT_VERSION='1.2'

iRedMail/conf/global

     export SSL_FILE_DIR="/etc/ssl"
 
     # Override default value.
+    export VMAIL_GROUP_NAME='mail'
     export PKG_DIALOG="dialog"
     export PKG_BZIP2="bzip2"
 

iRedMail/conf/spamassassin

 export SA_RULES_DIR='/usr/share/spamassassin'
 export SA_INIT_PRE="${SA_CONF_DIR}/init.pre"
 export SA_LOCAL_CF="${SA_CONF_DIR}/local.cf"
+export BIN_SA_UPDATE='sa-update'
+export BIN_SA_COMPILE='sa-compile'
 
 if [ X"${DISTRO}" == X"FREEBSD" ]; then
     export SA_CONF_DIR='/usr/local/etc/mail/spamassassin'
     export SA_RULES_DIR='/usr/local/share/spamassassin'
     export SA_INIT_PRE="${SA_CONF_DIR}/init.pre"
     export SA_LOCAL_CF="${SA_CONF_DIR}/local.cf"
+    export BIN_SA_UPDATE='/usr/local/bin/sa-update'
+    export BIN_SA_COMPILE='/usr/local/bin/sa-compile'
 fi

iRedMail/functions/apache_php.sh

         #sed -i -e '/AllowOverride/,/AccessFileName/s#Deny from all#Allow from all#' ${HTTPD_CONF_ROOT}/httpd.conf
     else
         perl -pi -e 's#^(ServerTokens).*#${1} ProductOnly#' ${HTTPD_CONF}
+        perl -pi -e 's#^(ServerSignature).*#${1} EMail#' ${HTTPD_CONF}
+        perl -pi -e 's#^(LogLevel).*#${1} warn#' ${HTTPD_CONF}
+
         if [ X"${DISTRO}" == X"DEBIAN" -o X"${DISTRO}" == X"UBUNTU" ]; then
             perl -pi -e 's#^(ServerTokens).*#${1} ProductOnly#' ${HTTPD_CONF_DIR}/security
         fi
-
-        perl -pi -e 's#^(ServerSignature).*#${1} EMail#' ${HTTPD_CONF}
-        perl -pi -e 's#^(LogLevel).*#${1} warn#' ${HTTPD_CONF}
     fi
 
     ############
     if [ X"${DISTRO}" == X"RHEL" -o X"${DISTRO}" == X"FREEBSD" ]; then
         perl -pi -e 's#^(SSLCertificateFile)(.*)#${1} $ENV{SSL_CERT_FILE}#' ${HTTPD_SSL_CONF}
         perl -pi -e 's#^(SSLCertificateKeyFile)(.*)#${1} $ENV{SSL_KEY_FILE}#' ${HTTPD_SSL_CONF}
-    elif [ X"${DISTRO}" == X"DEBIAN" -o X"${DISTRO}" == X"UBUNTU" ]; then
+
+    elif [ X"${DISTRO}" == X"DEBIAN" \
+        -o X"${DISTRO}" == X"UBUNTU" \
+        -o X"${DISTRO}" == X'GENTOO' \
+        ]; then
         perl -pi -e 's#^([ \t]+SSLCertificateFile)(.*)#${1} $ENV{SSL_CERT_FILE}#' ${HTTPD_SSL_CONF}
         perl -pi -e 's#^([ \t]+SSLCertificateKeyFile)(.*)#${1} $ENV{SSL_KEY_FILE}#' ${HTTPD_SSL_CONF}
     else
         # Module: mod_auth_pgsql
         [ X"${BACKEND}" == X'PGSQL' ] && \
             perl -pi -e 's#^(APACHE2_OPTS=.*)(")#${1} -D AUTH_PGSQL${2}#' ${HTTPD_SYSCONFIG_CONF}
+
+        # Disable modules: mod_proxy_scgi
+        perl -pi -e 's/^(LoadModule.*mod_proxy_scgi.*)/#${1}/' ${HTTPD_CONF_ROOT}/httpd.conf
     else
         :
     fi
 
     # FreeBSD
-    if [ X"${DISTRO}" == X"FREEBSD" ]; then
+    if [ X"${DISTRO}" == X'GENTOO' ]; then
+        # Change 'Deny from all' to 'Allow from all'.
+        sed -i '/Order deny,allow/,/Deny from all/s#Deny\ from\ all#Allow\ from\ all#' ${HTTPD_CONF_DIR}/00_default_settings.conf
+        sed -i '/Order deny,allow/,/All from all/s#Order\ deny,allow#Order\ allow,deny#' ${HTTPD_CONF_DIR}/00_default_settings.conf
+
+    elif [ X"${DISTRO}" == X'FREEBSD' ]; then
         ECHO_DEBUG "Configure Apache."
         # With Apache2.2 it now wants to load an Accept Filter.
         echo 'accf_http_load="YES"' >> /boot/loader.conf
 
         # Change 'Deny from all' to 'Allow from all'.
         sed -i '.iredmailtmp' '/Each directory to/,/Note that from/s#Deny\ from\ all#Allow\ from\ all#' ${HTTPD_CONF}
-        rm -f ${HTTPD_CONF}.iredmailtmp >/dev/null 2>&1
+        rm -f ${HTTPD_CONF}.iredmailtmp &>/dev/null
 
         # Set ServerName.
         perl -pi -e 's/^#(ServerName).*/${1} $ENV{HOSTNAME}/' ${HTTPD_CONF}

iRedMail/functions/cleanup.sh

 
             # FreeBSD
             if [ X"${DISTRO}" == X"FREEBSD" ]; then
-                # Update clamav before start clamav-clamd service.
-                ECHO_INFO "Updating ClamAV database..."
-                freshclam
-
                 # Load kernel module 'accf_http' before start.
                 kldload accf_http
 
     echo 'export status_cleanup_start_postfix_now="DONE"' >> ${STATUS_FILE}
 }
 
-cleanup_sa_preconfig()
+cleanup_amavisd_preconfig()
 {
-    # Required on FreeBSD to start Amavisd-new.
-    ECHO_INFO "Fetching SpamAssassin rules (sa-update) ..."
-    /usr/local/bin/sa-update >/dev/null
+    # Required on Gentoo and FreeBSD to start Amavisd-new.
+    ECHO_INFO "Fetching SpamAssassin rules (sa-update), please wait..."
+    ${BIN_SA_UPDATE} &>/dev/null
 
-    ECHO_INFO "Compiling SpamAssassin ruleset into native code (sa-compile), be patient..."
-    /usr/local/bin/sa-compile >/dev/null
+    ECHO_INFO "Compiling SpamAssassin rulesets into native code, please be patient..."
+    ${BIN_SA_COMPILE} &>/dev/null
 
-    echo 'export status_cleanup_sa_preconfig="DONE"' >> ${STATUS_FILE}
+    # Update clamav before start clamav-clamd service.
+    ECHO_INFO "Updating ClamAV database..."
+    freshclam &>/dev/null
+
+    echo 'export status_cleanup_amavisd_preconfig="DONE"' >> ${STATUS_FILE}
 }
 
 cleanup_backup_scripts()
     check_status_before_run cleanup_remove_mod_python
     [ X"${KERNEL_NAME}" == X"Linux" ] && check_status_before_run cleanup_replace_iptables_rule
     [ X"${DISTRO}" == X"RHEL" ] && check_status_before_run cleanup_replace_mysql_config
-    check_status_before_run cleanup_start_postfix_now
-    [ X"${DISTRO}" == X"FREEBSD" ] && check_status_before_run cleanup_sa_preconfig
+    [ X"${DISTRO}" != X'GENTOO' ] && check_status_before_run cleanup_start_postfix_now
+    [ X"${DISTRO}" == X"FREEBSD" -o X"${DISTRO}" == X'GENTOO' ] && check_status_before_run cleanup_amavisd_preconfig
     check_status_before_run cleanup_backup_scripts
 
     # Send tip file to the mail server admin and/or first mail user.
 *
 EOF
 
-if [ X"${POSTFIX_STARTED}" != X"YES" -a X"${DISTRO}" != X"FREEBSD" ]; then
+if [ X"${POSTFIX_STARTED}" != X"YES" \
+    -a X"${DISTRO}" != X'FREEBSD' \
+    -a X"${DISTRO}" != X'GENTOO' \
+    ]; then
     cat <<EOF
 * Please reboot your system to enable mail related services or start them
 * manually without reboot:
 EOF
 fi
 
-    if [ X"${DISTRO}" == X"FREEBSD" ]; then
-        # Reboot freebsd to enable mail related services, because sendmail is
-        # binding to port '25'.
+    if [ X"${DISTRO}" == X'FREEBSD' \
+        -o X"${DISTRO}" == X'GENTOO' \
+        ]; then
+        # Reboot system to enable mail related services.
+        # - FreeBSD: sendmail is binding to port '25'
+        # - Gentoo: some services may require system reboot
         cat <<EOF
 * Please reboot your system to enable mail related services.
 *

iRedMail/pkgs/get_all.sh

 elif [ X"${DISTRO}" == X'GENTOO' ]; then
     # qlist is used to list all installed portages (qlist --installed).
     check_pkg 'qlist' 'portage-utils'
+    check_pkg 'equery' 'gentoolkit'
     check_pkg 'crontab' 'vixie-cron'
 fi