Commits

Zhang Huangbin committed 4f8db54

Improve support for Amazone EC2 CentOS instance.

  • Participants
  • Parent commits 26fdab4

Comments (0)

Files changed (4)

iRedMail/conf/global

     # Directory of RC scripts.
     export DIR_RC_SCRIPTS='/etc/init.d'
 
+    # Amazon EC2 (CentOS) support.
+    if [ -f /etc/system-release -a -f /etc/yum.repos.d/amzn-main.repo ]; then
+        if [ ! -f /etc/redhat-release ]; then
+            # Identified as CentOS 6.
+            # Note: Amazon AMI it uses 'latest' as release version number, we
+            # have to use the latest CentOS version for it.
+            echo 'CentOS Linux 6' > /etc/redhat-release
+        fi
+        export YUM='yum -d 2 --disableplugin=priorities'
+    fi
+
     if [ -f /etc/redhat-release ]; then
         # RHEL/CentOS
         export DISTRO='RHEL'

iRedMail/functions/cluebringer.sh

     [ X"${DISTRO}" == X'FREEBSD' ] && \
         cp /usr/local/share/policyd2/contrib/httpd/cluebringer-httpd.conf ${CLUEBRINGER_WEBUI_CONF}
 
-    # Make Cluebringer accessible via HTTPS.
-    perl -pi -e 's#^(\s*</VirtualHost>)#Alias /cluebringer "$ENV{CLUEBRINGER_HTTPD_ROOT}/"\n${1}#' ${HTTPD_SSL_CONF}
-
     # Configure webui.
     if [ X"${BACKEND}" == X'OPENLDAP' -o X"${BACKEND}" == X'MYSQL' ]; then
         perl -pi -e 's#(.DB_DSN=).*#${1}"mysql:host=$ENV{SQL_SERVER};dbname=$ENV{CLUEBRINGER_DB_NAME}";#' ${CLUEBRINGER_WEBUI_CONF}
     perl -pi -e 's/.*(.DB_PASS=).*/${1}"$ENV{CLUEBRINGER_DB_PASSWD}";/' ${CLUEBRINGER_WEBUI_CONF}
     perl -pi -e 's#(.DB_PASS=).*#${1}"$ENV{CLUEBRINGER_DB_PASSWD}";#' ${CLUEBRINGER_WEBUI_CONF}
 
-    cat > ${CLUEBRINGER_HTTPD_CONF} <<EOF
+    # Make Cluebringer accessible via HTTPS.
+    if [ X"${USE_APACHE}" == X'YES' ]; then
+        perl -pi -e 's#^(\s*</VirtualHost>)#Alias /cluebringer "$ENV{CLUEBRINGER_HTTPD_ROOT}/"\n${1}#' ${HTTPD_SSL_CONF}
+
+        cat > ${CLUEBRINGER_HTTPD_CONF} <<EOF
 ${CONF_MSG}
 #
 # SECURITY WARNING:
     AuthName "Authorization Required"
 EOF
 
-    ECHO_DEBUG "Setup user auth for cluebringer webui: ${CLUEBRINGER_HTTPD_CONF}."
-    if [ X"${BACKEND}" == X"OPENLDAP" ]; then
-        # Use LDAP auth.
-        cat >> ${CLUEBRINGER_HTTPD_CONF} <<EOF
+        ECHO_DEBUG "Setup user auth for cluebringer webui: ${CLUEBRINGER_HTTPD_CONF}."
+        if [ X"${BACKEND}" == X"OPENLDAP" ]; then
+            # Use LDAP auth.
+            cat >> ${CLUEBRINGER_HTTPD_CONF} <<EOF
     AuthBasicProvider ldap
     AuthzLDAPAuthoritative   Off
 
     AuthLDAPBindPassword "${LDAP_BINDPW}"
 EOF
 
-        [ X"${LDAP_USE_TLS}" == X"YES" ] && \
-            perl -pi -e 's#(AuthLDAPUrl.*)(ldap://)(.*)#${1}ldaps://${3}#' ${CLUEBRINGER_HTTPD_CONF}
+            [ X"${LDAP_USE_TLS}" == X"YES" ] && \
+                perl -pi -e 's#(AuthLDAPUrl.*)(ldap://)(.*)#${1}ldaps://${3}#' ${CLUEBRINGER_HTTPD_CONF}
 
-        # Ubuntu 13.10 ships Apache-2.4 which removes directive 'AuthzLDAPAuthoritative'.
-        [ X"${DISTRO}" == X'UBUNTU' -a X"${DISTRO_CODENAME}" != X'precise' ] && \
-            perl -pi -e 's/(.*)(AuthzLDAPAuthoritative.*)/${1}#${2}/g' ${CLUEBRINGER_HTTPD_CONF}
+            # Ubuntu 14.04 ships Apache-2.4 which removes directive 'AuthzLDAPAuthoritative'.
+            [ X"${DISTRO}" == X'UBUNTU' -a X"${DISTRO_CODENAME}" != X'precise' ] && \
+                perl -pi -e 's/(.*)(AuthzLDAPAuthoritative.*)/${1}#${2}/g' ${CLUEBRINGER_HTTPD_CONF}
 
