Commits

Zhang Huangbin committed 69f2f69

Add required system accounts by default.

  • Participants
  • Parent commits 216580d

Comments (0)

Files changed (67)

File iRedMail/conf/amavisd

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/conf/apache_php

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/conf/awstats

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/conf/clamav

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/conf/cluebringer

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/conf/core

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/conf/dovecot

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/conf/fail2ban

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/conf/global

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server
 # For managesieve service and software.
 export USE_MANAGESIEVE='YES'    # Use managesieve service.
 
-# vmail user. uid and gid should be export after user added. Reference:
-# functions/user_vmail.sh
+# vmail user. uid and gid should be export after user added.
 export VMAIL_USER_NAME='vmail'
 export VMAIL_GROUP_NAME='vmail'
 export VMAIL_DB_ADMIN_USER="${VMAIL_USER_NAME}admin"

File iRedMail/conf/iredadmin

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/conf/iredapd

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/conf/managesieve

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/conf/mysql

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/conf/openldap

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/conf/phpldapadmin

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/conf/phpmyadmin

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/conf/phppgadmin

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/conf/policy_server

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/conf/policyd

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/conf/postfix

 #!/usr/bin/env bash
 
-# Author: Zhang Huangbin <zhb(at)iredmail.org>
+# Author: Zhang Huangbin <zhb _at_ iredmail.org>
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/conf/postgresql

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/conf/roundcube

 #!/usr/bin/env bash
 
-# Author: Zhang Huangbin (zhb(at)iredmail.org)
+# Author: Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/conf/spamassassin

 #!/usr/bin/env bash
 
-# Author: Zhang Huangbin (zhb(at)iredmail.org)
+# Author: Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/dialog/awstats_config.sh

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/dialog/config_via_dialog.sh

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/dialog/ldap_config.sh

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin <zhb(at)iredmail.org>
+# Author:   Zhang Huangbin <zhb _at_ iredmail.org>
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/dialog/mysql_config.sh

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin <zhb(at)iredmail.org>
+# Author:   Zhang Huangbin <zhb _at_ iredmail.org>
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/dialog/optional_components.sh

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin <zhb(at)iredmail.org>
+# Author:   Zhang Huangbin <zhb _at_ iredmail.org>
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/dialog/pgsql_config.sh

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin <zhb(at)iredmail.org>
+# Author:   Zhang Huangbin <zhb _at_ iredmail.org>
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/dialog/virtual_domain_config.sh

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin <zhb(at)iredmail.org>
+# Author:   Zhang Huangbin <zhb _at_ iredmail.org>
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/functions/amavisd.sh

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/functions/apache_php.sh

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/functions/awstats.sh

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/functions/backend.sh

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/functions/clamav.sh

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/functions/cleanup.sh

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/functions/cluebringer.sh

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb@iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/functions/dovecot.sh

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/functions/dovecot1.sh

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/functions/dovecot2.sh

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/functions/fail2ban.sh

 #!/usr/bin/env bash
 
-# Author: Zhang Huangbin <zhb(at)iredmail.org>
+# Author: Zhang Huangbin <zhb _at_ iredmail.org>
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/functions/iredadmin.sh

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 # Purpose:  Install & config necessary packages for iRedAdmin.
 
 #---------------------------------------------------------------------
     export MYSQL_BACKUP_DATABASES="${MYSQL_BACKUP_DATABASES} ${IREDADMIN_DB_NAME}"
     export PGSQL_BACKUP_DATABASES="${PGSQL_BACKUP_DATABASES} ${IREDADMIN_DB_NAME}"
 
