Commits

Zhang Huangbin  committed 696faff

Revert part of last 2 commits.

  • Participants
  • Parent commits e23fff8

Comments (0)

Files changed (26)

File iRedMail/conf/core

 
     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
+        if grep '^#EOF$' ${IREDMAIL_CONFIG_FILE} >/dev/null; then
             echo -e " [FOUND]"
             ECHO_QUESTION -n "Use it for mail server setting? [y|N]"
             read_setting ${AUTO_USE_EXISTING_CONFIG_FILE}
                     #   export STATUS_PHP_INSTALLATION='DONE'
                     #   export STATUS_PHP_CONFIGURATION='DONE'
                     #
-                    if [ -e ${STATUS_FILE} ]; then
+                    if [ -f ${STATUS_FILE} ]; then
                         ECHO_INFO "Import installation process status from file: ${STATUS_FILE}."
                         . ${STATUS_FILE}
                     else
                     fi
 
                     # Initialize tip file.
-                    if [ ! -e ${TIP_FILE} ]; then
+                    if [ ! -f ${TIP_FILE} ]; then
                         cat > ${TIP_FILE} <<EOF
 ${CONF_MSG}
 EOF
-                    else
-                        :
                     fi
                     ;;
                 N|n|* )
-                    echo "Skip configuration file: ${IREDMAIL_CONFIG_FILE}."
+                    ECHO_INFO "Skip configuration file: ${IREDMAIL_CONFIG_FILE}."
                     . ${CONFIG_VIA_DIALOG}
                     ;;
             esac
         else
-            echo -e "\tFound, but not finished."
+            ECHO_INFO "Found, but not finished."
             . ${CONFIG_VIA_DIALOG}
         fi
     else
-        echo -e "\t[UNCOMPLETED]"
+        ECHO_INFO "[NOT FOUND]"
         . ${CONFIG_VIA_DIALOG}
     fi
 }
 
 check_status_before_run()
 {
-    # Every function will append status info to ${STATUS_FILE}. For example,
+    # If function was successfully executed, this function will write one line
+    # in $STATUS_FILE:
     #
     #   export status_[function_name]='DONE'
     #
-    function_status="status_$1"
-    if [ X"$(eval echo \$${function_status})" != X"DONE" ]; then
+    function_status_name="status_$1"
+    function_status_value="$(eval echo \$${function_status_name})"
+    if [ X"${function_status_value}" == X"DONE" ]; then
+        ECHO_SKIP "Function: $1."
+    else
         $1
-        echo "export ${function_status}='DONE'" >> ${STATUS_FILE}
-    else
-        ECHO_SKIP "Function: $1."
+        if [ X"$?" == X'0' ]; then
+            echo "export ${function_status_name}='DONE'" >> ${STATUS_FILE}
+        fi
     fi
 }
 

File iRedMail/functions/amavisd.sh

 DNS record for DKIM support:
 
 EOF
-
     if [ X"${DISTRO}" == X'RHEL' ]; then
         cat >> ${TIP_FILE} <<EOF
 $(${AMAVISD_BIN} -c ${AMAVISD_CONF} showkeys 2>/dev/null)
 $(${AMAVISD_BIN} showkeys 2>/dev/null)
 EOF
     fi
+
+    echo 'export status_amavisd_dkim="DONE"' >> ${STATUS_FILE}
 }
 
 amavisd_config_rhel()
     perl -pi -e 's%(os_fingerprint_method => undef.*)%${1}\n  allow_disclaimers => 1, # enables disclaimer insertion if available%' ${AMAVISD_CONF}
 
     echo '$sa_debug = 0;' >> ${AMAVISD_CONF}
+    echo 'export status_amavisd_config_rhel="DONE"' >> ${STATUS_FILE}
 }
 
 amavisd_config_debian()
     # groups when it drops priviledges, and that you add the
     # clamav user to the amavis group.
     adduser --quiet ${CLAMAV_USER} ${AMAVISD_SYS_GROUP} >/dev/null
+
+    echo 'export status_amavisd_config_debian="DONE"' >> ${STATUS_FILE}
 }
 
 amavisd_config_general()
     endscript
 }
 EOF
+    else
+        :
     fi
 
     # Add crontab job to delete virus mail.
         - SQL template: ${AMAVISD_DB_MYSQL_TMPL}
 
 EOF
+
+    echo 'export status_amavisd_config_general="DONE"' >> ${STATUS_FILE}
 }
 
 amavisd_import_sql()
 EOF
         fi
     fi
+
+    echo 'export status_amavisd_import_sql="DONE"' >> ${STATUS_FILE}
 }
 
 amavisd_config()

