Commits

Zhang Huangbin  committed 3c19c4e

Improve Gentoo support and code cleanup.

  • Participants
  • Parent commits 04678f9

Comments (0)

Files changed (7)

File iRedMail/conf/apache_php

     export HTTPD_CONF_ROOT="/etc/apache2"
     export HTTPD_CONF="${HTTPD_CONF_ROOT}/httpd.conf"
     export HTTPD_CONF_DIR="${HTTPD_CONF_ROOT}/modules.d"
-    export HTTPD_SSL_CONF="${HTTPD_CONF_DIR}/vhosts.d/00_default_ssl_vhost.conf"
+    export HTTPD_SSL_CONF="${HTTPD_CONF_ROOT}/vhosts.d/00_default_ssl_vhost.conf"
     export HTTPD_WSGI_CONF="${HTTPD_CONF_DIR}/wsgi.conf"
 
     # Web data.

File iRedMail/conf/core

 
     ECHO_DEBUG "Checking necessary command/package: ${cmd}/${pkg} ..."
     for i in $(echo $PATH|sed 's/:/ /g'); do
-        [ -x $i/${cmd} ] && export HAS_CMD='YES'
+        [ -x $i/${cmd} ] && export HAS_CMD='YES' && break
     done
 
     if [ X"${HAS_CMD}" != X'YES' ]; then
         eval ${install_pkg} ${pkg}
         if [ X"$?" != X"0" ]; then
             ECHO_ERROR "Please install package ${pkg} first." && exit 255
-        else
-            :
         fi
-    else
-        :
     fi
 
     unset HAS_CMD

File iRedMail/conf/global

     export CRON_SPOOL_DIR='/var/spool/cron/crontabs'
 
     # Directory /etc/sysconfig/ on RHEL/CentOS.
-    export ETC_SYSCONFIG_DIR='/etc/sysconfig'
+    export ETC_SYSCONFIG_DIR='/etc/conf.d'
 
     # Iptables rule file.
     export IPTABLES_CONFIG="${ETC_SYSCONFIG_DIR}/iptables"
     # Directory used to store SSL/TLS key/cert file.
     export SSL_FILE_DIR="/etc/ssl"
 
-    # Yum repository related.
-    export YUM_REPOS_DIR='/etc/yum.repos.d'
-    export LOCAL_REPO_NAME="${PROG_NAME}"
-    export LOCAL_REPO_FILE="${YUM_REPOS_DIR}/${LOCAL_REPO_NAME}.repo"
-
     # Override default value.
     export PKG_DIALOG="dev-util/dialog"
     export PKG_BZIP2="app-arch/bzip2"

File iRedMail/conf/openldap

     export OPENLDAP_CONF_ROOT="/etc/openldap"
     export OPENLDAP_DB_CONFIG_SAMPLE="${OPENLDAP_CONF_ROOT}/DB_CONFIG.example"
 
-    export OPENLDAP_SYSCONFIG_CONF="${ETC_SYSCONFIG_DIR}/ldap"
+    export OPENLDAP_SYSCONFIG_CONF="${ETC_SYSCONFIG_DIR}/slapd"
 
     # RC script.
     export LDAP_INIT_SCRIPT="${DIR_RC_SCRIPTS}/${LDAP_RC_SCRIPT_NAME}"
     # Module related.
     export OPENLDAP_MODULE_PATH='/usr/lib/openldap/openldap'
 
+    # Override default path
+    export OPENLDAP_DATA_DIR='/var/lib/openldap-data'
+
 elif [ X"${DISTRO}" == X"FREEBSD" ]; then
     # OpenLDAP version.
     export OPENLDAP_VERSION='2.4'

File iRedMail/functions/cleanup.sh

 cleanup_remove_sendmail()
 {
     # Remove sendmail.
-    eval ${LIST_ALL_PKGS} | grep sendmail >/dev/null 2>&1
+    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]"
             ;;
     esac
 
-    if [ X"${KERNEL_NAME}" == X"Linux" ]; then
-        if [ X"${DISTRO}" != X"SUSE" ]; then
-            # Restarting iptables before restarting fail2ban.
-            ENABLED_SERVICES="iptables ${ENABLED_SERVICES}"
-        fi
+    if [ X"${DISTRO}" != X"SUSE" ]; then
+        # Restarting iptables before restarting fail2ban.
+        ENABLED_SERVICES="iptables ${ENABLED_SERVICES}"
     fi
 
     echo 'export status_cleanup_replace_iptables_rule="DONE"' >> ${STATUS_FILE}

File iRedMail/functions/openldap.sh

 
     elif [ X"${DISTRO}" == X'GENTOO' ]; then
         # Comment out default option which uses slapd.d.
-        perl -pi -e 's/^(OPTS=.*)/#${1}/' ${OPENLDAP_SYSCONFIG_CONF}/${LDAP_RC_SCRIPT_NAME}
+        perl -pi -e 's/^(OPTS=.*)/#${1}/' ${OPENLDAP_SYSCONFIG_CONF}
 
         # Enable slapd.conf instead of slapd.d.
-        cat >> ${ETC_SYSCONFIG_DIR}/slapd <<EOF
+        cat >> ${OPENLDAP_SYSCONFIG_CONF} <<EOF
 OPTS="-f ${OPENLDAP_SLAPD_CONF} -h 'ldaps:// ldap:// ldapi://%2fvar%2frun%2fopenldap%2fslapd.sock'"
 EOF
     fi

File iRedMail/pkgs/get_all.sh

 
 prepare_dirs
 
-# Create yum repository.
 if [ X"${DISTRO}" == X"RHEL" ]; then
+    # Check required commands, install related package if command doesn't exist.
     check_pkg ${BIN_WHICH} ${PKG_WHICH} && \
     check_pkg ${BIN_WGET} ${PKG_WGET} && \
+
+    # Create yum repository.
     create_repo_rhel
 elif [ X"${DISTRO}" == X"SUSE" ]; then
     create_repo_suse
         ECHO_INFO "Execute 'apt-get update'..."
         ${APTGET} update
     fi
+elif [ X"${DISTRO}" == X'GENTOO' ]; then
+    # qlist is used to list all installed portages (qlist --installed).
+    check_pkg 'qlist' 'portage-utils'
 fi
 
 check_status_before_run track_iredmail_info