-    # Create a low privilege user as httpd daemon user.
-    if [ X"${KERNEL_NAME}" == X"FreeBSD" ]; then
-        pw useradd -m -d ${IREDADMIN_HOME_DIR} -s ${SHELL_NOLOGIN} -n ${IREDADMIN_HTTPD_USER}
-    elif [ X"${DISTRO}" == X"SUSE" ]; then
-        groupadd ${IREDADMIN_HTTPD_GROUP}
-        useradd -m -d ${IREDADMIN_HOME_DIR} -s ${SHELL_NOLOGIN} -g ${IREDADMIN_HTTPD_GROUP} ${IREDADMIN_HTTPD_USER} 2>/dev/null
-    else
-        useradd -m -d ${IREDADMIN_HOME_DIR} -s ${SHELL_NOLOGIN} ${IREDADMIN_HTTPD_GROUP}
-    fi
-
     if [ X"${DISTRO}" == X"DEBIAN" -o X"${DISTRO}" == X"UBUNTU" -o X"${DISTRO}" == X"SUSE" ]; then
         ECHO_DEBUG "Enable apache module: wsgi."
         a2enmod wsgi >/dev/null 2>&1

File iRedMail/functions/iredapd.sh

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 # Purpose:  Install & config necessary packages for iRedAPD.
 
 #---------------------------------------------------------------------
 {
     ECHO_INFO "Configure iRedAPD (postfix policy daemon)."
 
-    # Create a low privilege user as daemon user.
-    if [ X"${DISTRO}" == X'FREEBSD' ]; then
-        pw useradd -m -d ${IREDAPD_HOME_DIR} -s ${SHELL_NOLOGIN} -c "iRedAPD daemon user" -n ${IREDAPD_DAEMON_USER}
-    elif [ X"${DISTRO}" == X"SUSE" ]; then
-        groupadd ${IREDAPD_DAEMON_GROUP}
-        useradd -m -d ${IREDAPD_HOME_DIR} -s ${SHELL_NOLOGIN} -g ${IREDAPD_DAEMON_GROUP} ${IREDAPD_DAEMON_USER} 2>/dev/null
-    else
-        useradd -m -d ${IREDAPD_HOME_DIR} -s ${SHELL_NOLOGIN} -c "iRedAPD daemon user" ${IREDAPD_DAEMON_USER}
-    fi
-
     # Extract source tarball.
     cd ${MISC_DIR}
     [ -d ${IREDAPD_ROOT_DIR} ] || mkdir -p ${IREDAPD_ROOT_DIR}

File iRedMail/functions/managesieve.sh

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/functions/mysql.sh

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/functions/openldap.sh

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/functions/optional_components.sh

 #!/usr/bin/env bash
 
-# Author: Zhang Huangbin <zhb(at)iredmail.org>
+# Author: Zhang Huangbin <zhb _at_ iredmail.org>
 
 # -------------------------------------------
 # Install all optional components.

File iRedMail/functions/packages.sh

 #!/usr/bin/env bash
 
-# Author: Zhang Huangbin <zhb(at)iredmail.org>
+# Author: Zhang Huangbin <zhb _at_ iredmail.org>
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/functions/packages_freebsd.sh

 #!/usr/bin/env bash
 
-# Author: Zhang Huangbin <zhb(at)iredmail.org>
+# Author: Zhang Huangbin <zhb _at_ iredmail.org>
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/functions/phpldapadmin.sh

 #!/usr/bin/env bash
 
-# Author: Zhang Huangbin <zhb(at)iredmail.org>
+# Author: Zhang Huangbin <zhb _at_ iredmail.org>
 
 # -------------------------------------------------------
 # ------------------- phpLDAPadmin ----------------------

File iRedMail/functions/phpmyadmin.sh

 #!/usr/bin/env bash
 
-# Author: Zhang Huangbin <zhb(at)iredmail.org>
+# Author: Zhang Huangbin <zhb _at_ iredmail.org>
 
 # -------------------------------------------------
 # phpMyAdmin.

File iRedMail/functions/phppgadmin.sh

 #!/usr/bin/env bash
 
-# Author: Zhang Huangbin <zhb(at)iredmail.org>
+# Author: Zhang Huangbin <zhb _at_ iredmail.org>
 
 # -------------------------------------------------
 # phpPgAdmin.

File iRedMail/functions/postfix.sh

 #!/usr/bin/env bash
 
-# Author: Zhang Huangbin <zhb(at)iredmail.org>
+# Author: Zhang Huangbin <zhb _at_ iredmail.org>
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/functions/postgresql.sh

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/functions/roundcubemail.sh

 #!/usr/bin/env bash
 
-# Author: Zhang Huangbin <zhb(at)iredmail.org>
+# Author: Zhang Huangbin <zhb _at_ iredmail.org>
 
 # -----------------------
 # Roundcube.

File iRedMail/functions/spamassassin.sh

 #!/usr/bin/env bash
 
-# Author: Zhang Huangbin <zhb(at)iredmail.org>
+# Author: Zhang Huangbin <zhb _at_ iredmail.org>
 
 # ---------------------------------------------------------
 # SpamAssassin.

File iRedMail/functions/system_accounts.sh

+#!/usr/bin/env bash
+
+# Author: Zhang Huangbin <zhb _at_ iredmail.org>
+
+# -------------------------------------------------------
+# ---------------- User/Group: vmail --------------------
+# -------------------------------------------------------
+add_user_vmail()
+{
+    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}
+    [ -d ${STORAGE_BASE_DIR}/${STORAGE_NODE} ] || mkdir -p ${STORAGE_BASE_DIR}/${STORAGE_NODE}
+
+    ECHO_DEBUG "Create system user/group: vmail:vmail."
+
+    # It will create a group with the same name as vmail user name.
+    if [ X"${DISTRO}" == X"FREEBSD" ]; then
+        pw useradd -n ${VMAIL_USER_NAME} -s ${SHELL_NOLOGIN} -d ${VMAIL_USER_HOME_DIR} -m 2>/dev/null
+    elif [ X"${DISTRO}" == X"SUSE" ]; then
+        # Note: package 'postfix-mysql' will create vmail:vmail, with uid/gid=303.
+        groupadd ${VMAIL_GROUP_NAME} 2>/dev/null
+        useradd -m -d ${VMAIL_USER_HOME_DIR} -s ${SHELL_NOLOGIN} -g ${VMAIL_GROUP_NAME} ${VMAIL_USER_NAME} 2>/dev/null
+    else
+        useradd -m -d ${VMAIL_USER_HOME_DIR} -s ${SHELL_NOLOGIN} ${VMAIL_USER_NAME} 2>/dev/null
+    fi
+    rm -f ${VMAIL_USER_HOME_DIR}/.* 2>/dev/null
+
+    # Export vmail user uid/gid.
+    export VMAIL_USER_UID="$(id -u ${VMAIL_USER_NAME})"
+    export VMAIL_USER_GID="$(id -g ${VMAIL_USER_NAME})"
+
+    # Set permission for exist home directory.
+    if [ -d ${VMAIL_USER_HOME_DIR} ]; then
+        chown -R ${VMAIL_USER_NAME}:${VMAIL_GROUP_NAME} ${VMAIL_USER_HOME_DIR}
+        chmod -R 0700 ${VMAIL_USER_HOME_DIR}
+    fi
+
+    ECHO_DEBUG "Create directory to store user sieve rule files: ${SIEVE_DIR}."
+    mkdir -p ${SIEVE_DIR} && \
+    chown -R ${VMAIL_USER_NAME}:${VMAIL_GROUP_NAME} ${SIEVE_DIR} && \
+    chmod -R 0700 ${SIEVE_DIR}
+
+    cat >> ${TIP_FILE} <<EOF
+Mail Storage:
+    - Path:
+        + ${VMAIL_USER_HOME_DIR}
+        + ${STORAGE_BASE_DIR}/${STORAGE_NODE}
+
+EOF
+
+    echo 'export status_add_user_vmail="DONE"' >> ${STATUS_FILE}
+}
+
+add_user_iredadmin()
+{
+    ECHO_DEBUG "Create system user: iredadmin."
+
+    # Low privilege user used to run iRedAdmin.
+    if [ X"${KERNEL_NAME}" == X"FreeBSD" ]; then
+        pw useradd -m -d ${IREDADMIN_HOME_DIR} -s ${SHELL_NOLOGIN} -n ${IREDADMIN_HTTPD_USER}
+    elif [ X"${DISTRO}" == X"SUSE" ]; then
+        groupadd ${IREDADMIN_HTTPD_GROUP}
+        useradd -m -d ${IREDADMIN_HOME_DIR} -s ${SHELL_NOLOGIN} -g ${IREDADMIN_HTTPD_GROUP} ${IREDADMIN_HTTPD_USER} 2>/dev/null
+    else
+        useradd -m -d ${IREDADMIN_HOME_DIR} -s ${SHELL_NOLOGIN} ${IREDADMIN_HTTPD_GROUP}
+    fi
+
+    echo 'export status_add_user_iredadmin="DONE"' >> ${STATUS_FILE}
+}
+
+add_user_iredapd()
+{
+    ECHO_DEBUG "Create system user: iredapd."
+
+    # Low privilege user used to run iRedAPD daemon.
+    if [ X"${DISTRO}" == X'FREEBSD' ]; then
+        pw useradd -m -d ${IREDAPD_HOME_DIR} -s ${SHELL_NOLOGIN} -c "iRedAPD daemon user" -n ${IREDAPD_DAEMON_USER}
+    elif [ X"${DISTRO}" == X"SUSE" ]; then
+        groupadd ${IREDAPD_DAEMON_GROUP}
+        useradd -m -d ${IREDAPD_HOME_DIR} -s ${SHELL_NOLOGIN} -g ${IREDAPD_DAEMON_GROUP} ${IREDAPD_DAEMON_USER} 2>/dev/null
+    else
+        useradd -m -d ${IREDAPD_HOME_DIR} -s ${SHELL_NOLOGIN} -c "iRedAPD daemon user" ${IREDAPD_DAEMON_USER}
+    fi
+
+    echo 'export status_add_user_iredapd="DONE"' >> ${STATUS_FILE}
+}
+
+add_required_users()
+{
+    ECHO_INFO "Create required system accounts: vmail, iredapd, iredadmin."
+    check_status_before_run add_user_vmail
+    check_status_before_run add_user_iredadmin
+    check_status_before_run add_user_iredapd
+}

