Commits

Zhang Huangbin  committed 72ad0fa

Code cleanup.

  • Participants
  • Parent commits e4e6298

Comments (0)

Files changed (17)

File iRedMail/conf/amavisd

 export AMAVISD_LOGROTATE_FILE="${LOGROTATE_DIR}/amavisd"
 export AMAVISD_DKIM_SELECTOR='dkim'
 export AMAVISD_DKIM_DIR='/var/lib/dkim'
+export AMAVISD_RC_SCRIPT_NAME='amavisd'
 
 # Database used to store incoming & outgoing email related information.
 export AMAVISD_DB_NAME='amavisd'
 
 if [ X"${DISTRO}" == X"RHEL" ]; then
     export AMAVISD_BIN='/usr/sbin/amavisd'
-    export AMAVISD_RC_SCRIPT_NAME='amavisd'
     export AMAVISD_LDAP_SCHEMA_NAME='amavisd-new.schema'
 
     if [ X"${DISTRO_VERSION}" == X"5" ]; then
 
 elif [ X"${DISTRO}" == X"GENTOO" ]; then
     export AMAVISD_BIN='/usr/sbin/amavisd'
-    export AMAVISD_RC_SCRIPT_NAME='amavisd'
     export AMAVISD_LDAP_SCHEMA_NAME='amavisd-new.schema'
 
     export AMAVISD_CONF='/etc/amavisd.conf'
     export AMAVISD_BIN='/usr/local/sbin/amavisd'
     export AMAVISD_CONF='/usr/local/etc/amavisd.conf'
     export AMAVISD_DKIM_CONF='/usr/local/etc/amavisd.conf'
-    export AMAVISD_RC_SCRIPT_NAME='amavisd'
     export AMAVISD_LDAP_SCHEMA_NAME='amavisd-new.schema'
     export AMAVISD_VIRUSMAILS_DIR='/var/virusmails'
 

File iRedMail/conf/apache_php

 # ---- Apache ----
 
 export HTTPD_PORT='80'
+export HTTPD_RC_SCRIPT_NAME='apache2'
 
 if [ X"${DISTRO}" == X"RHEL" ]; then
+    export HTTPD_RC_SCRIPT_NAME='httpd'
     # Apache configuration files.
     export HTTPD_CONF_ROOT="/etc/httpd"
     export HTTPD_CONF="${HTTPD_CONF_ROOT}/conf/httpd.conf"
     export PHP_INI='/etc/php/apache2-php5.3/php.ini'
 
 elif [ X"${DISTRO}" == X"FREEBSD" ]; then
+    export HTTPD_RC_SCRIPT_NAME='apache22'
+
     # Apache configuration files.
     export HTTPD_CONF_ROOT="/usr/local/etc/apache22"
     export HTTPD_CONF="${HTTPD_CONF_ROOT}/httpd.conf"
     # ---- PHP ----
     # Copy from example: /usr/local/etc/php.ini-production
     export PHP_INI='/usr/local/etc/php.ini'
-
-else
-    :
 fi
 
 export HTTPD_CGIBIN_DIR="${HTTPD_SERVERROOT}/cgi-bin"

File iRedMail/conf/clamav

 
 export CLAMAV_USER='clamav'
 export CLAMAV_GROUP='clamav'
+export CLAMAV_CLAMD_RC_SCRIPT_NAME='clamd'
+export CLAMAV_FRESHCLAMD_RC_SCRIPT_NAME='freshclamd'
 
 # Clamav.
 if [ X"${DISTRO}" == X"RHEL" ]; then
     export FRESHCLAM_INIT_FILE_SAMPLE="${SAMPLE_DIR}/freshclam.init"
 
 elif [ X"${DISTRO}" == X"SUSE" ]; then
+    export CLAMAV_FRESHCLAMD_RC_SCRIPT_NAME='freshclam'
+
     export CLAMD_CONF='/etc/clamd.conf'
     export FRESHCLAM_CONF='/etc/freshclam.conf'
 
 elif [ X"${DISTRO}" == X"DEBIAN" -o X"${DISTRO}" == X"UBUNTU" ]; then
+    export CLAMAV_CLAMD_RC_SCRIPT_NAME='clamav-daemon'
+    export CLAMAV_FRESHCLAMD_RC_SCRIPT_NAME='clamav-freshclam'
+
     export CLAMD_CONF='/etc/clamav/clamd.conf'
     export FRESHCLAM_CONF='/etc/clamav/freshclam.conf'
 

File iRedMail/conf/cluebringer

 
 export CLUEBRINGER_BINDHOST='127.0.0.1'
 export CLUEBRINGER_BINDPORT='10031'
+export CLUEBRINGER_RC_SCRIPT_NAME='cluebringer'
 
 # Database.
 export CLUEBRINGER_DB_NAME='cluebringer'
     export PKG_CLUEBRINGER='policyd'
     export CLUEBRINGER_CONF='/etc/policyd.conf'
     export CLUEBRINGER_WEBUI_CONF="/etc/cluebringer/cluebringer-webui.conf"
