Source

iredmail / iRedMail / functions / dovecot1.sh

Diff from to

iRedMail/functions/dovecot1.sh

 EOF
 
         if [ X"${BACKEND}" == X"OPENLDAP" ]; then
-            realtime_quota_db_name="${IREDADMIN_DB_NAME}"
-            realtime_quota_db_user="${IREDADMIN_DB_USER}"
-            realtime_quota_db_passwd="${IREDADMIN_DB_PASSWD}"
+            export realtime_quota_db_name="${IREDADMIN_DB_NAME}"
+            export realtime_quota_db_user="${IREDADMIN_DB_USER}"
+            export realtime_quota_db_passwd="${IREDADMIN_DB_PASSWD}"
         else
-            realtime_quota_db_name="${VMAIL_DB}"
-            realtime_quota_db_user="${VMAIL_DB_ADMIN_USER}"
-            realtime_quota_db_passwd="${VMAIL_DB_ADMIN_PASSWD}"
+            export realtime_quota_db_name="${VMAIL_DB}"
+            export realtime_quota_db_user="${VMAIL_DB_ADMIN_USER}"
+            export realtime_quota_db_passwd="${VMAIL_DB_ADMIN_PASSWD}"
         fi
 
-        cat > ${DOVECOT_REALTIME_QUOTA_CONF} <<EOF
-${CONF_MSG}
-connect = host=${MYSQL_SERVER} dbname=${realtime_quota_db_name} user=${realtime_quota_db_user} password=${realtime_quota_db_passwd}
-map {
-    pattern = priv/quota/storage
-    table = ${DOVECOT_REALTIME_QUOTA_TABLE}
-    username_field = username
-    value_field = bytes
-}
-map {
-    pattern = priv/quota/messages
-    table = ${DOVECOT_REALTIME_QUOTA_TABLE}
-    username_field = username
-    value_field = messages
-}
-EOF
 
+        # Copy sample config and set file owner/permission
+        cp ${SAMPLE_DIR}/dovecot/dovecot-used-quota.conf ${DOVECOT_REALTIME_QUOTA_CONF}
         chown ${DOVECOT_USER}:${DOVECOT_GROUP} ${DOVECOT_REALTIME_QUOTA_CONF}
         chmod 0500 ${DOVECOT_REALTIME_QUOTA_CONF}
 
+        # Replace place holders in sample config file
+        perl -pi -e 's#PH_SQL_SERVER#$ENV{SQL_SERVER}#' ${DOVECOT_REALTIME_QUOTA_CONF}
+        perl -pi -e 's#PH_REALTIME_QUOTA_DB_NAME#$ENV{realtime_quota_db_name}#' ${DOVECOT_REALTIME_QUOTA_CONF}
+        perl -pi -e 's#PH_REALTIME_QUOTA_DB_USER#$ENV{realtime_quota_db_user}#' ${DOVECOT_REALTIME_QUOTA_CONF}
+        perl -pi -e 's#PH_REALTIME_QUOTA_DB_PASSWORD#$ENV{realtime_quota_db_passwd}#' ${DOVECOT_REALTIME_QUOTA_CONF}
+        perl -pi -e 's#PH_DOVECOT_REALTIME_QUOTA_TABLE#$ENV{DOVECOT_REALTIME_QUOTA_TABLE}#' ${DOVECOT_REALTIME_QUOTA_CONF}
+
         # Create MySQL database ${IREDADMIN_DB_USER} and table 'used_quota'
         # which used to store realtime quota.
         if [ X"${BACKEND}" == X"OPENLDAP" -a X"${USE_IREDADMIN}" != X"YES" ]; then
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.