Commits

Zhang Huangbin committed cfa8e95

Fixed a long live bug: Dovecot cannot be started immediately during iRedMail installation. Caused by global variable CONFIG_FILE.

Comments (0)

Files changed (12)

iRedMail/conf/core

     # Check config tool: dialog.
     check_pkg ${BIN_DIALOG} ${PKG_DIALOG}
 
-    ECHO_INFO -n "Checking configuration file: ${CONFIG_FILE} ..."
-    if [ -f ${CONFIG_FILE} ]; then
-        grep '^#EOF$' ${CONFIG_FILE} >/dev/null
+    ECHO_INFO -n "Checking configuration file: ${IREDMAIL_CONFIG_FILE} ..."
+    if [ -f ${IREDMAIL_CONFIG_FILE} ]; then
+        grep '^#EOF$' ${IREDMAIL_CONFIG_FILE} >/dev/null
 
         if [ X"$?" == X"0" ]; then
             echo -e " [FOUND]"
             read_setting ${AUTO_USE_EXISTING_CONFIG_FILE}
             case $ANSWER in
                 Y|y )
-                    ECHO_INFO "Use config file: ${CONFIG_FILE} for mail server setting."
-                    . ${CONFIG_FILE}
+                    ECHO_INFO "Use config file: ${IREDMAIL_CONFIG_FILE} for mail server setting."
+                    . ${IREDMAIL_CONFIG_FILE}
 
                     # Check installation status.
                     # After each component installation was completed, there
                     fi
                     ;;
                 N|n|* )
-                    echo "Skip configuration file: ${CONFIG_FILE}."
+                    echo "Skip configuration file: ${IREDMAIL_CONFIG_FILE}."
                     . ${CONFIG_VIA_DIALOG}
                     ;;
             esac

iRedMail/conf/global

 # Tools.
 export CONFIG_VIA_DIALOG="${DIALOG_DIR}/config_via_dialog.sh"
 # Note: config file will be sourced in file 'conf/core', function 'check_env()'.
-export CONFIG_FILE="${ROOTDIR}/config"
+export IREDMAIL_CONFIG_FILE="${ROOTDIR}/config"
 export TIP_FILE="${ROOTDIR}/${PROG_NAME}.tips"
 export DOC_FILE="${ROOTDIR}/Documentations"
 export STATUS_FILE="${ROOTDIR}/.status"

iRedMail/dialog/awstats_config.sh

         [ X"${AWSTATS_USERNAME}" != X"" ] && break
     done
 
-    echo "export AWSTATS_USERNAME='${AWSTATS_USERNAME}'" >>${CONFIG_FILE}
+    echo "export AWSTATS_USERNAME='${AWSTATS_USERNAME}'" >>${IREDMAIL_CONFIG_FILE}
     rm -f /tmp/awstats_username
 
     # Set password for awstats user.
         [ X"${AWSTATS_PASSWD}" != X"" ] && break
     done
 
-    echo "export AWSTATS_PASSWD='${AWSTATS_PASSWD}'" >>${CONFIG_FILE}
+    echo "export AWSTATS_PASSWD='${AWSTATS_PASSWD}'" >>${IREDMAIL_CONFIG_FILE}
     rm -f /tmp/awstats_passwd
 fi

iRedMail/dialog/config_via_dialog.sh

 trap "exit 255" 2
 
 # Initialize config file.
-echo '' > ${CONFIG_FILE}
+echo '' > ${IREDMAIL_CONFIG_FILE}
 
 if [ X"${DISTRO}" == X"FREEBSD" ]; then
     DIALOG='dialog'
 export STORAGE_BASE_DIR="${VMAIL_USER_HOME_DIR}"
 export STORAGE_MAILBOX_DIR="${STORAGE_BASE_DIR}/${STORAGE_NODE}"
 export SIEVE_DIR="${VMAIL_USER_HOME_DIR}/sieve"