-    export CLUEBRINGER_INIT_SCRIPT="${DIR_RC_SCRIPTS}/policyd"
     export CLUEBRINGER_PID_FILE='/var/run/cluebringer/cbpolicyd.pid'
     export CLUEBRINGER_HTTPD_ROOT=''
 
     export PKG_CLUEBRINGER='policyd'
     export CLUEBRINGER_CONF='/etc/cluebringer/cluebringer.conf'
     export CLUEBRINGER_WEBUI_CONF="/etc/cluebringer/cluebringer-webui.conf"
-    export CLUEBRINGER_INIT_SCRIPT="${DIR_RC_SCRIPTS}/policyd"
     export CLUEBRINGER_PID_FILE='var/run/cluebringer/cbpolicyd.pid'
     export CLUEBRINGER_HTTPD_ROOT=''
 
     export PKG_CLUEBRINGER='postfix-cluebringer'
     export CLUEBRINGER_CONF='/etc/cluebringer/cluebringer.conf'
     export CLUEBRINGER_WEBUI_CONF="/etc/cluebringer/cluebringer-webui.conf"
-    export CLUEBRINGER_INIT_SCRIPT="${DIR_RC_SCRIPTS}/postfix-policyd"
+    export CLUEBRINGER_RC_SCRIPT_NAME='postfix-cluebringer'
     export CLUEBRINGER_PID_FILE='var/run/cluebringer/cbpolicyd.pid'
     export CLUEBRINGER_HTTPD_ROOT='/usr/share/postfix-cluebringer-webui/webui'
 
     export PKG_CLUEBRINGER='postfix-policyd-sf'
     export CLUEBRINGER_CONF='/usr/local/etc/postfix-policyd-sf.conf'
     export CLUEBRINGER_WEBUI_CONF="/usr/local/etc/cluebringer/cluebringer-webui.conf"
-    export CLUEBRINGER_INIT_SCRIPT="${DIR_RC_SCRIPTS}/policyd"
     export CLUEBRINGER_PID_FILE='var/run/cluebringer/cbpolicyd.pid'
     export CLUEBRINGER_HTTPD_ROOT=''
 
     :
 fi
 
+export CLUEBRINGER_RC_SCRIPT="${DIR_RC_SCRIPTS}/${CLUEBRINGER_RC_SCRIPT_NAME}"
+
 export MYSQL_BACKUP_DATABASES="${MYSQL_BACKUP_DATABASES} ${CLUEBRINGER_DB_NAME}"

File iRedMail/conf/dovecot

 # Dovecot user & group.
 export DOVECOT_USER='dovecot'
 export DOVECOT_GROUP='dovecot'
+export DOVECOT_RC_SCRIPT_NAME='dovecot'
 
 # Dovecot running directory, required by dovecot-2.x.
 export DOVECOT_BASE_DIR='/var/run/dovecot'

File iRedMail/conf/fail2ban

 # Variables for Fail2ban and related.
 
 export FAIL2BAN_CONF_ROOT='/etc/fail2ban'
+export FAIL2BAN_RC_SCRIPT_NAME='fail2ban'
 
 if [ X"${DISTRO}" == X"RHEL" ]; then
     export FAIL2BAN_SSHD_LOGFILE='/var/log/secure'

File iRedMail/conf/mysql

 export MYSQL_SOCKET='/var/lib/mysql/mysql.sock'
 export MYSQL_ROOT_USER='root'
 
+export MYSQL_RC_SCRIPT_NAME='mysql'
+
 # MySQL config file.
 if [ X"${DISTRO}" == X"RHEL" ]; then
-    export MYSQLD_INIT_SCRIPT="${DIR_RC_SCRIPTS}/mysqld"
+    export MYSQL_RC_SCRIPT_NAME='mysqld'
 
 elif [ X"${DISTRO}" == X"SUSE" ]; then
     export MYSQL_SOCKET='/var/run/mysql/mysql.sock'
-    export MYSQLD_INIT_SCRIPT="${DIR_RC_SCRIPTS}/mysql"
 
 elif [ X"${DISTRO}" == X"UBUNTU" -o X"${DISTRO}" == X"DEBIAN" ]; then
     export MYSQL_MY_CNF='/etc/mysql/my.cnf'
-    export MYSQLD_INIT_SCRIPT="${DIR_RC_SCRIPTS}/mysql"
 
 elif [ X"${DISTRO}" == X"GENTOO" ]; then
     export MYSQL_MY_CNF='/etc/mysql/my.cnf'
     export MYSQL_SOCKET='/var/run/mysqld/mysql.sock'
-    export MYSQLD_INIT_SCRIPT="${DIR_RC_SCRIPTS}/mysql"
 
 elif [ X"${DISTRO}" == X"FREEBSD" ]; then
     export MYSQL_SOCKET='/tmp/mysql.sock'
     export MYSQL_MY_CNF="/var/db/mysql/my.cnf"
-    export MYSQLD_INIT_SCRIPT="${DIR_RC_SCRIPTS}/mysql-server"
 fi
 
+export MYSQLD_RC_SCRIPT="${DIR_RC_SCRIPTS}/${MYSQL_RC_SCRIPT_NAME}"
 export MYSQL_INIT_SQL="${CONF_DIR}/mysql_init.sql"
 export MYSQL_VMAIL_SQL="${CONF_DIR}/mysql_vmail.sql"
 