File iRedMail/functions/user_vmail.sh

-#!/usr/bin/env bash
-
-# Author: Zhang Huangbin <zhb(at)iredmail.org>
-
-# -------------------------------------------------------
-# ---------------- User/Group: vmail --------------------
-# -------------------------------------------------------
-adduser_vmail()
-{
-    ECHO_INFO "Configure User/Group: vmail."
-
-    homedir="$(dirname $(echo ${VMAIL_USER_HOME_DIR} | sed 's#/$##'))"
-    [ -L ${homedir} ] && rm -f ${homedir}
-    [ -d ${homedir} ] || mkdir -p ${homedir}
-    [ -d ${STORAGE_BASE_DIR}/${STORAGE_NODE} ] || mkdir -p ${STORAGE_BASE_DIR}/${STORAGE_NODE}
-
-    ECHO_DEBUG "Add user/group: vmail."
-
-    # It will create a group with the same name as vmail user name.
-    if [ X"${DISTRO}" == X"FREEBSD" ]; then
-        pw useradd -n ${VMAIL_USER_NAME} -s ${SHELL_NOLOGIN} -d ${VMAIL_USER_HOME_DIR} -m 2>/dev/null
-    elif [ X"${DISTRO}" == X"SUSE" ]; then
-        # Note: package 'postfix-mysql' will create vmail:vmail, with uid/gid=303.
-        groupadd ${VMAIL_GROUP_NAME} 2>/dev/null
-        useradd -m -d ${VMAIL_USER_HOME_DIR} -s ${SHELL_NOLOGIN} -g ${VMAIL_GROUP_NAME} ${VMAIL_USER_NAME} 2>/dev/null
-    else
-        useradd -m -d ${VMAIL_USER_HOME_DIR} -s ${SHELL_NOLOGIN} ${VMAIL_USER_NAME} 2>/dev/null
-    fi
-    rm -f ${VMAIL_USER_HOME_DIR}/.* 2>/dev/null
-
-    # Export vmail user uid/gid.
-    export VMAIL_USER_UID="$(id -u ${VMAIL_USER_NAME})"
-    export VMAIL_USER_GID="$(id -g ${VMAIL_USER_NAME})"
-
-    # Set permission for exist home directory.
-    if [ -d ${VMAIL_USER_HOME_DIR} ]; then
-        chown -R ${VMAIL_USER_NAME}:${VMAIL_GROUP_NAME} ${VMAIL_USER_HOME_DIR}
-        chmod -R 0700 ${VMAIL_USER_HOME_DIR}
-    else
-        :
-    fi
-
-    ECHO_DEBUG "Create directory to store user sieve rule files: ${SIEVE_DIR}."
-    mkdir -p ${SIEVE_DIR} && \
-    chown -R ${VMAIL_USER_NAME}:${VMAIL_GROUP_NAME} ${SIEVE_DIR} && \
-    chmod -R 0700 ${SIEVE_DIR}
-
-    cat >> ${TIP_FILE} <<EOF
-Mail Storage:
-    - Path:
-        + ${VMAIL_USER_HOME_DIR}
-        + ${STORAGE_BASE_DIR}/${STORAGE_NODE}
-
-EOF
-
-    echo 'export status_adduser_vmail="DONE"' >> ${STATUS_FILE}
-}