-    elif [ X"${BACKEND}" == X"MYSQL" ]; then
-        # Use mod_auth_mysql.
-        if [ X"${DISTRO}" == X"RHEL" -o X"${DISTRO}" == X"FREEBSD" ]; then
-            cat >> ${CLUEBRINGER_HTTPD_CONF} <<EOF
+        elif [ X"${BACKEND}" == X"MYSQL" ]; then
+            # Use mod_auth_mysql.
+            if [ X"${DISTRO}" == X"RHEL" -o X"${DISTRO}" == X"FREEBSD" ]; then
+                cat >> ${CLUEBRINGER_HTTPD_CONF} <<EOF
     AuthMYSQLEnable On
     AuthMySQLHost ${SQL_SERVER}
     AuthMySQLPort ${SQL_SERVER_PORT}
     AuthMySQLPasswordField password
 EOF
 
-            # FreeBSD special.
-            if [ X"${DISTRO}" == X"FREEBSD" ]; then
-                # Enable mod_auth_mysql module in httpd.conf.
-                perl -pi -e 's/^#(LoadModule.*mod_auth_mysql.*)/${1}/' ${HTTPD_CONF}
-                echo "AuthBasicAuthoritative Off" >> ${CLUEBRINGER_HTTPD_CONF}
-            fi
+                # FreeBSD special.
+                if [ X"${DISTRO}" == X"FREEBSD" ]; then
+                    # Enable mod_auth_mysql module in httpd.conf.
+                    perl -pi -e 's/^#(LoadModule.*mod_auth_mysql.*)/${1}/' ${HTTPD_CONF}
+                    echo "AuthBasicAuthoritative Off" >> ${CLUEBRINGER_HTTPD_CONF}
+                fi
 
-        elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
-            cat >> ${CLUEBRINGER_HTTPD_CONF} <<EOF
+            elif [ X"${DISTRO}" == X'DEBIAN' -o X"${DISTRO}" == X'UBUNTU' ]; then
+                cat >> ${CLUEBRINGER_HTTPD_CONF} <<EOF
     AuthMYSQL on
     AuthBasicAuthoritative Off
     AuthUserFile /dev/null
     AuthMySQL_Encryption_Types Crypt_MD5
     Auth_MySQL_Authoritative On
 EOF
-            cat >> ${HTTPD_CONF} <<EOF
+
+                cat >> ${HTTPD_CONF} <<EOF
 # MySQL auth (libapache2-mod-auth-apache2).
 # Global config of MySQL server, username, password.
 Auth_MySQL_Info ${SQL_SERVER} ${VMAIL_DB_BIND_USER} ${VMAIL_DB_BIND_PASSWD}
 Auth_MySQL_General_DB ${VMAIL_DB}
 EOF
 
-            # Set file permission.
-            chmod 0600 ${CLUEBRINGER_HTTPD_CONF}
+                # Set file permission.
+                chmod 0600 ${CLUEBRINGER_HTTPD_CONF}
+            fi  # DISTRO
 
-        fi  # DISTRO
-
-    elif [ X"${BACKEND}" == X"PGSQL" ]; then
-        # mod_auth_pgsql
-        cat >> ${CLUEBRINGER_HTTPD_CONF} <<EOF
+        elif [ X"${BACKEND}" == X"PGSQL" ]; then
+            # mod_auth_pgsql
+            cat >> ${CLUEBRINGER_HTTPD_CONF} <<EOF
     Auth_PG_authoritative on
     Auth_PG_host ${SQL_SERVER}
     Auth_PG_port ${SQL_SERVER_PORT}
     Auth_PG_hash_type CRYPT
 EOF
 
-        # Set file permission.
-        chmod 0600 ${CLUEBRINGER_HTTPD_CONF}
-
+            # Set file permission.
+            chmod 0600 ${CLUEBRINGER_HTTPD_CONF}
     fi
     # END BACKEND
 
 </Directory>
 EOF
 
-    if [ X"${DISTRO}" == X'UBUNTU' ]; then
-        a2enconf cluebringer &>/dev/null
+        if [ X"${DISTRO}" == X'UBUNTU' ]; then
+            a2enconf cluebringer &>/dev/null
+        fi
     fi
 
     echo 'export status_cluebringer_webui_config="DONE"' >> ${STATUS_FILE}

iRedMail/functions/iredadmin.sh

         chown -R ${HTTPD_USER}:${HTTPD_GROUP} settings.py
     fi
 
-    backup_file ${IREDADMIN_HTTPD_CONF}
-    ECHO_DEBUG "Create directory alias for iRedAdmin."
+    if [ X"${USE_APACHE}" == X'YES' ]; then
+        backup_file ${IREDADMIN_HTTPD_CONF}
+        ECHO_DEBUG "Create directory alias for iRedAdmin."
 