File iRedMail/conf/openldap

 export LDAP_BIND='yes'
 export LDAP_BIND_VERSION='3'
 
+export LDAP_RC_SCRIPT_NAME='slapd'
+
 # Database backend type.
 # Note:
 #   * We use the same database type on all distributions to reduce our
         export LDAP_RC_SCRIPT_NAME='ldap'
     else
         export OPENLDAP_VERSION='2.4'
-        export LDAP_RC_SCRIPT_NAME='slapd'
     fi
 
     # LDAP daemon user & group.
 
     export OPENLDAP_SYSCONFIG_CONF="${ETC_SYSCONFIG_DIR}/ldap"
 
-    # RC script.
-    export LDAP_INIT_SCRIPT="${DIR_RC_SCRIPTS}/${LDAP_RC_SCRIPT_NAME}"
-
     # Module related.
     export OPENLDAP_MODULE_PATH='/usr/lib/openldap'
 
 
     export OPENLDAP_SYSCONFIG_CONF="${ETC_SYSCONFIG_DIR}/openldap"
 
-    # RC script.
-    export LDAP_INIT_SCRIPT="${DIR_RC_SCRIPTS}/ldap"
+    # RC script
+    export LDAP_RC_SCRIPT_NAME='ldap'
 
 elif [ X"${DISTRO}" == X"DEBIAN" -o X"${DISTRO}" == X"UBUNTU" ]; then
     # OpenLDAP version.
     # Module related.
     export OPENLDAP_MODULE_PATH='/usr/lib/ldap'
 
-    # RC script.
-    export LDAP_INIT_SCRIPT="${DIR_RC_SCRIPTS}/slapd"
-
 elif [ X"${DISTRO}" == X"GENTOO" ]; then
     # OpenLDAP version.
     export OPENLDAP_VERSION='2.4'
-    export LDAP_RC_SCRIPT_NAME='slapd'
 
     # LDAP daemon user & group.
     export LDAP_USER='ldap'
 
     export OPENLDAP_SYSCONFIG_CONF="${ETC_SYSCONFIG_DIR}/slapd"
 
-    # RC script.
-    export LDAP_INIT_SCRIPT="${DIR_RC_SCRIPTS}/${LDAP_RC_SCRIPT_NAME}"
-
     # Module related.
     export OPENLDAP_MODULE_PATH='/usr/lib/openldap/openldap'
 
     export OPENLDAP_CONF_ROOT='/usr/local/etc/openldap'
     export OPENLDAP_DB_CONFIG_SAMPLE="${OPENLDAP_CONF_ROOT}/DB_CONFIG.example"
 
-
     # Module related.
     export OPENLDAP_MODULE_PATH='/usr/local/libexec/openldap'
 
-    # RC script.
-    export LDAP_INIT_SCRIPT="${DIR_RC_SCRIPTS}/slapd"
-
     # Override default setting.
     export OPENLDAP_DATA_DIR='/var/db/openldap-data'    # Do *NOT* end with '/'.
 else
     :
 fi
 
+# RC script.
+export LDAP_RC_SCRIPT="${DIR_RC_SCRIPTS}/${LDAP_RC_SCRIPT_NAME}"
+
 export OPENLDAP_SCHEMA_DIR="${OPENLDAP_CONF_ROOT}/schema"
 export OPENLDAP_SLAPD_CONF="${OPENLDAP_CONF_ROOT}/slapd.conf"
 export OPENLDAP_LDAP_CONF="${OPENLDAP_CONF_ROOT}/ldap.conf"

File iRedMail/conf/policyd

 export POLICYD_BINDHOST='127.0.0.1' # Default value in policyd.conf.
 export POLICYD_BINDPORT='10031' # Default value in policyd.conf.
 
+export POLICYD_RC_SCRIPT_NAME='policyd'
 export POLICYD_DB_PASSWD="$(${RANDOM_STRING})"
 
 export POLICYD_USER='policyd'
     export POLICYD_CONF='/etc/policyd.conf'
     export POLICYD_THROTTLE_CONF='/etc/policyd_sender_throttle.conf'
     export POLICYD_THROTTLE_PIDFILE='/var/run/policyd_sender_throttle.pid'
-    export POLICYD_INIT_SCRIPT="${DIR_RC_SCRIPTS}/policyd"
 
     # Database.
     export POLICYD_DB_NAME='policyd'
     export POLICYD_CONF='/etc/policyd.conf'
     export POLICYD_THROTTLE_CONF='/etc/policyd_sender_throttle.conf'
     export POLICYD_THROTTLE_PIDFILE='/var/run/policyd_sender_throttle.pid'
-    export POLICYD_INIT_SCRIPT="${DIR_RC_SCRIPTS}/policyd"
 
     # Database.
     export POLICYD_DB_NAME='policyd'
     export PKG_POLICYD='postfix-policyd'
     export POLICYD_CONF='/etc/postfix-policyd.conf'
     export POLICYD_THROTTLE_CONF='/etc/postfix-policyd_throttle.conf'