File iRedMail/iRedMail.sh

 fi
 
 # User/Group: vmail. We will export vmail uid/gid here.
-. ${FUNCTIONS_DIR}/user_vmail.sh
+. ${FUNCTIONS_DIR}/system_accounts.sh
 
 . ${FUNCTIONS_DIR}/apache_php.sh
 . ${FUNCTIONS_DIR}/openldap.sh
 check_status_before_run gen_pem_key
 
 # User/Group: vmail
-check_status_before_run adduser_vmail
+check_status_before_run add_required_users
 
 # Apache & PHP.
 check_status_before_run apache_php_config

File iRedMail/pkgs/get_all.sh

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 # Purpose:  Fetch all extra packages we need to build mail server.
 
 #---------------------------------------------------------------------

File iRedMail/samples/freshclam.init

 #!/bin/sh
 
-# Author: Zhang Huangbin (zhb(at)iredmail.org)
+# Author: Zhang Huangbin (zhb _at_ iredmail.org)
 
 #---------------------------------------------------------------------
 # This file is part of iRedMail, which is an open source mail server

File iRedMail/samples/iptables.init.debian

 #
 # This init.d script is used to control iptables, based on
 # /etc/init.d/iptables on Red Hat Enterprise Linux 5.3, modified
-# by Zhang Huangbin (zhb(at)iredmail.org), iRedMail project
+# by Zhang Huangbin (zhb _at_ iredmail.org), iRedMail project
 # (http://www.iredmail.org/).
 #
 