File iRedMail/functions/apache_php.sh

     * Disabled functions: ${PHP_DISABLED_FUNCTIONS}
 
 EOF
+
+    echo 'export status_apache_php_config="DONE"' >> ${STATUS_FILE}
 }

File iRedMail/functions/awstats.sh

         shell> crontab -l root
 
 EOF
+
+    echo 'export status_awstats_config_basic="DONE"' >> ${STATUS_FILE}
 }
 
 awstats_config_weblog()
     # On RHEL/CentOS/Debian, ${AWSTATS_CONF_SAMPLE} is default config file. Overrided here.
     backup_file ${AWSTATS_CONF_SAMPLE}
     cp -f ${AWSTATS_CONF_WEB} ${AWSTATS_CONF_SAMPLE}
+
+    echo 'export status_awstats_config_weblog="DONE"' >> ${STATUS_FILE}
 }
 
 awstats_config_maillog()
     perl -pi -e 's#^(Lang=)(.*)#${1}$ENV{AWSTATS_LANGUAGE}#' ${AWSTATS_CONF_MAIL}
 
     perl -pi -e 's#^(DirIcons=)(.*)#${1}"/awstats/icon#' ${AWSTATS_CONF_MAIL}
+
+    echo 'export status_awstats_config_maillog="DONE"' >> ${STATUS_FILE}
 }
 
 awstats_config_crontab()
 1   */1   *   *   *   perl ${AWSTATS_CGI_DIR}/awstats.pl -config=web -update >/dev/null
 1   */1   *   *   *   perl ${AWSTATS_CGI_DIR}/awstats.pl -config=smtp -update >/dev/null
 EOF
+
+    echo 'export status_awstats_config_crontab="DONE"' >> ${STATUS_FILE}
 }

File iRedMail/functions/backend.sh

     elif [ X"${BACKEND}" == X'PGSQL' ]; then
         check_status_before_run pgsql_initialize
         check_status_before_run pgsql_import_vmail_users
+    else
+        :
     fi
 }

File iRedMail/functions/clamav.sh

         - ${FRESHCLAM_LOGFILE}
 
 EOF
+
+    echo 'export status_clamav_config="DONE"' >> ${STATUS_FILE}
 }

File iRedMail/functions/cleanup.sh

 
         setenforce 0 &>/dev/null
     fi
+
+    echo 'export status_cleanup_disable_selinux="DONE"' >> ${STATUS_FILE}
 }
 
 cleanup_remove_sendmail()
             esac
         fi
     fi
+
+    echo 'export status_cleanup_remove_sendmail="DONE"' >> ${STATUS_FILE}
 }
 
 cleanup_remove_mod_python()
     else
         :
     fi
+
+    echo 'export status_cleanup_remove_mod_python="DONE"' >> ${STATUS_FILE}
 }
 
 cleanup_replace_firewall_rules()
 
     # Restarting iptables before restarting fail2ban.
     ENABLED_SERVICES="iptables ${ENABLED_SERVICES}"
+
+    echo 'export status_cleanup_replace_firewall_rules="DONE"' >> ${STATUS_FILE}
 }
 
 cleanup_replace_mysql_config()
             esac
         fi
     fi
+
+    echo 'export status_cleanup_replace_mysql_config="DONE"' >> ${STATUS_FILE}
 }
 
 cleanup_update_compile_spamassassin_rules()
 
     ECHO_INFO "Compiling SpamAssassin rulesets (sa-compile), please wait ..."
     ${BIN_SA_COMPILE} &>/dev/null
+
+    echo 'export status_cleanup_update_compile_spamassassin_rules="DONE"' >> ${STATUS_FILE}
 }
 
 cleanup_update_clamav_signatures()
     # Update clamav before start clamav-clamd service.
     ECHO_INFO "Updating ClamAV database (freshclam), please wait ..."
     freshclam
+
+    echo 'export status_cleanup_update_clamav_signatures="DONE"' >> ${STATUS_FILE}
 }
 
 cleanup_backup_scripts()
 
 EOF
     fi
+
+    echo 'export status_cleanup_backup_scripts="DONE"' >> ${STATUS_FILE}
 }
 
 cleanup_pgsql_force_connect_with_password()
         perl -pi -e 's#^(local.*)trust#${1}md5#' ${PGSQL_CONF_PG_HBA}
         perl -pi -e 's#^(host.*)trust#${1}md5#' ${PGSQL_CONF_PG_HBA}
     fi