-    export POLICYD_INIT_SCRIPT="${DIR_RC_SCRIPTS}/postfix-policyd"
+    export POLICYD_RC_SCRIPT_NAME="postfix-policyd"
 
     # Database.
     export POLICYD_DB_NAME='postfixpolicyd'
     export POLICYD_CONF='/etc/policyd.conf'
     export POLICYD_THROTTLE_CONF='/etc/policyd_sender_throttle.conf'
     export POLICYD_THROTTLE_PIDFILE='/var/run/policyd_sender_throttle.pid'
-    export POLICYD_INIT_SCRIPT="${DIR_RC_SCRIPTS}/policyd"
 
     # Database.
     export POLICYD_DB_NAME='policyd'
     export PKG_POLICYD='postfix-policyd-sf'
     export POLICYD_CONF='/usr/local/etc/postfix-policyd-sf.conf'
     export POLICYD_THROTTLE_CONF='/usr/local/etc/policyd_throttle.conf'
-    export POLICYD_INIT_SCRIPT="${DIR_RC_SCRIPTS}/policyd"
 
     # Database.
     export POLICYD_DB_NAME='policyd'
     :
 fi
 
+export POLICYD_RC_SCRIPT="${DIR_RC_SCRIPTS}/${POLICYD_RC_SCRIPT_NAME}"
 export MYSQL_BACKUP_DATABASES="${MYSQL_BACKUP_DATABASES} ${POLICYD_DB_NAME}"

File iRedMail/conf/postfix

 export POSTFIX_DAEMON_USER='postfix'
 export POSTFIX_DAEMON_GROUP='postfix'
 
+export POSTFIX_ROOTDIR='/etc/postfix'
+export POSTFIX_RC_SCRIPT_NAME='postfix'
+
 # Mail log files.
 if [ X"${DISTRO}" == X"RHEL" -o X"${DISTRO}" == X"FREEBSD" ]; then
-    # RHEL, CentOS, FreeBSD
+    # RHEL, CentOS
     export MAILLOG='/var/log/maillog'
-    export MAILLOG_INFO=''
-    export MAILLOG_ERROR=''
-    export MAILLOG_WARN=''
 elif [ X"${DISTRO}" == X"SUSE" ]; then
     export MAILLOG='/var/log/mail'
     export MAILLOG_INFO='/var/log/mail.info'
 elif [ X"${DISTRO}" == X"GENTOO" ]; then
     # Gentoo
     export MAILLOG='/var/log/maillog'
-    export MAILLOG_INFO=''
-    export MAILLOG_ERROR=''
-    export MAILLOG_WARN=''
-fi
-
-if [ X"${DISTRO}" == X"FREEBSD" ]; then
+elif [ X"${DISTRO}" == X"FREEBSD" ]; then
+    # FreeBSD
     export POSTFIX_ROOTDIR='/usr/local/etc/postfix'
-else
-    export POSTFIX_ROOTDIR='/etc/postfix'
+    export MAILLOG='/var/log/maillog'
 fi
 
 # You do *NOT* need to modify them.

File iRedMail/conf/postgresql

 export PGSQL_DOT_PGPASS="${PGSQL_SYS_USER_HOME}/.pgpass"
 
 export PGSQL_VERSION='9.1'
-export PGSQL_INIT_SCRIPT="${DIR_RC_SCRIPTS}/postgresql"
-[ X"${DISTRO}" == X"GENTOO" ] && \
-    export PGSQL_INIT_SCRIPT="${DIR_RC_SCRIPTS}/postgresql-${PGSQL_VERSION}"
+export PGSQL_RC_SCRIPT_NAME='postgresql'
+
+if [ X"${DISTRO}" == X"GENTOO" ]; then
+    export PGSQL_RC_SCRIPT="${DIR_RC_SCRIPTS}/postgresql-${PGSQL_VERSION}"
+else
+    export PGSQL_RC_SCRIPT="${DIR_RC_SCRIPTS}/postgresql"
+fi
+
 export PGSQL_VMAIL_STRUCTURE_SAMPLE="${SAMPLE_DIR}/iredmail.pgsql"
 export PGSQL_INIT_SQL_SAMPLE="${CONF_DIR}/pgsql_init.pgsql"
 

File iRedMail/functions/cluebringer.sh

         - ${CLUEBRINGER_CONF}
         - ${CLUEBRINGER_WEBUI_CONF}
     * RC script:
-        - ${CLUEBRINGER_INIT_SCRIPT}
+        - ${CLUEBRINGER_RC_SCRIPT}
     * Database:
         - Database name: ${CLUEBRINGER_DB_NAME}
         - Database user: ${CLUEBRINGER_DB_USER}

File iRedMail/functions/mysql.sh

 mysql_enable="YES"
 EOF
 
-    ${MYSQLD_INIT_SCRIPT} restart >/dev/null 2>&1
+    ${MYSQLD_RC_SCRIPT} restart >/dev/null 2>&1
 
     ECHO_DEBUG -n "Sleep 5 seconds for MySQL daemon initialize:"
     sleep 5
     * Vmail admin account (read-write):
         - Name: ${VMAIL_DB_ADMIN_USER}, Password: ${VMAIL_DB_ADMIN_PASSWD}
     * Database stored in: /var/lib/mysql