-echo "export VMAIL_USER_HOME_DIR='${VMAIL_USER_HOME_DIR}'" >> ${CONFIG_FILE}
-echo "export STORAGE_BASE_DIR='${VMAIL_USER_HOME_DIR}'" >> ${CONFIG_FILE}
-echo "export STORAGE_MAILBOX_DIR='${STORAGE_MAILBOX_DIR}'" >> ${CONFIG_FILE}
-echo "export SIEVE_DIR='${SIEVE_DIR}'" >>${CONFIG_FILE}
+echo "export VMAIL_USER_HOME_DIR='${VMAIL_USER_HOME_DIR}'" >> ${IREDMAIL_CONFIG_FILE}
+echo "export STORAGE_BASE_DIR='${VMAIL_USER_HOME_DIR}'" >> ${IREDMAIL_CONFIG_FILE}
+echo "export STORAGE_MAILBOX_DIR='${STORAGE_MAILBOX_DIR}'" >> ${IREDMAIL_CONFIG_FILE}
+echo "export SIEVE_DIR='${SIEVE_DIR}'" >>${IREDMAIL_CONFIG_FILE}
 
 export BACKUP_DIR="${VMAIL_USER_HOME_DIR}/backup"
 export BACKUP_SCRIPT_OPENLDAP="${BACKUP_DIR}/backup_openldap.sh"
 export BACKUP_SCRIPT_MYSQL="${BACKUP_DIR}/backup_mysql.sh"
 export BACKUP_SCRIPT_PGSQL="${BACKUP_DIR}/backup_pgsql.sh"
-echo "export BACKUP_DIR='${BACKUP_DIR}'" >>${CONFIG_FILE}
-echo "export BACKUP_SCRIPT_OPENLDAP='${BACKUP_SCRIPT_OPENLDAP}'" >>${CONFIG_FILE}
-echo "export BACKUP_SCRIPT_MYSQL='${BACKUP_SCRIPT_MYSQL}'" >>${CONFIG_FILE}
-echo "export BACKUP_SCRIPT_PGSQL='${BACKUP_SCRIPT_PGSQL}'" >>${CONFIG_FILE}
+echo "export BACKUP_DIR='${BACKUP_DIR}'" >>${IREDMAIL_CONFIG_FILE}
+echo "export BACKUP_SCRIPT_OPENLDAP='${BACKUP_SCRIPT_OPENLDAP}'" >>${IREDMAIL_CONFIG_FILE}
+echo "export BACKUP_SCRIPT_MYSQL='${BACKUP_SCRIPT_MYSQL}'" >>${IREDMAIL_CONFIG_FILE}
+echo "export BACKUP_SCRIPT_PGSQL='${BACKUP_SCRIPT_PGSQL}'" >>${IREDMAIL_CONFIG_FILE}
 
 # --------------------------------------------------
 # --------------------- Backends --------------------
     export BACKEND='PGSQL'
     export BACKEND_ORIG='PGSQL'
 fi
-echo "export BACKEND_ORIG='${BACKEND_ORIG}'" >> ${CONFIG_FILE}
-echo "export BACKEND='${BACKEND}'" >> ${CONFIG_FILE}
+echo "export BACKEND_ORIG='${BACKEND_ORIG}'" >> ${IREDMAIL_CONFIG_FILE}
+echo "export BACKEND='${BACKEND}'" >> ${IREDMAIL_CONFIG_FILE}
 rm -f /tmp/backend &>/dev/null
 
 # Read-only SQL user/role, used to query mail accounts in Postfix, Dovecot.
 export VMAIL_DB_BIND_PASSWD="$(${RANDOM_STRING})"
-echo "export VMAIL_DB_BIND_PASSWD='${VMAIL_DB_BIND_PASSWD}'" >> ${CONFIG_FILE}
+echo "export VMAIL_DB_BIND_PASSWD='${VMAIL_DB_BIND_PASSWD}'" >> ${IREDMAIL_CONFIG_FILE}
 
 # For database management: vmail.
 export VMAIL_DB_ADMIN_PASSWD="$(${RANDOM_STRING})"
