Commits

Zhang Huangbin  committed bf6b04d

Fixed: Too many open files on OpenBSD 5.2 with Dovecot-2.

  • Participants
  • Parent commits 9005139

Comments (0)

Files changed (2)

File iRedMail/functions/cleanup.sh

 
     cat ${TIP_FILE} >> /tmp/.tips.eml
     ${DOVECOT_DELIVER} -c ${DOVECOT_CONF} -f root@${HOSTNAME} -d ${tip_recipient} < /tmp/.tips.eml
+    rm -f /tmp/.tips.eml &>/dev/null
 
     cat > /tmp/.links.eml <<EOF
 From: root@${HOSTNAME}
 EOF
     cat ${DOC_FILE} >> /tmp/.links.eml
     ${DOVECOT_DELIVER} -c ${DOVECOT_CONF} -f root@${HOSTNAME} -d ${tip_recipient} < /tmp/.links.eml
+    rm -f /tmp/.links.eml &>/dev/null
 
     if [ X"${DISTRO}" == X'GENTOO' \
         -o X"${DISTRO}" == X'FREEBSD' \

File iRedMail/functions/dovecot2.sh

         check_status_before_run dovecot2_config
     fi
 
-    if [ X"${DISTRO}" == X"FREEBSD" ]; then
+    if [ X"${DISTRO}" == X'FREEBSD' ]; then
         # It seems there's a bug in Dovecot port, it will try to invoke '/usr/lib/sendmail'
         # to send vacation response which should be '/usr/sbin/mailwrapper'.
         [ ! -e /usr/lib/sendmail ] && ln -s /usr/sbin/mailwrapper /usr/lib/sendmail 2>/dev/null
 
         # Start dovecot when system start up.
         freebsd_enable_service_in_rc_conf 'dovecot_enable' 'YES'
+
+    elif [ X"${DISTRO}" == X'OPENBSD' ]; then
+        # By default, the _dovecot user, and so the Dovecot processes run in
+        # the login(1) class of "daemon". On a busy server, it may be advisable
+        # to put the _dovecot user and processes in their own login(1) class
+        # with tuned resources, such as more open file descriptors etc.
+        if [ -f /etc/login.conf ]; then
+            if ! grep '^dovecot:' /etc/login.conf &>/dev/null; then
+                cat >> /etc/login.conf <<EOF
+dovecot:\
+        :openfiles-cur=512:\
+        :openfiles-max=2048:\
+        :tc=daemon:
+EOF
+            fi
+
+            # Rebuild the login.conf.db file if necessary
+            [ -f /etc/login.conf.db ] && cap_mkdb /etc/login.conf
+        fi
     fi
 
     echo 'export status_enable_dovecot2="DONE"' >> ${STATUS_FILE}