File iRedMail/tools/create_mail_user_OpenLDAP.py

 #!/usr/bin/env python
 # encoding: utf-8
 
-# Author: Zhang Huangbin <zhb(at)iredmail.org>
+# Author: Zhang Huangbin <zhb _at_ iredmail.org>
 # Purpose: Add new OpenLDAP user for postfix mail server.
 # Project:  iRedMail (http://www.iredmail.org/)
 

File iRedMail/tools/create_mail_user_OpenLDAP.sh

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 # Purpose: Add new OpenLDAP user for postfix mail server.
 # Project:  iRedMail (http://www.iredmail.org/)
 

File iRedMail/tools/create_mail_user_SQL.sh

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 # Purpose:  Import users to MySQL database from plain text file.
 # Project:  iRedMail (http://www.iredmail.org/)
 

File iRedMail/tools/dovecot-quota-warning.sh

 #!/bin/sh
 
-# Author:   Zhang Huangbin <zhb(at)iredmail.org>
+# Author:   Zhang Huangbin <zhb _at_ iredmail.org>
 # Purpose:  Send mail to notify user when his mailbox quota exceeds a
 #           specified limit.
 # Project:  iRedMail (http://www.iredmail.org/)

File iRedMail/tools/generate_ssl_keys.sh

 #!/usr/bin/env bash
 
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Author:   Zhang Huangbin (zhb _at_ iredmail.org)
 # Purpose:  Create new SSL keys.
 # Project:  iRedMail (http://www.iredmail.org/)