-    * RC script: ${MYSQLD_INIT_SCRIPT}
+    * RC script: ${MYSQLD_RC_SCRIPT}
     * Log file: /var/log/mysqld.log
     * See also:
         - ${MYSQL_INIT_SQL}

File iRedMail/functions/openldap.sh

     ECHO_INFO "Configure OpenLDAP server."
 
     ECHO_DEBUG "Stoping OpenLDAP."
-    ${LDAP_INIT_SCRIPT} stop &>/dev/null
+    ${LDAP_RC_SCRIPT} stop &>/dev/null
 
     backup_file ${OPENLDAP_SLAPD_CONF} ${OPENLDAP_LDAP_CONF}
 
     chmod -R 0700 ${OPENLDAP_DATA_DIR}
 
     ECHO_DEBUG "Starting OpenLDAP."
-    ${LDAP_INIT_SCRIPT} restart &>/dev/null
+    ${LDAP_RC_SCRIPT} restart &>/dev/null
 
     ECHO_DEBUG -n "Sleep 5 seconds for LDAP daemon initialize:"
     sleep 5
         - ${LDAP_DATA_DIR}
         - ${LDAP_DATA_DIR}/DB_CONFIG
     * RC script:
-        - ${LDAP_INIT_SCRIPT}
+        - ${LDAP_RC_SCRIPT}
     * See also:
         - ${LDAP_INIT_LDIF}
 

File iRedMail/functions/packages.sh

     #
     if [ X"${BACKEND}" == X"OPENLDAP" ]; then
         # OpenLDAP server & client.
+        ENABLED_SERVICES="${ENABLED_SERVICES} ${LDAP_RC_SCRIPT_NAME} ${MYSQL_RC_SCRIPT_NAME}"
+
         if [ X"${DISTRO}" == X"RHEL" ]; then
-            ALL_PKGS="${ALL_PKGS} openldap${PKG_ARCH} openldap-clients${PKG_ARCH} openldap-servers${PKG_ARCH}"
-            ENABLED_SERVICES="${ENABLED_SERVICES} ${LDAP_RC_SCRIPT_NAME}"
-
-            # MySQL server and client.
-            ALL_PKGS="${ALL_PKGS} mysql-server${PKG_ARCH} mysql${PKG_ARCH}"
-            ENABLED_SERVICES="${ENABLED_SERVICES} mysqld"
+            ALL_PKGS="${ALL_PKGS} openldap${PKG_ARCH} openldap-clients${PKG_ARCH} openldap-servers${PKG_ARCH} mysql-server${PKG_ARCH} mysql${PKG_ARCH}"
 
         elif [ X"${DISTRO}" == X"SUSE" ]; then
-            ALL_PKGS="${ALL_PKGS} openldap2 openldap2-client"
-            ENABLED_SERVICES="${ENABLED_SERVICES} ldap"
+            ALL_PKGS="${ALL_PKGS} openldap2 openldap2-client mysql-community-server mysql-community-server-client"
 
-            # MySQL server and client.
-            ALL_PKGS="${ALL_PKGS} mysql-community-server mysql-community-server-client"
-            ENABLED_SERVICES="${ENABLED_SERVICES} mysql"
         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"
+            ALL_PKGS="${ALL_PKGS} postfix-ldap slapd ldap-utils libnet-ldap-perl mysql-server mysql-client"
 
-            # MySQL server and client.
-            ALL_PKGS="${ALL_PKGS} mysql-server mysql-client"
-            ENABLED_SERVICES="${ENABLED_SERVICES} mysql"
         elif [ X"${DISTRO}" == X"GENTOO" ]; then
-            ALL_PKGS="${ALL_PKGS} openldap"
-            ENABLED_SERVICES="${ENABLED_SERVICES} slapd"
+            ALL_PKGS="${ALL_PKGS} openldap mysql"
 
-            # MySQL server and client.
-            ALL_PKGS="${ALL_PKGS} mysql"
-            ENABLED_SERVICES="${ENABLED_SERVICES} mysql"
         fi
     elif [ X"${BACKEND}" == X"MYSQL" ]; then
         # MySQL server & client.
+        ENABLED_SERVICES="${ENABLED_SERVICES} ${MYSQL_RC_SCRIPT_NAME}"
         if [ X"${DISTRO}" == X"RHEL" ]; then
-            # MySQL server and client.
             ALL_PKGS="${ALL_PKGS} mysql-server${PKG_ARCH} mysql${PKG_ARCH}"
-            ENABLED_SERVICES="${ENABLED_SERVICES} mysqld"
 
             # For Awstats.
             [ X"${USE_AWSTATS}" == X"YES" ] && ALL_PKGS="${ALL_PKGS} mod_auth_mysql${PKG_ARCH}"
 
         elif [ X"${DISTRO}" == X"SUSE" ]; then
-            # MySQL server and client.
             ALL_PKGS="${ALL_PKGS} mysql-community-server mysql-community-server-client"