+
+    echo 'export status_cleanup_pgsql_force_connect_with_password="DONE"' >> ${STATUS_FILE}
 }
 
 cleanup()
 *
 ********************************************************************
 EOF
+
+    echo 'export status_cleanup="DONE"' >> ${STATUS_FILE}
 }

File iRedMail/functions/cluebringer.sh

     elif [ X"${DISTRO}" == X'FREEBSD' ]; then
         pw useradd -n ${CLUEBRINGER_USER} -s ${SHELL_NOLOGIN} -d ${CLUEBRINGER_USER_HOME} -m
     fi
+
+    echo 'export status_cluebringer_user="DONE"' >> ${STATUS_FILE}
 }
 
 cluebringer_config()
     else
         echo -e '\n' >> ${TIP_FILE}
     fi
+
+    echo 'export status_cluebringer_config="DONE"' >> ${STATUS_FILE}
 }
 
 cluebringer_webui_config()
         a2enmod authn_dbd &>/dev/null
         a2enconf cluebringer &>/dev/null
     fi
+
+    echo 'export status_cluebringer_webui_config="DONE"' >> ${STATUS_FILE}
 }

File iRedMail/functions/dovecot.sh

         - Logrotate config file: ${DOVECOT_LOGROTATE_FILE}
 
 EOF
+
+    echo 'export status_dovecot_config="DONE"' >> ${STATUS_FILE}
 }
 
 enable_dovecot()
             [ -f /etc/login.conf.db ] && cap_mkdb /etc/login.conf
         fi
     fi
+
+    echo 'export status_enable_dovecot="DONE"' >> ${STATUS_FILE}
 }
 

File iRedMail/functions/fail2ban.sh

     #    # Start service when system start up.
     #    service_control enable 'fail2ban_enable' 'YES'
     #fi
+
+    echo 'export status_fail2ban_config="DONE"' >> ${STATUS_FILE}
 }

File iRedMail/functions/iredadmin.sh

         - ${IREDADMIN_HTTPD_CONF}
 
 EOF
+
+    echo 'export status_iredadmin_config="DONE"' >> ${STATUS_FILE}
 }

File iRedMail/functions/iredapd.sh

         - ${IREDAPD_ROOT_DIR}/iredapd/etc/settings.py
 
 EOF
+
+    echo 'export status_iredapd_config="DONE"' >> ${STATUS_FILE}
 }

File iRedMail/functions/ldapd.sh

         -h ${LDAP_SERVER_HOST} -p ${LDAP_SERVER_PORT} \
         -D "${LDAP_ROOTDN}" -w "${LDAP_ROOTPW}" \
         -f ${LDAP_INIT_LDIF} >/dev/null
+
+    echo 'export status_ldapd_config="DONE"' >> ${STATUS_FILE}
 }

File iRedMail/functions/mysql.sh

         - ${MYSQL_INIT_SQL}
 
 EOF
+
+    echo 'export status_mysql_initialize="DONE"' >> ${STATUS_FILE}
 }
 
 # It's used only when backend is MySQL.
     - ${MYSQL_VMAIL_SQL}
 
 EOF
+
+    echo 'export status_mysql_import_vmail_users="DONE"' >> ${STATUS_FILE}
 }

File iRedMail/functions/nginx.sh

         - ${UWSGI_CONF_DIR}
     * Socket for iRedAdmin: ${UWSGI_SOCKET_IREDADMIN}
 EOF
+
+    echo 'export status_nginx_config="DONE"' >> ${STATUS_FILE}
 }

File iRedMail/functions/openldap.sh

         -o X"${DISTRO}" == X"UBUNTU" ]; then
         service_control restart rsyslog >/dev/null
     fi
+
+    echo 'export status_openldap_config="DONE"' >> ${STATUS_FILE}
 }
 
 openldap_data_initialize()
         - ${LDAP_INIT_LDIF}
 
 EOF
+
+    echo 'export status_openldap_data_initialize="DONE"' >> ${STATUS_FILE}
 }
 

File iRedMail/functions/packages.sh

             ECHO_INFO "Installing packages:${ALL_PKGS}"
         fi
         eval ${install_pkg} ${ALL_PKGS}
+
+        echo 'export status_install_all_pkgs="DONE"' >> ${STATUS_FILE}
     }
 
     # Enable/Disable services.
             service_control enable ${ENABLED_SERVICES} &>/dev/null
             service_control disable ${DISABLED_SERVICES} &>/dev/null
         fi
+
+        echo 'export status_enable_all_services="DONE"' >> ${STATUS_FILE}
     }
 
     after_package_installation()
                 cd uwsgi-*/ && \
                 python setup.py install &>/dev/null
         fi
