Commits

Zhang Huangbin committed 6096007

Improve Gentoo support:
* Do not include portage directory name in package name
* Fix incorrect file location of iptables rules
* Build binary package in addition to install portage
* Add missing packages: mod_auth_{pgsql,mysql}
* Enable required Apache modules in /etc/conf.d/apache2
* Check required package: vixie-cron

Comments (0)

Files changed (8)

iRedMail/conf/apache_php

     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_SYSCONFIG_CONF="${ETC_SYSCONFIG_DIR}/apache2"
 
     # Web data.
     export HTTPD_SERVERROOT='/var/www'

iRedMail/conf/core

     cmd="$1"
     pkg="$2"
 
-    ECHO_DEBUG "Checking necessary command/package: ${cmd}/${pkg} ..."
+    ECHO_INFO "Checking necessary command/package: ${cmd}/${pkg} ..."
     for i in $(echo $PATH|sed 's/:/ /g'); do
         [ -x $i/${cmd} ] && export HAS_CMD='YES' && break
     done
             status="\$status_install_port_$portname"
             if [ X"$(eval echo ${status})" != X"DONE" ]; then
                 ECHO_INFO "Installing package: ${i} ..."
-                emerge ${i}
+                emerge --buildpkg ${i}
 
                 if [ X"$?" == X"0" ]; then
                     echo "export status_install_port_${portname}='DONE'" >> ${STATUS_FILE}
     [ -f /etc/portage/package.mask ] || touch /etc/portage/package.mask
     ECHO_DEBUG "Mask packages in /etc/portage/package.mask: $@"
     for pkg in $@; do