-            ENABLED_SERVICES="${ENABLED_SERVICES} mysql"
 
             [ X"${USE_AWSTATS}" == X"YES" ] && ALL_PKGS="${ALL_PKGS} postfix-mysql apache2-mod_auth_mysql"
 
         elif [ X"${DISTRO}" == X"DEBIAN" -o X"${DISTRO}" == X"UBUNTU" ]; then
             # MySQL server and client.
-            ALL_PKGS="${ALL_PKGS} mysql-server mysql-client"
-            ENABLED_SERVICES="${ENABLED_SERVICES} mysql"
-
-            # Postfix module
-            ALL_PKGS="${ALL_PKGS} postfix-mysql"
+            ALL_PKGS="${ALL_PKGS} mysql-server mysql-client postfix-mysql"
 
             # For Awstats.
             [ X"${USE_AWSTATS}" == X"YES" ] && ALL_PKGS="${ALL_PKGS} libapache2-mod-auth-mysql"
 
         elif [ X"${DISTRO}" == X'GENTOO' ]; then
             ALL_PKGS="${ALL_PKGS} mysql mod_auth_mysql"
-            ENABLED_SERVICES="${ENABLED_SERVICES} mysql"
+
         fi
     elif [ X"${BACKEND}" == X"PGSQL" ]; then
+        ENABLED_SERVICES="${ENABLED_SERVICES} ${PGSQL_RC_SCRIPT_NAME}"
+
+        # iRedAPD doesn't work with PGSQL
         export USE_IREDAPD='NO'
 
         # PGSQL server & client.
         if [ X"${DISTRO}" == X"RHEL" ]; then
-            ALL_PKGS="${ALL_PKGS} postgresql-server"
-            ENABLED_SERVICES="${ENABLED_SERVICES} postgresql"
+            ALL_PKGS="${ALL_PKGS} postgresql-server postgresql-contrib"
 
         elif [ X"${DISTRO}" == X"SUSE" ]; then
-            ALL_PKGS="${ALL_PKGS} postgresql-server"
-            ENABLED_SERVICES="${ENABLED_SERVICES} postgresql"
+            ALL_PKGS="${ALL_PKGS} postgresql-server postgresql-contrib postfix-postgresql"
 
         elif [ X"${DISTRO}" == X"DEBIAN" -o X"${DISTRO}" == X"UBUNTU" ]; then
             # postgresql-contrib provides extension 'dblink' used in Roundcube password plugin.
-            ALL_PKGS="${ALL_PKGS} postgresql postgresql-client postgresql-contrib"
-            ENABLED_SERVICES="${ENABLED_SERVICES} postgresql"
+            ALL_PKGS="${ALL_PKGS} postgresql postgresql-client postgresql-contrib postfix-pgsql"
 
-            # Postfix module
-            ALL_PKGS="${ALL_PKGS} postfix-pgsql"
         elif [ X"${DISTRO}" == X'GENTOO' ]; then
             ALL_PKGS="${ALL_PKGS} postgresql-server mod_auth_pgsql"
-            ENABLED_SERVICES="${ENABLED_SERVICES} postgresql-${PGSQL_VERSION}"
         fi
     fi
 
     #################
     # Apache and PHP.
     #
+    ENABLED_SERVICES="${ENABLED_SERVICES} ${HTTPD_RC_SCRIPT_NAME}"
     if [ X"${DISTRO}" == X"RHEL" ]; then
         ALL_PKGS="${ALL_PKGS} httpd${PKG_ARCH} mod_ssl${PKG_ARCH} php${PKG_ARCH} php-common${PKG_ARCH} php-gd${PKG_ARCH} php-xml${PKG_ARCH} php-mysql${PKG_ARCH} php-ldap${PKG_ARCH}"
         if [ X"${DISTRO_VERSION}" == X"5" ]; then
             ALL_PKGS="${ALL_PKGS} php-imap${PKG_ARCH} libmcrypt${PKG_ARCH} php-mcrypt${PKG_ARCH} php-mhash${PKG_ARCH} php-mbstring${PKG_ARCH}"
         fi
-        ENABLED_SERVICES="${ENABLED_SERVICES} httpd"
 
     elif [ X"${DISTRO}" == X"SUSE" ]; then
         ALL_PKGS="${ALL_PKGS} apache2-prefork apache2-mod_php5 php5-iconv php5-ldap php5-mysql php5-mcrypt php5-mbstring php5-gettext php5-dom php5-json php5-intl php5-fileinfo"
         if [ X"${DISTRO_VERSION}" == X"11.3" -o X"${DISTRO_VERSION}" == X"11.4" ]; then
             ALL_PKGS="${ALL_PKGS} php5-hash"
         fi
-        ENABLED_SERVICES="${ENABLED_SERVICES} apache2"
 
     elif [ X"${DISTRO}" == X"DEBIAN" -o X"${DISTRO}" == X"UBUNTU" ]; then
         ALL_PKGS="${ALL_PKGS} apache2 apache2-mpm-prefork apache2.2-common libapache2-mod-php5 php5-cli php5-imap php5-gd php5-mcrypt php5-mysql php5-ldap php5-pgsql"
             fi
         fi
 