+
+        echo 'export status_after_package_installation="DONE"' >> ${STATUS_FILE}
     }
 
     check_status_before_run install_all_pkgs

File iRedMail/functions/packages_freebsd.sh

 
                         echo "export status_install_port_${portname}='DONE'  # ${used_time} seconds, ~= $((used_time/60)) minute(s). Recent ~= $((recent_all_used_time/60)) minutes" >> ${STATUS_FILE}
                     else
-                        ECHO_ERROR "Port was not success installed, please fix it manually and then re-execute this script."
+                        ECHO_ERROR "Port was not successfully installed, please fix it manually and then re-execute this script."
                         exit 255
                     fi
             else
     # Log and print used time
     all_used_time="$(($(date +%s)-start_time))"
     ECHO_INFO "Total time of ports compiling: ${all_used_time} seconds, ~= $((all_used_time/60)) minute(s)"
+
+    echo 'export status_install_all="DONE"' >> ${STATUS_FILE}
 }

File iRedMail/functions/phpldapadmin.sh

         - ${HTTPD_CONF_DIR}/phpldapadmin.conf
 
 EOF
+
+    echo 'export status_phpldapadmin_config="DONE"' >> ${STATUS_FILE}
 }

File iRedMail/functions/policy_server.sh

     if [ X"${USE_SPAMD}" == X'YES' ]; then
         check_status_before_run openbsd_spamd_config
     fi
+
+    echo 'export status_policy_server_config="DONE"' >> ${STATUS_FILE}
 }

File iRedMail/functions/postfix.sh

 
     # Create directory, used to store lookup files.
     [ -d ${POSTFIX_LOOKUP_DIR} ] || mkdir -p ${POSTFIX_LOOKUP_DIR}
+
+    echo 'export status_postfix_config_basic="DONE"' >> ${STATUS_FILE}
 }
 
 postfix_config_vhost_ldap()
     done
 
     echo '' >> ${TIP_FILE}
+
+    echo 'export status_postfix_config_vhost_ldap="DONE"' >> ${STATUS_FILE}
 }
 
 postfix_config_vhost_mysql()
         - $i
 EOF
     done
+
+    echo 'export status_postfix_config_vhost_mysql="DONE"' >> ${STATUS_FILE}
 }
 
 postfix_config_vhost_pgsql()
 EOF
     done
 
-    echo '' >> ${TIP_FILE}
+        echo '' >> ${TIP_FILE}
+    echo 'export status_postfix_config_vhost_pgsql="DONE"' >> ${STATUS_FILE}
 }
 
 # Starting config.
     elif [ X"${BACKEND}" == X"PGSQL" ]; then
         check_status_before_run postfix_config_vhost_pgsql
     fi
+
+    echo 'export status_postfix_config_virtual_host="DONE"' >> ${STATUS_FILE}
 }
 
 postfix_config_sasl()
         postconf -e smtpd_recipient_restrictions="reject_unknown_sender_domain, reject_non_fqdn_sender, reject_non_fqdn_recipient, reject_unlisted_recipient, ${POSTCONF_IREDAPD} permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination"
 
     fi
+
+    echo 'export status_postfix_config_sasl="DONE"' >> ${STATUS_FILE}
 }
 
 postfix_config_tls()
 #  -o content_filter=smtp-amavis:[${AMAVISD_SERVER}]:10026
 
 EOF
+
+    echo 'export status_postfix_config_tls="DONE"' >> ${STATUS_FILE}
 }

File iRedMail/functions/postgresql.sh

         - ${PGSQL_DOT_PGPASS}
 
 EOF
+
+    echo 'export status_pgsql_initialize="DONE"' >> ${STATUS_FILE}
 }
 
 pgsql_import_vmail_users()
     - ${PGSQL_INIT_SQL_SAMPLE}
 
 EOF
+
+    echo 'export status_pgsql_import_vmail_users="DONE"' >> ${STATUS_FILE}
 }

File iRedMail/functions/roundcubemail.sh

     cp -f ${SAMPLE_DIR}/dovecot/dovecot.sieve.roundcube ${RCM_SIEVE_SAMPLE_FILE}
     chown ${HTTPD_USER}:${HTTPD_GROUP} config.inc.php ${RCM_SIEVE_SAMPLE_FILE}
     chmod 0640 config.inc.php ${RCM_SIEVE_SAMPLE_FILE}
+
+    echo 'export status_rcm_install="DONE"' >> ${STATUS_FILE}
 }
 
 rcm_config_httpd()
     </head>
 </html>
 EOF
