Commits

Zhang Huangbin  committed f6a9ece

Code cleanup.

  • Participants
  • Parent commits 13dafc2

Comments (0)

Files changed (9)

File iRedMail/conf/core

 # along with iRedMail.  If not, see <http://www.gnu.org/licenses/>.
 #---------------------------------------------------------------------
 
+ECHO_INFO()
+{
+    if [ X"$1" == X"-n" ]; then
+        shift 1
+        if [ X"${TERM}" == X"xterm" -o X"${TERM}" == X"linux" -o X"${TERM}" == X"pcconsole" ]; then
+            echo -ne "\033[42m${INFO_FLAG}\033[0m $@"
+        else
+            echo -ne "${INFO_FLAG} $@"
+        fi
+    else
+        if [ X"${TERM}" == X"xterm" -o X"${TERM}" == X"linux" -o X"${TERM}" == X"pcconsole" ]; then
+            echo -e "\033[42m${INFO_FLAG}\033[0m $@"
+        else
+            echo -e "${INFO_FLAG} $@"
+        fi
+    fi
+}
+
+ECHO_QUESTION()
+{
+    if [ X"$1" == X"-n" ]; then
+        shift 1
+        if [ X"${TERM}" == X"xterm" -o X"${TERM}" == X"linux" -o X"${TERM}" == X"pcconsole" ]; then
+            echo -ne "\033[45m${QUESTION_FLAG}\033[0m $@"
+        else
+            echo -ne "${QUESTION_FLAG} $@"
+        fi
+    else
+        if [ X"${TERM}" == X"xterm" -o X"${TERM}" == X"linux" -o X"${TERM}" == X"pcconsole" ]; then
+            echo -e "\033[45m${QUESTION_FLAG}\033[0m $@"
+        else
+            echo -e "${QUESTION_FLAG} $@"
+        fi
+    fi
+}
+
+ECHO_ERROR()
+{
+    if [ X"$1" == X"-n" ]; then
+        shift 1
+        if [ X"${TERM}" == X"xterm" -o X"${TERM}" == X"linux" -o X"${TERM}" == X"pcconsole" ]; then
+            echo -ne "\033[41m${ERROR_FLAG}\033[0m $@"
+        else
+            echo -ne "${ERROR_FLAG} $@"
+        fi
+    else
+        if [ X"${TERM}" == X"xterm" -o X"${TERM}" == X"linux" -o X"${TERM}" == X"pcconsole" ]; then
+            echo -e "\033[41m${ERROR_FLAG}\033[0m $@"
+        else
+            echo -e "${ERROR_FLAG} $@"
+        fi
+    fi
+}
+
+ECHO_DEBUG()
+{
+    if [ X"${DEBUG}" == X"YES" ]; then
+        if [ X"$1" == X"-n" ]; then
+            shift 1
+            if [ X"${TERM}" == X"xterm" -o X"${TERM}" == X"linux" -o X"${TERM}" == X"pcconsole" ]; then
+                echo -ne "\033[42m${DEBUG_FLAG}\033[0m $@"
+            else
+                echo -ne "${DEBUG_FLAG} $@"
+            fi
+        else
+            if [ X"${TERM}" == X"xterm" -o X"${TERM}" == X"linux" -o X"${TERM}" == X"pcconsole" ]; then
+                echo -e "\033[42m${DEBUG_FLAG}\033[0m $@"
+            else
+                echo -e "${DEBUG_FLAG} $@"
+            fi
+        fi
+    else
+        :
+    fi
+}
+
 backup_file()
 {
     # Usage: backup_file file1 [file2 file3 ... fileN]

File iRedMail/conf/functions

-#!/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/>.
-#---------------------------------------------------------------------
-
-ECHO_INFO()
-{
-    if [ X"$1" == X"-n" ]; then
-        shift 1
-        if [ X"${TERM}" == X"xterm" -o X"${TERM}" == X"linux" -o X"${TERM}" == X"pcconsole" ]; then
-            echo -ne "\033[42m${INFO_FLAG}\033[0m $@"
-        else
-            echo -ne "${INFO_FLAG} $@"
-        fi
-    else
-        if [ X"${TERM}" == X"xterm" -o X"${TERM}" == X"linux" -o X"${TERM}" == X"pcconsole" ]; then
-            echo -e "\033[42m${INFO_FLAG}\033[0m $@"
-        else
-            echo -e "${INFO_FLAG} $@"
-        fi
-    fi
-}
-
-ECHO_QUESTION()
-{
-    if [ X"$1" == X"-n" ]; then
-        shift 1
-        if [ X"${TERM}" == X"xterm" -o X"${TERM}" == X"linux" -o X"${TERM}" == X"pcconsole" ]; then
-            echo -ne "\033[45m${QUESTION_FLAG}\033[0m $@"
-        else
-            echo -ne "${QUESTION_FLAG} $@"
-        fi
-    else
-        if [ X"${TERM}" == X"xterm" -o X"${TERM}" == X"linux" -o X"${TERM}" == X"pcconsole" ]; then
-            echo -e "\033[45m${QUESTION_FLAG}\033[0m $@"
-        else
-            echo -e "${QUESTION_FLAG} $@"
-        fi
-    fi
-}
-
-ECHO_ERROR()
-{
-    if [ X"$1" == X"-n" ]; then
-        shift 1
-        if [ X"${TERM}" == X"xterm" -o X"${TERM}" == X"linux" -o X"${TERM}" == X"pcconsole" ]; then
-            echo -ne "\033[41m${ERROR_FLAG}\033[0m $@"
-        else
-            echo -ne "${ERROR_FLAG} $@"
-        fi
-    else
-        if [ X"${TERM}" == X"xterm" -o X"${TERM}" == X"linux" -o X"${TERM}" == X"pcconsole" ]; then
-            echo -e "\033[41m${ERROR_FLAG}\033[0m $@"
-        else
-            echo -e "${ERROR_FLAG} $@"
-        fi
-    fi
-}
-
-ECHO_DEBUG()
-{
-    if [ X"${DEBUG}" == X"YES" ]; then
-        if [ X"$1" == X"-n" ]; then
-            shift 1
-            if [ X"${TERM}" == X"xterm" -o X"${TERM}" == X"linux" -o X"${TERM}" == X"pcconsole" ]; then
-                echo -ne "\033[42m${DEBUG_FLAG}\033[0m $@"
-            else
-                echo -ne "${DEBUG_FLAG} $@"
-            fi
-        else
-            if [ X"${TERM}" == X"xterm" -o X"${TERM}" == X"linux" -o X"${TERM}" == X"pcconsole" ]; then
-                echo -e "\033[42m${DEBUG_FLAG}\033[0m $@"
-            else
-                echo -e "${DEBUG_FLAG} $@"
-            fi
-        fi
-    else
-        :
-    fi
-}

File iRedMail/conf/global

 
 export PROG_NAME='iRedMail'
 export PROG_NAME_LOWERCASE='iredmail'
-export PROG_VERSION='0.7.4'
+export PROG_VERSION='0.8.0-beta'
 
 # -----------------
 # ---- Generic ----
             # Debian 5
             export DISTRO_VERSION='5'
             export DISTRO_CODENAME='lenny'
-        elif grep '^6\.' /etc/debian_version &>/dev/null
+        elif grep '^6\.' /etc/debian_version &>/dev/null; then
             # Debian 6
             export DISTRO_VERSION='6'
             export DISTRO_CODENAME='squeeze'

File iRedMail/dialog/config_via_dialog.sh

 # along with iRedMail.  If not, see <http://www.gnu.org/licenses/>.
 #---------------------------------------------------------------------
 
-# Note: config file will be sourced in 'conf/functions', check_env().
+# Note: config file will be sourced in 'conf/core', check_env().
 
 . ${CONF_DIR}/global
-. ${CONF_DIR}/functions
 . ${CONF_DIR}/core
 . ${CONF_DIR}/openldap
 . ${CONF_DIR}/roundcube

File iRedMail/functions/cleanup.sh

 # -------------------------------------------
 # Misc.
 # -------------------------------------------
-track_iredmail_info()
-{
-    # Help track basic information, used to help iRedMail team understand
-    # which Linux/BSD distribution we should take more care of.
-    # iRedMail version number, OS distribution, release version, code name, backend.
-    ${FETCH_CMD} "http://iredmail.org/version/check.py/iredmail_os?iredmail_version=${PROG_VERSION}&arch=${ARCH}&distro=${DISTRO}&distro_version=${DISTRO_VERSION}&distro_code_name=${DISTRO_CODENAME}&backend=${BACKEND}" &>/dev/null
-
-    rm -f iredmail_os* &>/dev/null
-    echo 'export status_track_iredmail_info="DONE"' >> ${STATUS_FILE}
-}
-
 cleanup_disable_selinux()
 {
     ECHO_INFO "Disable SELinux in /etc/selinux/config."

File iRedMail/functions/packages.sh

         elif [ X"${DISTRO}" == X"DEBIAN" -o X"${DISTRO}" == X"UBUNTU" ]; then
             ALL_PKGS="${ALL_PKGS} postfix-ldap slapd ldap-utils libnet-ldap-perl"
             ENABLED_SERVICES="${ENABLED_SERVICES} slapd"
-        else
-            :
         fi
     elif [ X"${BACKEND}" == X"MYSQL" ]; then
         # MySQL server & client.
 
             # For Awstats.
             [ X"${USE_AWSTATS}" == X"YES" ] && ALL_PKGS="${ALL_PKGS} libapache2-mod-auth-mysql"
-        else
-            :
+        fi
+    elif [ X"${BACKEND}" == X"PGSQL" ]; then
+        # MySQL server & client.
+        if [ X"${DISTRO}" == X"RHEL" ]; then
+            ALL_PKGS="${ALL_PKGS} postgresql-server"
+
+        elif [ X"${DISTRO}" == X"SUSE" ]; then
+            ALL_PKGS="${ALL_PKGS} postgresql-server"
+
+        elif [ X"${DISTRO}" == X"DEBIAN" -o X"${DISTRO}" == X"UBUNTU" ]; then
+            ALL_PKGS="${ALL_PKGS} postgresql postgresql-client"
         fi
     else
         :
         DISABLED_SERVICES="${DISABLED_SERVICES} saslauthd"
 
     elif [ X"${DISTRO}" == X"SUSE" ]; then
-        ALL_PKGS="${ALL_PKGS} dovecot12 dovecot12-backend-mysql"
+        ALL_PKGS="${ALL_PKGS} dovecot12"
+
+        if [ X"${BACKEND}" == X"MYSQL" ]; then
+            ALL_PKGS="${ALL_PKGS} dovecot12-backend-mysql"
+        elif [ X"${BACKEND}" == X"PGSQL" ]; then
+            ALL_PKGS="${ALL_PKGS} dovecot12-backend-pgsql"
+        fi
 
     elif [ X"${DISTRO}" == X"DEBIAN" -o X"${DISTRO}" == X"UBUNTU" ]; then
         ALL_PKGS="${ALL_PKGS} dovecot-imapd dovecot-pop3d"

File iRedMail/iRedMail.sh

 export TOOLS_DIR="${ROOTDIR}/tools"
 
 . ${CONF_DIR}/global
-. ${CONF_DIR}/functions
 . ${CONF_DIR}/core
 
 # Check downloaded packages, pkg repository.

File iRedMail/pkgs/get_all.sh

 CONF_DIR="${ROOTDIR}/../conf"
 
 . ${CONF_DIR}/global
-. ${CONF_DIR}/functions
 . ${CONF_DIR}/core
 . ${CONF_DIR}/iredadmin
 
         ${APTGET} update
     fi
 }
+
+track_iredmail_info()
+{
+    # Help track basic information, used to help iRedMail team understand
+    # which Linux/BSD distribution we should take more care of.
+    # iRedMail version number, OS distribution, release version, code name, backend.
+    ${FETCH_CMD} "http://iredmail.org/version/check.py/iredmail_os?iredmail_version=${PROG_VERSION}&arch=${ARCH}&distro=${DISTRO}&distro_version=${DISTRO_VERSION}&distro_code_name=${DISTRO_CODENAME}" &>/dev/null
+
+    rm -f iredmail_os* &>/dev/null
+    echo 'export status_track_iredmail_info="DONE"' >> ${STATUS_FILE}
+}
+
 echo_end_msg()
 {
     cat <<EOF
     fi
 fi
 
+check_status_before_run track_iredmail_info
 fetch_misc && \
 check_md5 && \
 check_pkg ${BIN_DIALOG} ${PKG_DIALOG} && \

File iRedMail/tools/create_mail_user_OpenLDAP.sh

 
 # Source functions.
 . ../conf/global
-. ../conf/functions
 . ../conf/core
 
 # ----------------------------------------------