-echo "export VMAIL_DB_ADMIN_PASSWD='${VMAIL_DB_ADMIN_PASSWD}'" >> ${CONFIG_FILE}
+echo "export VMAIL_DB_ADMIN_PASSWD='${VMAIL_DB_ADMIN_PASSWD}'" >> ${IREDMAIL_CONFIG_FILE}
 
 # LDAP bind dn & password.
 export LDAP_BINDPW="$(${RANDOM_STRING})"
 export LDAP_ADMIN_PW="$(${RANDOM_STRING})"
-echo "export LDAP_BINDPW='${LDAP_BINDPW}'" >> ${CONFIG_FILE}
-echo "export LDAP_ADMIN_PW='${LDAP_ADMIN_PW}'" >> ${CONFIG_FILE}
+echo "export LDAP_BINDPW='${LDAP_BINDPW}'" >> ${IREDMAIL_CONFIG_FILE}
+echo "export LDAP_ADMIN_PW='${LDAP_ADMIN_PW}'" >> ${IREDMAIL_CONFIG_FILE}
 
 if [ X"${BACKEND}" == X"OPENLDAP" ]; then
     . ${DIALOG_DIR}/ldap_config.sh
     export SQL_ROOT_PASSWD="${PGSQL_ROOT_PASSWD}"
 fi
 
-echo "export SQL_SERVER='${SQL_SERVER}'" >> ${CONFIG_FILE}
-echo "export SQL_SERVER_PORT='${SQL_SERVER_PORT}'" >> ${CONFIG_FILE}
+echo "export SQL_SERVER='${SQL_SERVER}'" >> ${IREDMAIL_CONFIG_FILE}
+echo "export SQL_SERVER_PORT='${SQL_SERVER_PORT}'" >> ${IREDMAIL_CONFIG_FILE}
 
 # Virtual domain configuration.
 . ${DIALOG_DIR}/virtual_domain_config.sh
 . ${DIALOG_DIR}/optional_components.sh
 
 # Append EOF tag in config file.
-echo "#EOF" >> ${CONFIG_FILE}
+echo "#EOF" >> ${IREDMAIL_CONFIG_FILE}
 
 #
 # Ending message.
 * Below file contains sensitive infomation (username/password), please  *
 * do remember to *MOVE* it to a safe place after installation.          *
 *                                                                       *
-*   * ${CONFIG_FILE}
+*   * ${IREDMAIL_CONFIG_FILE}
 *                                                                       *
 *************************************************************************
 EOF

iRedMail/dialog/ldap_config.sh

 export LDAP_ADMIN_BASEDN="o=${LDAP_ATTR_DOMAINADMIN_DN_NAME},${LDAP_SUFFIX}"
 rm -f /tmp/ldap_suffix
 
-cat >> ${CONFIG_FILE} <<EOF
+cat >> ${IREDMAIL_CONFIG_FILE} <<EOF
 export dn2dnsname="${dn2dnsname}"
 export LDAP_SUFFIX="${LDAP_SUFFIX}"
 export LDAP_SUFFIX_MAJOR="${LDAP_SUFFIX_MAJOR}"
     fi
 done
 
-echo "export LDAP_ROOTPW='${LDAP_ROOTPW}'" >>${CONFIG_FILE}
+echo "export LDAP_ROOTPW='${LDAP_ROOTPW}'" >>${IREDMAIL_CONFIG_FILE}
 rm -f /tmp/ldap_rootpw

iRedMail/dialog/mysql_config.sh

     [ X"${MYSQL_ROOT_PASSWD}" != X"" ] && break
 done
 
-echo "export MYSQL_ROOT_PASSWD='${MYSQL_ROOT_PASSWD}'" >>${CONFIG_FILE}
+echo "export MYSQL_ROOT_PASSWD='${MYSQL_ROOT_PASSWD}'" >>${IREDMAIL_CONFIG_FILE}
 # MYSQL_ROOT_USER is defined in conf/mysql