-        ENABLED_SERVICES="${ENABLED_SERVICES} apache2"
     elif [ X"${DISTRO}" == X'GENTOO' ]; then
         ALL_PKGS="${ALL_PKGS} apache php"
-        ENABLED_SERVICES="${ENABLED_SERVICES} apache2"
         gentoo_add_use_flags 'dev-libs/apr-util' 'ldap'
         gentoo_add_use_flags 'www-servers/apache' 'ssl doc ldap suexec'
         gentoo_add_make_conf 'APACHE2_MODULES' 'actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias auth_digest authn_dbd log_forensic proxy proxy_ajp proxy_balancer proxy_connect proxy_ftp proxy_http proxy_scgi substitute version'
     ###############
     # Postfix.
     #
+    ENABLED_SERVICES="${ENABLED_SERVICES} ${POSTFIX_RC_SCRIPT_NAME}"
     if [ X"${DISTRO}" == X"RHEL" ]; then
         ALL_PKGS="${ALL_PKGS} postfix${PKG_ARCH}"
     elif [ X"${DISTRO}" == X"SUSE" ]; then
         gentoo_add_use_flags 'mail-mta/postfix' 'ipv6 pam ssl cdb dovecot-sasl hardened ldap ldap-bind mbox mysql postgres sasl'
     fi
 
-    ENABLED_SERVICES="${ENABLED_SERVICES} postfix"
-
     # Policyd.
     if [ X"${DISTRO}" == X"RHEL" ]; then
         ALL_PKGS="${ALL_PKGS} policyd${PKG_ARCH}"
-        ENABLED_SERVICES="${ENABLED_SERVICES} policyd"
+        ENABLED_SERVICES="${ENABLED_SERVICES} ${POLICYD_RC_SCRIPT_NAME}"
     elif [ X"${DISTRO}" == X"SUSE" ]; then
         ALL_PKGS="${ALL_PKGS} policyd"
-        ENABLED_SERVICES="${ENABLED_SERVICES} policyd"
+        ENABLED_SERVICES="${ENABLED_SERVICES} ${POLICYD_RC_SCRIPT_NAME}"
     elif [ X"${DISTRO}" == X"DEBIAN" -o X"${DISTRO}" == X"UBUNTU" ]; then
         if [ X"${DISTRO_CODENAME}" == X"oneiric" \
             -o X"${DISTRO_CODENAME}" == X"precise" \
             ]; then
             # Policyd-2.x, code name "cluebringer".
             ALL_PKGS="${ALL_PKGS} postfix-cluebringer postfix-cluebringer-webui"
-            ENABLED_SERVICES="${ENABLED_SERVICES} postfix-cluebringer"
+            ENABLED_SERVICES="${ENABLED_SERVICES} ${CLUEBRINGER_RC_SCRIPT_NAME}"
 
             if [ X"${BACKEND}" == X"OPENLDAP" -o X"${BACKEND}" == X"MYSQL" ]; then
                 ALL_PKGS="${ALL_PKGS} postfix-cluebringer-mysql"
             fi
         else
             ALL_PKGS="${ALL_PKGS} postfix-policyd"
-            ENABLED_SERVICES="${ENABLED_SERVICES} postfix-policyd"
+            ENABLED_SERVICES="${ENABLED_SERVICES} ${POLICYD_RC_SCRIPT_NAME}"
         fi
 
 
         fi
     elif [ X"${DISTRO}" == X'GENTOO' ]; then
         ALL_PKGS="${ALL_PKGS} policyd"
-        ENABLED_SERVICES="${ENABLED_SERVICES} policyd"
+        ENABLED_SERVICES="${ENABLED_SERVICES} ${POLICYD_RC_SCRIPT_NAME}"
     fi
 
     # Dovecot.
             ALL_PKGS="${ALL_PKGS} dovecot${PKG_ARCH} dovecot-managesieve${PKG_ARCH} dovecot-pigeonhole${PKG_ARCH}"
         fi
 
-        # We will use Dovecot SASL auth mechanism, so 'saslauthd'
-        # is not necessary, should be disabled.
+        # We use Dovecot SASL auth instead of saslauthd
         DISABLED_SERVICES="${DISABLED_SERVICES} saslauthd"
 
     elif [ X"${DISTRO}" == X"SUSE" ]; then
         gentoo_add_use_flags 'net-mail/dovecot' 'bzip2 ipv6 maildir pam ssl zlib caps doc kerberos ldap managesieve mbox mdbox mysql postgres sdbox sieve sqlite suid'
     fi
 
-    ENABLED_SERVICES="${ENABLED_SERVICES} dovecot"
+    ENABLED_SERVICES="${ENABLED_SERVICES} ${DOVECOT_RC_SCRIPT_NAME}"
 
     # Amavisd-new & ClamAV & Altermime.
+    ENABLED_SERVICES="${ENABLED_SERVICES} ${AMAVISD_RC_SCRIPT_NAME} ${CLAMAV_CLAMD_RC_SCRIPT_NAME}"
     if [ X"${DISTRO}" == X"RHEL" ]; then
         ALL_PKGS="${ALL_PKGS} clamd${PKG_ARCH} clamav${PKG_ARCH} clamav-db${PKG_ARCH} spamassassin${PKG_ARCH} altermime${PKG_ARCH} perl-LDAP.noarch"
         if [ X"${DISTRO_VERSION}" == X"5" ]; then
         else
             ALL_PKGS="${ALL_PKGS} amavisd-new.noarch"
         fi