-        if not $(grep "^${pkg}$" /etc/portage/package.mask); then
+        if ! grep "^${pkg}$" /etc/portage/package.mask; then
             echo ${pkg} >> /etc/portage/package.mask
         fi
     done
 {
     [ -f /etc/portage/package.unmask ] || touch /etc/portage/package.unmask
     for pkg in $@; do
-        if not $(grep "^${pkg}$" /etc/portage/package.unmask); then
+        if ! grep "^${pkg}$" /etc/portage/package.unmask &>/dev/null; then
             ECHO_DEBUG "Unmask packages in /etc/portage/package.unmask: $@"
             echo ${pkg} >> /etc/portage/package.unmask
         fi

iRedMail/conf/global

     export ETC_SYSCONFIG_DIR='/etc/conf.d'
 
     # Iptables rule file.
-    export IPTABLES_CONFIG="${ETC_SYSCONFIG_DIR}/iptables"
+    export IPTABLES_CONFIG="/var/lib/iptables/rules-save"
 
     # Directory used to store SSL/TLS key/cert file.
     export SSL_FILE_DIR="/etc/ssl"
 
     # Override default value.
-    export PKG_DIALOG="dev-util/dialog"
-    export PKG_BZIP2="app-arch/bzip2"
+    export PKG_DIALOG="dialog"
+    export PKG_BZIP2="bzip2"
 
 elif [ X"${DISTRO}" == X"FREEBSD" ]; then
     # System user: root.

iRedMail/functions/apache_php.sh

             a2enmod ldap &>/dev/null
 
         [ X"${BACKEND}" == X"MYSQL" ] && a2enmod auth_mysql &>/dev/null
+
+    elif [ X"${DISTRO}" == X'GENTOO' ]; then
+        # Enable modules: php, wsgi
+        perl -pi -e 's#^(APACHE2_OPTS=.*)(")#${1} -D PHP5 -D WSGI${2}#' ${HTTPD_SYSCONFIG_CONF}
+
+        # Modules: ldap, authnz_ldap
+        [ X"${BACKEND}" == X"OPENLDAP" ] && \
+            perl -pi -e 's#^(APACHE2_OPTS=.*)(")#${1} -D LDAP -D AUTHNZ_LDAP${2}#' ${HTTPD_SYSCONFIG_CONF}
+
+        # Module: mod_auth_mysql
+        [ X"${BACKEND}" == X'MYSQL' ] && \
+            perl -pi -e 's#^(APACHE2_OPTS=.*)(")#${1} -D AUTH_MYSQL${2}#' ${HTTPD_SYSCONFIG_CONF}
+
+        # Module: mod_auth_pgsql
+        [ X"${BACKEND}" == X'PGSQL' ] && \
+            perl -pi -e 's#^(APACHE2_OPTS=.*)(")#${1} -D AUTH_PGSQL${2}#' ${HTTPD_SYSCONFIG_CONF}
     else
         :
     fi

iRedMail/functions/cleanup.sh

 cleanup_remove_sendmail()
 {
     # Remove sendmail.
-    eval ${LIST_ALL_PKGS} | grep sendmail &>/dev/null
+    eval ${LIST_ALL_PKGS} | grep 'sendmail' &>/dev/null
 
     if [ X"$?" == X"0" ]; then
         ECHO_QUESTION -n "Would you like to *REMOVE* sendmail now? [Y|n]"

iRedMail/functions/openldap.sh

     ECHO_INFO "Configure OpenLDAP server."
 
     ECHO_DEBUG "Stoping OpenLDAP."
-    ${LDAP_INIT_SCRIPT} stop >/dev/null
+    ${LDAP_INIT_SCRIPT} stop &>/dev/null
 
     backup_file ${OPENLDAP_SLAPD_CONF} ${OPENLDAP_LDAP_CONF}
 

iRedMail/functions/packages.sh

             ALL_PKGS="${ALL_PKGS} mysql-server mysql-client"
             ENABLED_SERVICES="${ENABLED_SERVICES} mysql"
         elif [ X"${DISTRO}" == X"GENTOO" ]; then
-            ALL_PKGS="${ALL_PKGS} net-nds/openldap"
+            ALL_PKGS="${ALL_PKGS} openldap"
             ENABLED_SERVICES="${ENABLED_SERVICES} slapd"
             gentoo_add_use_flags 'net-nds/openldap' 'berkdb crypt ipv6 ssl tcpd overlays perl sasl syslog'
 
             # MySQL server and client.
-            ALL_PKGS="${ALL_PKGS} dev-db/mysql"
+            ALL_PKGS="${ALL_PKGS} mysql"
             ENABLED_SERVICES="${ENABLED_SERVICES} mysql"
             gentoo_add_use_flags 'dev-db/mysql' 'berkdb community perl ssl big-tables cluster'
         fi
             [ X"${USE_AWSTATS}" == X"YES" ] && ALL_PKGS="${ALL_PKGS} libapache2-mod-auth-mysql"
 
         elif [ X"${DISTRO}" == X'GENTOO' ]; then
-            ALL_PKGS="${ALL_PKGS} dev-db/mysql"
+            ALL_PKGS="${ALL_PKGS} mysql mod_auth_mysql"
             ENABLED_SERVICES="${ENABLED_SERVICES} mysql"
             gentoo_add_use_flags 'dev-db/mysql' 'berkdb community perl ssl big-tables cluster'
         fi
             # Postfix module
             ALL_PKGS="${ALL_PKGS} postfix-pgsql"
         elif [ X"${DISTRO}" == X'GENTOO' ]; then
-            ALL_PKGS="${ALL_PKGS} dev-db/postgresql-server"
+            ALL_PKGS="${ALL_PKGS} postgresql-server mod_auth_pgsql"
             ENABLED_SERVICES="${ENABLED_SERVICES} postgresql-${PGSQL_VERSION}"
             gentoo_add_use_flags 'dev-db/postgresql-server' 'nls pam doc perl python xml'
 
 
         ENABLED_SERVICES="${ENABLED_SERVICES} apache2"
     elif [ X"${DISTRO}" == X'GENTOO' ]; then
-        ALL_PKGS="${ALL_PKGS} www-servers/apache dev-lang/php"
+        ALL_PKGS="${ALL_PKGS} apache php"
         ENABLED_SERVICES="${ENABLED_SERVICES} apache2"
         gentoo_add_use_flags 'dev-libs/apr-util' 'ldap'
         gentoo_add_use_flags 'www-servers/apache' 'ssl doc ldap suexec'
     elif [ X"${DISTRO}" == X"DEBIAN" -o X"${DISTRO}" == X"UBUNTU" ]; then
         ALL_PKGS="${ALL_PKGS} postfix postfix-pcre"
     elif [ X"${DISTRO}" == X'GENTOO' ]; then
-        ALL_PKGS="${ALL_PKGS} mail-mta/postfix"
+        ALL_PKGS="${ALL_PKGS} postfix"
         gentoo_unmark_package 'mail-mta/ssmtp'
         gentoo_add_use_flags 'mail-mta/postfix' 'ipv6 pam ssl cdb dovecot-sasl hardened ldap ldap-bind mbox mysql postgres sasl'
     fi
 EOF
         fi
     elif [ X"${DISTRO}" == X'GENTOO' ]; then
-        ALL_PKGS="${ALL_PKGS} mail-filter/policyd"
+        ALL_PKGS="${ALL_PKGS} policyd"
         ENABLED_SERVICES="${ENABLED_SERVICES} policyd"
     fi
 
             fi
         fi
     elif [ X"${DISTRO}" == X'GENTOO' ]; then
-        ALL_PKGS="${ALL_PKGS} net-mail/dovecot"
+        ALL_PKGS="${ALL_PKGS} dovecot"
         DISABLED_SERVICES="${DISABLED_SERVICES} saslauthd"
         gentoo_add_use_flags 'net-mail/dovecot' 'bzip2 ipv6 maildir pam ssl zlib caps doc kerberos ldap managesieve mbox mdbox mysql postgres sdbox sieve sqlite suid'
     fi
         DISABLED_SERVICES="${DISABLED_SERVICES} spamassassin"
 
     elif [ X"${DISTRO}" == X'GENTOO' ]; then
-        ALL_PKGS="${ALL_PKGS} mail-filter/amavisd-new mail-filter/spamassassin app-antivirus/clamav net-mail/altermime"
+        ALL_PKGS="${ALL_PKGS} amavisd-new spamassassin clamav altermime"
         ENABLED_SERVICES="${ENABLED_SERVICES} ${AMAVISD_RC_SCRIPT_NAME} clamd"
         DISABLED_SERVICES="${DISABLED_SERVICES} spamd"
 
         ALL_PKGS="${ALL_PKGS} libmail-spf-perl"
 
     elif [ X"${DISTRO}" == X'GENTOO' ]; then
-        ALL_PKGS="${ALL_PKGS} dev-perl/Mail-SPF"
+        ALL_PKGS="${ALL_PKGS} Mail-SPF"
     fi
 
     # phpPgAdmin
         elif [ X"${DISTRO}" == X"DEBIAN" -o X"${DISTRO}" == X"UBUNTU" ]; then
             ALL_PKGS="${ALL_PKGS} phppgadmin"
         elif [ X"${DISTRO}" == X'GENTOO' ]; then
-            ALL_PKGS="${ALL_PKGS} dev-db/phppgadmin"
+            ALL_PKGS="${ALL_PKGS} phppgadmin"
         fi
     fi
 
         ALL_PKGS="${ALL_PKGS} libapache2-mod-wsgi python-mysqldb python-jinja2 python-netifaces python-webpy"
         [ X"${USE_IREDAPD}" != "YES" ] && ALL_PKGS="${ALL_PKGS} python-ldap"
     elif [ X"${DISTRO}" == X'GENTOO' ]; then
-        ALL_PKGS="${ALL_PKGS} dev-python/jinja dev-python/webpy dev-python/mysql-python"
-        [ X"${USE_IREDAPD}" != "YES" ] && ALL_PKGS="${ALL_PKGS} dev-python/python-ldap"
+        ALL_PKGS="${ALL_PKGS} jinja webpy mysql-python mod_wsgi"
+        [ X"${USE_IREDAPD}" != "YES" ] && ALL_PKGS="${ALL_PKGS} python-ldap"
 
         gentoo_add_use_flags 'dev-python/jinja' 'examples i18n vim-syntax'
     fi
         elif [ X"${DISTRO}" == X"DEBIAN" -o X"${DISTRO}" == X"UBUNTU" ]; then
             ALL_PKGS="${ALL_PKGS} awstats"
         elif [ X"${DISTRO}" == X'GENTOO' ]; then
-            ALL_PKGS="${ALL_PKGS} www-misc/awstats"
+            ALL_PKGS="${ALL_PKGS} awstats"
             gentoo_add_use_flags 'www-misc/awstats' 'ipv6 geoip'
         fi
     fi
             ALL_PKGS="${ALL_PKGS} fail2ban"
             ENABLED_SERVICES="${ENABLED_SERVICES} fail2ban"
         elif [ X"${DISTRO}" == X'GENTOO' ]; then
-            ALL_PKGS="${ALL_PKGS} net-analyzer/fail2ban"
+            ALL_PKGS="${ALL_PKGS} fail2ban"
             ENABLED_SERVICES="${ENABLED_SERVICES} fail2ban"
         fi
 
         ALL_PKGS="${ALL_PKGS} bzip2 acl patch cron tofrodos"
         ENABLED_SERVICES="${ENABLED_SERVICES} cron"
     elif [ X"${DISTRO}" == X'GENTOO' ]; then
-        ALL_PKGS="${ALL_PKGS} app-text/dos2unix"
+        ALL_PKGS="${ALL_PKGS} dos2unix"
     fi
     #### End Misc packages & 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 'crontab' 'vixie-cron'
 fi
 
 check_status_before_run track_iredmail_info