-echo "export MYSQL_ROOT_USER='${MYSQL_ROOT_USER}'" >>${CONFIG_FILE}
+echo "export MYSQL_ROOT_USER='${MYSQL_ROOT_USER}'" >>${IREDMAIL_CONFIG_FILE}
 rm -f /tmp/mysql_rootpw

iRedMail/dialog/optional_components.sh

 rm -f ${tmp_config_optional_components} &>/dev/null
 
 echo ${OPTIONAL_COMPONENTS} | grep -i '\<SPF\>' >/dev/null 2>&1
-[ X"$?" == X"0" ] && export ENABLE_SPF='YES' && echo "export ENABLE_SPF='YES'" >>${CONFIG_FILE}
+[ X"$?" == X"0" ] && export ENABLE_SPF='YES' && echo "export ENABLE_SPF='YES'" >>${IREDMAIL_CONFIG_FILE}
 
 echo ${OPTIONAL_COMPONENTS} | grep -i '\<DKIM\>' >/dev/null 2>&1
-[ X"$?" == X"0" ] && export ENABLE_DKIM='YES' && echo "export ENABLE_DKIM='YES'" >>${CONFIG_FILE}
+[ X"$?" == X"0" ] && export ENABLE_DKIM='YES' && echo "export ENABLE_DKIM='YES'" >>${IREDMAIL_CONFIG_FILE}
 
 echo ${OPTIONAL_COMPONENTS} | grep -i 'iredadmin' >/dev/null 2>&1
-[ X"$?" == X"0" ] && export USE_IREDADMIN='YES' && export USE_IREDADMIN='YES' && echo "export USE_IREDADMIN='YES'" >> ${CONFIG_FILE}
+[ X"$?" == X"0" ] && export USE_IREDADMIN='YES' && export USE_IREDADMIN='YES' && echo "export USE_IREDADMIN='YES'" >> ${IREDMAIL_CONFIG_FILE}
 
 if echo ${OPTIONAL_COMPONENTS} | grep -i 'roundcubemail' &>/dev/null; then
     export USE_WEBMAIL='YES'
     export USE_RCM='YES'
     export REQUIRE_PHP='YES'
-    echo "export USE_WEBMAIL='YES'" >> ${CONFIG_FILE}
-    echo "export USE_RCM='YES'" >> ${CONFIG_FILE}
-    echo "export REQUIRE_PHP='YES'" >> ${CONFIG_FILE}
+    echo "export USE_WEBMAIL='YES'" >> ${IREDMAIL_CONFIG_FILE}
+    echo "export USE_RCM='YES'" >> ${IREDMAIL_CONFIG_FILE}
+    echo "export REQUIRE_PHP='YES'" >> ${IREDMAIL_CONFIG_FILE}
 fi
 
 if echo ${OPTIONAL_COMPONENTS} | grep -i 'phpldapadmin' &>/dev/null; then
     export USE_PHPLDAPADMIN='YES'
     export REQUIRE_PHP='YES'
-    echo "export USE_PHPLDAPADMIN='YES'" >>${CONFIG_FILE}
-    echo "export REQUIRE_PHP='YES'" >> ${CONFIG_FILE}
+    echo "export USE_PHPLDAPADMIN='YES'" >>${IREDMAIL_CONFIG_FILE}
+    echo "export REQUIRE_PHP='YES'" >> ${IREDMAIL_CONFIG_FILE}
 fi
 
 echo ${OPTIONAL_COMPONENTS} | grep -i 'phpmyadmin' >/dev/null 2>&1
 if [ X"$?" == X"0" ]; then
     export USE_PHPMYADMIN='YES'
-    echo "export USE_PHPMYADMIN='YES'" >>${CONFIG_FILE}
-    echo "export REQUIRE_PHP='YES'" >> ${CONFIG_FILE}
+    echo "export USE_PHPMYADMIN='YES'" >>${IREDMAIL_CONFIG_FILE}
+    echo "export REQUIRE_PHP='YES'" >> ${IREDMAIL_CONFIG_FILE}
 fi
 
 if echo ${OPTIONAL_COMPONENTS} | grep -i 'phppgadmin' &>/dev/null; then
     export USE_PHPPGADMIN='YES'