-    if [ X"${DISTRO}" == X'OPENBSD' ]; then
-        # Create directory alias.
-        perl -pi -e 's#^(\s*</VirtualHost>)#Alias /iredadmin/static "$ENV{IREDADMIN_HTTPD_ROOT_SYMBOL_LINK}/static"\n${1}#' ${HTTPD_SSL_CONF}
-        perl -pi -e 's#^(\s*</VirtualHost>)#ScriptAlias /iredadmin "$ENV{IREDADMIN_HTTPD_ROOT_SYMBOL_LINK}/iredadmin.py"\n${1}#' ${HTTPD_SSL_CONF}
+        if [ X"${DISTRO}" == X'OPENBSD' ]; then
+            # Create directory alias.
+            perl -pi -e 's#^(\s*</VirtualHost>)#Alias /iredadmin/static "$ENV{IREDADMIN_HTTPD_ROOT_SYMBOL_LINK}/static"\n${1}#' ${HTTPD_SSL_CONF}
+            perl -pi -e 's#^(\s*</VirtualHost>)#ScriptAlias /iredadmin "$ENV{IREDADMIN_HTTPD_ROOT_SYMBOL_LINK}/iredadmin.py"\n${1}#' ${HTTPD_SSL_CONF}
 
-        # There's no wsgi module for Apache available on OpenBSD, so
-        # iRedAdmin runs as CGI program.
-        cat > ${IREDADMIN_HTTPD_CONF} <<EOF
+            # There's no wsgi module for Apache available on OpenBSD, so
+            # iRedAdmin runs as CGI program.
+            cat > ${IREDADMIN_HTTPD_CONF} <<EOF
 AddType text/html .py
 AddHandler cgi-script .py
 
     Allow from all
 </Directory>
 EOF
-    else
-        perl -pi -e 's#^(\s*</VirtualHost>)#Alias /iredadmin/static "$ENV{IREDADMIN_HTTPD_ROOT_SYMBOL_LINK}/static/"\n${1}#' ${HTTPD_SSL_CONF}
-        perl -pi -e 's#^(\s*</VirtualHost>)#WSGIScriptAlias /iredadmin "$ENV{IREDADMIN_HTTPD_ROOT_SYMBOL_LINK}/iredadmin.py/"\n${1}#' ${HTTPD_SSL_CONF}
+        else
+            perl -pi -e 's#^(\s*</VirtualHost>)#Alias /iredadmin/static "$ENV{IREDADMIN_HTTPD_ROOT_SYMBOL_LINK}/static/"\n${1}#' ${HTTPD_SSL_CONF}
+            perl -pi -e 's#^(\s*</VirtualHost>)#WSGIScriptAlias /iredadmin "$ENV{IREDADMIN_HTTPD_ROOT_SYMBOL_LINK}/iredadmin.py/"\n${1}#' ${HTTPD_SSL_CONF}
 
-        # iRedAdmin runs as WSGI application with Apache + mod_wsgi
-        cat > ${IREDADMIN_HTTPD_CONF} <<EOF
+            # iRedAdmin runs as WSGI application with Apache + mod_wsgi
+            cat > ${IREDADMIN_HTTPD_CONF} <<EOF
 WSGISocketPrefix /var/run/wsgi
 WSGIDaemonProcess iredadmin user=${IREDADMIN_USER_NAME} threads=15
 WSGIProcessGroup ${IREDADMIN_GROUP_NAME}
     Allow from all
 </Directory>
 EOF
-    fi
+        fi
 
-    # Enable Apache module config file on Ubuntu 13.10.
-    if [ X"${DISTRO}" == X'UBUNTU' ]; then
-        a2enconf iredadmin &>/dev/null
+        # Enable Apache module config file on Ubuntu 14.04.
+        if [ X"${DISTRO}" == X'UBUNTU' ]; then
+            a2enconf iredadmin &>/dev/null
+        fi
     fi
 
     ECHO_DEBUG "Import iredadmin database template."

iRedMail/functions/packages.sh

     # Amavisd-new & ClamAV & Altermime.
     ENABLED_SERVICES="${ENABLED_SERVICES} ${CLAMAV_CLAMD_RC_SCRIPT_NAME} ${AMAVISD_RC_SCRIPT_NAME}"
     if [ X"${DISTRO}" == X"RHEL" ]; then
-        ALL_PKGS="${ALL_PKGS} clamd clamav clamav-db spamassassin altermime perl-LDAP perl-Mail-SPF amavisd-new"
+        ALL_PKGS="${ALL_PKGS} clamd clamav-db spamassassin altermime perl-LDAP perl-Mail-SPF amavisd-new"
 
         if [ X"${BACKEND}" == X'PGSQL' ]; then
             ALL_PKGS="${ALL_PKGS} perl-DBD-Pg"