-        ENABLED_SERVICES="${ENABLED_SERVICES} ${AMAVISD_RC_SCRIPT_NAME} clamd"
         DISABLED_SERVICES="${DISABLED_SERVICES} spamassassin"
 
     elif [ X"${DISTRO}" == X"SUSE" ]; then
         ALL_PKGS="${ALL_PKGS} amavisd-new clamav clamav-db spamassassin altermime perl-ldap perl-DBD-mysql"
-        ENABLED_SERVICES="${ENABLED_SERVICES} ${AMAVISD_RC_SCRIPT_NAME} clamd freshclam"
+        ENABLED_SERVICES="${ENABLED_SERVICES} ${CLAMAV_FRESHCLAMD_RC_SCRIPT_NAME}"
         DISABLED_SERVICES="${DISABLED_SERVICES} clamav-milter spamd spampd"
 
     elif [ X"${DISTRO}" == X"DEBIAN" -o X"${DISTRO}" == X"UBUNTU" ]; then
         ALL_PKGS="${ALL_PKGS} amavisd-new libcrypt-openssl-rsa-perl libmail-dkim-perl clamav-freshclam clamav-daemon spamassassin altermime arj zoo nomarch cpio lzop cabextract p7zip rpm unrar-free ripole"
-        ENABLED_SERVICES="${ENABLED_SERVICES} ${AMAVISD_RC_SCRIPT_NAME} clamav-daemon clamav-freshclam"
+        ENABLED_SERVICES="${ENABLED_SERVICES} ${CLAMAV_FRESHCLAMD_RC_SCRIPT_NAME}"
         DISABLED_SERVICES="${DISABLED_SERVICES} spamassassin"
 
     elif [ X"${DISTRO}" == X'GENTOO' ]; then
         ALL_PKGS="${ALL_PKGS} amavisd-new spamassassin clamav altermime"
-        ENABLED_SERVICES="${ENABLED_SERVICES} ${AMAVISD_RC_SCRIPT_NAME} clamd"
         DISABLED_SERVICES="${DISABLED_SERVICES} spamd"
 
         gentoo_add_use_flags 'mail-filter/amavisd-new' 'dkim ldap mysql postgres razor snmp spamassassin'
 
     #### Fail2ban ####
     if [ X"${USE_FAIL2BAN}" == X"YES" ]; then
-        if [ X"${DISTRO}" == X"RHEL" -o \
-            X"${DISTRO}" == X"DEBIAN" -o \
-            X"${DISTRO}" == X"UBUNTU" -o \
-            X"${DISTRO}" == X"SUSE" \
-            ]; then
-            ALL_PKGS="${ALL_PKGS} fail2ban"
-            ENABLED_SERVICES="${ENABLED_SERVICES} fail2ban"
-        elif [ X"${DISTRO}" == X'GENTOO' ]; then
-            ALL_PKGS="${ALL_PKGS} fail2ban"
-            ENABLED_SERVICES="${ENABLED_SERVICES} fail2ban"
-        fi
+        ALL_PKGS="${ALL_PKGS} fail2ban"
+        ENABLED_SERVICES="${ENABLED_SERVICES} ${FAIL2BAN_RC_SCRIPT_NAME}"
 
         if [ X"${DISTRO}" == X"RHEL" ]; then
             DISABLED_SERVICES="${DISABLED_SERVICES} shorewall"

File iRedMail/functions/packages_freebsd.sh

 
     ALL_PKGS="${ALL_PKGS} apache"
     ALL_PORTS="${ALL_PORTS} www/apache22"
-    ENABLED_SERVICES="${ENABLED_SERVICES} apache22"
+    ENABLED_SERVICES="${ENABLED_SERVICES} ${HTTPD_RC_SCRIPT_NAME}"
 
     # PHP5. REQUIRED.
     cat > /var/db/ports/php5/options <<EOF

File iRedMail/functions/postgresql.sh

     ln -s ${PGSQL_SSL_KEY} ${PGSQL_DATA_DIR}/server.key >/dev/null
 
     ECHO_DEBUG "Start PostgreSQL server"
-    ${PGSQL_INIT_SCRIPT} restart >/dev/null 2>&1
+    ${PGSQL_RC_SCRIPT} restart >/dev/null 2>&1
 
     ECHO_DEBUG -n "Sleep 5 seconds for PostgreSQL daemon initialize:"
     sleep 5
     * Vmail admin account (read-write):
         - Name: ${VMAIL_DB_ADMIN_USER}, Password: ${VMAIL_DB_ADMIN_PASSWD}
     * Database stored in: ${PGSQL_DATA_DIR}
-    * RC script: ${PGSQL_INIT_SCRIPT}
+    * RC script: ${PGSQL_RC_SCRIPT}
     * Log file: /var/log/postgresql/
     * See also:
         - ${PGSQL_INIT_SQL_SAMPLE}