+
+    echo 'export status_rcm_config_httpd="DONE"' >> ${STATUS_FILE}
 }
 
 rcm_import_sql()
 FLUSH PRIVILEGES;
 EOF
     fi
+
+    echo 'export status_rcm_import_sql="DONE"' >> ${STATUS_FILE}
 }
 
 rcm_config()
         - ${HTTPD_CONF_DIR}/roundcubemail.conf
 
 EOF
+
+    echo 'export status_rcm_config="DONE"' >> ${STATUS_FILE}
 }
 
 rcm_plugin_managesieve()
     perl -pi -e 's#(.*managesieve_usetls.*=).*#${1} false;#' config.inc.php
     perl -pi -e 's#(.*managesieve_default.*=).*#${1} "$ENV{RCM_SIEVE_SAMPLE_FILE}";#' config.inc.php
     perl -pi -e 's#(.*managesieve_vacation.*=).*#${1} 1;#' config.inc.php
+
+    echo 'export status_rcm_plugin_managesieve="DONE"' >> ${STATUS_FILE}
 }
 
 rcm_plugin_password()
     else
         :
     fi
+
+    echo 'export status_rcm_plugin_password="DONE"' >> ${STATUS_FILE}
 }

File iRedMail/functions/spamassassin.sh

         - ${SA_CONF_DIR}/local.cf
 
 EOF
+
+    echo 'export status_sa_config="DONE"' >> ${STATUS_FILE}
 }

File iRedMail/functions/system_accounts.sh

 add_user_vmail()
 {
     ECHO_INFO "Create required system account: ${VMAIL_USER_NAME}:${VMAIL_GROUP_NAME}."
+
     ECHO_DEBUG "Create HOME folder for vmail user."
-
     homedir="$(dirname $(echo ${VMAIL_USER_HOME_DIR} | sed 's#/$##'))"
     [ -L ${homedir} ] && rm -f ${homedir}
     [ -d ${homedir} ] || mkdir -p ${homedir}
     - Backup scripts and copies: ${BACKUP_DIR}
 
 EOF
+
+    echo 'export status_add_user_vmail="DONE"' >> ${STATUS_FILE}
 }
 
 add_user_iredadmin()
 {
     ECHO_INFO "Create required system account: ${IREDADMIN_USER_NAME}:${IREDADMIN_GROUP_NAME}."
+
     ECHO_DEBUG "Create system account: ${IREDADMIN_USER_NAME}:${IREDADMIN_GROUP_NAME} (${IREDADMIN_USER_UID}:${IREDADMIN_USER_GID})"
-
     # Low privilege user used to run iRedAdmin.
     if [ X"${DISTRO}" == X'FREEBSD' ]; then
         pw groupadd -g ${IREDADMIN_USER_GID} -n ${IREDADMIN_USER_NAME} &>/dev/null
             -d ${IREDADMIN_HOME_DIR} \
             ${IREDADMIN_USER_NAME} &>/dev/null
     fi
+
+    echo 'export status_add_user_iredadmin="DONE"' >> ${STATUS_FILE}
 }
 
 add_user_iredapd()
             -d ${IREDAPD_HOME_DIR} \
             ${IREDAPD_DAEMON_USER} &>/dev/null
     fi
+
+    echo 'export status_add_user_iredapd="DONE"' >> ${STATUS_FILE}
 }
 
 add_required_users()
     check_status_before_run add_user_vmail
     check_status_before_run add_user_iredadmin
     check_status_before_run add_user_iredapd
+
+    echo 'export status_add_required_users="DONE"' >> ${STATUS_FILE}
 }

File iRedMail/pkgs/get_all.sh

 . ${CONF_DIR}/core
 . ${CONF_DIR}/iredadmin
 
-# Re-define $STATUS_FILE, so that iRedMail.sh can read it.
+# Re-define @STATUS_FILE, so that iRedMail.sh can read it.
 export STATUS_FILE="${ROOTDIR}/../.status"
 
 check_user root
             exit 255
         else
             echo -e "\t[ OK ]"
+            echo 'export status_fetch_misc="DONE"' >> ${STATUS_FILE}
+            echo 'export status_check_md5="DONE"' >> ${STATUS_FILE}
         fi
     fi
 }
 
     ECHO_INFO "Clean metadata of yum repositories."
     yum clean metadata
+
+    echo 'export status_create_repo_rhel="DONE"' >> ${STATUS_FILE}
 }
 
 check_new_iredmail()
         echo ''
         exit 255
     fi
+
+    echo 'export status_check_new_iredmail="DONE"' >> ${STATUS_FILE}
 }
 
 echo_end_msg()