Zhang Huangbin avatar Zhang Huangbin committed f37c1f8

Code cleanup.

Comments (0)

Files changed (5)

iRedMail/conf/global

 # PGSQL server
 export PGSQL_SERVER="${PGSQL_SERVER:=${LOCAL_ADDRESS}}"
 export PGSQL_SERVER_PORT="${PGSQL_SERVER_PORT:=5432}"
+
+export USE_LOCAL_MYSQL_SERVER='YES'
+if [ X"${MYSQL_SERVER}" == X"${LOCAL_ADDRESS}" ]; then
+    export USE_LOCAL_MYSQL_SERVER='NO'
+fi
+
 # Dovecot: POP3, IMAP, managesieve
 export IMAP_SERVER="${LOCAL_ADDRESS}"
 export MANAGESIEVE_BIND_HOST="${LOCAL_ADDRESS}"

iRedMail/dialog/mysql_config.sh

     ${DIALOG} \
     --title "Password for MySQL administrator: ${MYSQL_ROOT_USER}" \
     ${PASSWORDBOX} "\
-Please specify password for MySQL administrator: ${MYSQL_ROOT_USER}
+Please specify password for MySQL administrator ${MYSQL_ROOT_USER} on server
+${MYSQL_SERVER}.
 
 WARNING:
 

iRedMail/functions/backend.sh

         check_status_before_run ldap_server_config
 
         # Initialize MySQL database server.
+        mysql_generate_defauts_file_root
         check_status_before_run mysql_initialize
     elif [ X"${BACKEND}" == X"MYSQL" ]; then
-        check_status_before_run mysql_initialize
+        ECHO_INFO "Configure MySQL database server."
+        mysql_generate_defauts_file_root
+        if [ X"${USE_LOCAL_MYSQL_SERVER}" == X'YES' ]; then
+            check_status_before_run mysql_initialize
+        fi
         check_status_before_run mysql_import_vmail_users
     elif [ X"${BACKEND}" == X"PGSQL" ]; then
         check_status_before_run pgsql_initialize

iRedMail/functions/mysql.sh

 # -------------------------------------------------------
 # -------------------- MySQL ----------------------------
 # -------------------------------------------------------
+mysql_generate_defauts_file_root()
+{
+    ECHO_DEBUG "Generate temporary defauts file for MySQL client option --defaults-file: ${MYSQL_DEFAULTS_FILE_ROOT}."
+    cat >> ${MYSQL_DEFAULTS_FILE_ROOT} <<EOF
+[client]
+host=${MYSQL_SERVER}
+port=${MYSQL_SERVER_PORT}
+user=${MYSQL_ROOT_USER}
+password=${MYSQL_ROOT_PASSWD}
+EOF
+}
+
 mysql_initialize()
 {
-    ECHO_INFO "Configure MySQL database server." 
-
     ECHO_DEBUG "Starting MySQL."
 
     # Initial MySQL database first
     ECHO_DEBUG "Sleep 5 seconds for MySQL daemon initialize ..."
     sleep 5
 
-    # Generate temporary file for MySQL client option --defaults-file.
-    cat >> ${MYSQL_DEFAULTS_FILE_ROOT} <<EOF
-[client]
-host=${MYSQL_SERVER}
-port=${MYSQL_SERVER_PORT}
-user=${MYSQL_ROOT_USER}
-password=${MYSQL_ROOT_PASSWD}
-EOF
-
     if [ X"${LOCAL_ADDRESS}" == X'127.0.0.1' ]; then
         # Try to access without password, set a password if it's empty.
         mysql -u${MYSQL_ROOT_USER} -e "show databases" &>/dev/null

iRedMail/functions/packages.sh

         # MySQL server & client.
         ENABLED_SERVICES="${ENABLED_SERVICES} ${MYSQL_RC_SCRIPT_NAME}"
         if [ X"${DISTRO}" == X"RHEL" ]; then
-            if [ X"${MYSQL_SERVER}" == X"${LOCAL_ADDRESS}" ]; then
+            if [ X"${USE_LOCAL_MYSQL_SERVER}" == X'YES' ]; then
                 ALL_PKGS="${ALL_PKGS} mysql-server${PKG_ARCH}"
             fi
             ALL_PKGS="${ALL_PKGS} mysql${PKG_ARCH}"
             [ X"${USE_AWSTATS}" == X"YES" ] && ALL_PKGS="${ALL_PKGS} mod_auth_mysql${PKG_ARCH}"
 
         elif [ X"${DISTRO}" == X"SUSE" ]; then
-            if [ X"${MYSQL_SERVER}" == X"${LOCAL_ADDRESS}" ]; then
+            if [ X"${USE_LOCAL_MYSQL_SERVER}" == X'YES' ]; then
                 ALL_PKGS="${ALL_PKGS} mysql-community-server-client"
             fi
             ALL_PKGS="${ALL_PKGS} mysql-community-server-client"
 
         elif [ X"${DISTRO}" == X"DEBIAN" -o X"${DISTRO}" == X"UBUNTU" ]; then
             # MySQL server and client.
-            if [ X"${MYSQL_SERVER}" == X"${LOCAL_ADDRESS}" ]; then
+            if [ X"${USE_LOCAL_MYSQL_SERVER}" == X'YES' ]; then
                 ALL_PKGS="${ALL_PKGS} mysql-server"
             fi
             ALL_PKGS="${ALL_PKGS} mysql-client postfix-mysql libapache2-mod-auth-mysql"
 
         elif [ X"${DISTRO}" == X'OPENBSD' ]; then
-            if [ X"${MYSQL_SERVER}" == X"${LOCAL_ADDRESS}" ]; then
+            if [ X"${USE_LOCAL_MYSQL_SERVER}" == X'YES' ]; then
                 ALL_PKGS="${ALL_PKGS} mysql-server"
                 PKG_SCRIPTS="${PKG_SCRIPTS} ${MYSQL_RC_SCRIPT_NAME}"
             fi
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.