-    echo "export USE_PHPPGADMIN='YES'" >>${CONFIG_FILE}
+    echo "export USE_PHPPGADMIN='YES'" >>${IREDMAIL_CONFIG_FILE}
 fi
 
 if echo ${OPTIONAL_COMPONENTS} | grep -i 'awstats' &>/dev/null; then
     export USE_AWSTATS='YES'
-    echo "export USE_AWSTATS='YES'" >>${CONFIG_FILE}
+    echo "export USE_AWSTATS='YES'" >>${IREDMAIL_CONFIG_FILE}
 fi
 
 if echo ${OPTIONAL_COMPONENTS} | grep -i 'fail2ban' &>/dev/null; then
     export USE_FAIL2BAN='YES'
-    echo "export USE_FAIL2BAN='YES'" >>${CONFIG_FILE}
+    echo "export USE_FAIL2BAN='YES'" >>${IREDMAIL_CONFIG_FILE}
 fi
 
 # Used when you use awstats.

iRedMail/dialog/pgsql_config.sh

     [ X"${PGSQL_ROOT_PASSWD}" != X"" ] && break
 done
 
-echo "export PGSQL_ROOT_PASSWD='${PGSQL_ROOT_PASSWD}'" >>${CONFIG_FILE}
+echo "export PGSQL_ROOT_PASSWD='${PGSQL_ROOT_PASSWD}'" >>${IREDMAIL_CONFIG_FILE}
 # PGSQL_ROOT_USER is defined in conf/postgresql
-echo "export PGSQL_ROOT_USER='${PGSQL_ROOT_USER}'" >>${CONFIG_FILE}
+echo "export PGSQL_ROOT_USER='${PGSQL_ROOT_USER}'" >>${IREDMAIL_CONFIG_FILE}
 rm -f /tmp/pgsql_rootpw

iRedMail/dialog/virtual_domain_config.sh

     [ X"$?" == X"0" ] && break
 done
 
-echo "export FIRST_DOMAIN='${FIRST_DOMAIN}'" >> ${CONFIG_FILE}
+echo "export FIRST_DOMAIN='${FIRST_DOMAIN}'" >> ${IREDMAIL_CONFIG_FILE}
 rm -f /tmp/first_domain
 
 #DOMAIN_ADMIN_NAME
 export DOMAIN_ADMIN_NAME='postmaster'
 export SITE_ADMIN_NAME="${DOMAIN_ADMIN_NAME}@${FIRST_DOMAIN}"
-echo "export DOMAIN_ADMIN_NAME='${DOMAIN_ADMIN_NAME}'" >>${CONFIG_FILE}
-echo "export SITE_ADMIN_NAME='${SITE_ADMIN_NAME}'" >>${CONFIG_FILE}
+echo "export DOMAIN_ADMIN_NAME='${DOMAIN_ADMIN_NAME}'" >>${IREDMAIL_CONFIG_FILE}
+echo "export SITE_ADMIN_NAME='${SITE_ADMIN_NAME}'" >>${IREDMAIL_CONFIG_FILE}
 
 # DOMAIN_ADMIN_PASSWD
 while : ; do
 
 export DOMAIN_ADMIN_PASSWD_PLAIN="${DOMAIN_ADMIN_PASSWD}"
 export SITE_ADMIN_PASSWD="${DOMAIN_ADMIN_PASSWD_PLAIN}"
-echo "export DOMAIN_ADMIN_PASSWD_PLAIN='${DOMAIN_ADMIN_PASSWD}'" >> ${CONFIG_FILE}
-echo "export DOMAIN_ADMIN_PASSWD='${DOMAIN_ADMIN_PASSWD}'" >> ${CONFIG_FILE}
-echo "export SITE_ADMIN_PASSWD='${SITE_ADMIN_PASSWD}'" >> ${CONFIG_FILE}
+echo "export DOMAIN_ADMIN_PASSWD_PLAIN='${DOMAIN_ADMIN_PASSWD}'" >> ${IREDMAIL_CONFIG_FILE}
+echo "export DOMAIN_ADMIN_PASSWD='${DOMAIN_ADMIN_PASSWD}'" >> ${IREDMAIL_CONFIG_FILE}
+echo "export SITE_ADMIN_PASSWD='${SITE_ADMIN_PASSWD}'" >> ${IREDMAIL_CONFIG_FILE}
 rm -f /tmp/first_domain_admin_passwd
 
 # First mail user and password
 export FIRST_USER="${DOMAIN_ADMIN_NAME}"
 export FIRST_USER_PASSWD="${DOMAIN_ADMIN_PASSWD}"
 export FIRST_USER_PASSWD_PLAIN="${DOMAIN_ADMIN_PASSWD_PLAIN}"
-echo "export FIRST_USER='${FIRST_USER}'" >>${CONFIG_FILE}
-echo "export FIRST_USER_PASSWD='${FIRST_USER_PASSWD}'" >>${CONFIG_FILE}
-echo "export FIRST_USER_PASSWD_PLAIN='${FIRST_USER_PASSWD_PLAIN}'" >>${CONFIG_FILE}
+echo "export FIRST_USER='${FIRST_USER}'" >>${IREDMAIL_CONFIG_FILE}
+echo "export FIRST_USER_PASSWD='${FIRST_USER_PASSWD}'" >>${IREDMAIL_CONFIG_FILE}
+echo "export FIRST_USER_PASSWD_PLAIN='${FIRST_USER_PASSWD_PLAIN}'" >>${IREDMAIL_CONFIG_FILE}
 
 cat >> ${TIP_FILE} <<EOF
 Admin of domain ${FIRST_DOMAIN}:

iRedMail/functions/cleanup.sh

     [ X"${BACKEND}" == X'PGSQL' ] && check_status_before_run cleanup_pgsql_force_password
 
     # Start Dovecot to deliver emails.
-    ${DIR_RC_SCRIPTS}/${DOVECOT_RC_SCRIPT_NAME} restart &>/dev/null
+    bash -xv ${DIR_RC_SCRIPTS}/${DOVECOT_RC_SCRIPT_NAME} restart #&>/dev/null
     sleep 3
 
     # Send tip file to the mail server admin and/or first mail user.

iRedMail/functions/iredadmin.sh

 {
     ECHO_INFO "Configure iRedAdmin (official web-based admin panel)."
 
-    echo "export IREDADMIN_DB_PASSWD='${IREDADMIN_DB_PASSWD}'" >> ${CONFIG_FILE}
+    echo "export IREDADMIN_DB_PASSWD='${IREDADMIN_DB_PASSWD}'" >> ${IREDMAIL_CONFIG_FILE}
 
     if [ X"${DISTRO}" == X"DEBIAN" -o X"${DISTRO}" == X"UBUNTU" -o X"${DISTRO}" == X"SUSE" ]; then
         ECHO_DEBUG "Enable apache module: wsgi."

iRedMail/functions/roundcubemail.sh

 {
     ECHO_INFO "Configure Roundcube webmail."
 
-    echo "export RCM_DB_USER='${RCM_DB_USER}'" >> ${CONFIG_FILE}
-    echo "export RCM_DB_PASSWD='${RCM_DB_PASSWD}'" >> ${CONFIG_FILE}
+    echo "export RCM_DB_USER='${RCM_DB_USER}'" >> ${IREDMAIL_CONFIG_FILE}
+    echo "export RCM_DB_PASSWD='${RCM_DB_PASSWD}'" >> ${IREDMAIL_CONFIG_FILE}
 
     if [ X"${RCM_USE_SOURCE}" == X'YES' ]; then
         cd ${MISC_DIR}
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.