[Dovecot] utility to update indexes ?
We have both dovecot and a webmail application that are both modifying our users maildirs, so dovecot indexes can be out of sync when the webmail has been messing with the maildirs. We also have a webservice that report how many unread messages a user has in his inbox, which is simply counting files in the maildirs (plus caching the result, and present old values if the directory timestamps hasn´t changed).
I think this checking of unread messages webservice would be much nicer on the filesystem if it instead used the dovecot indexes, so I created a small utility based on utils/idxview.c that do that: http://blag.tanso.net/code/unread.c
But this woun´t work if the maildir has been modified outside of dovecot (i.e. webmail usage). Are there any simple interface I can use in this short snippet for noticing that the index is out of sync, and update it ?
-jf
On Thu, 2011-01-20 at 23:50 +0100, Jan-Frode Myklebust wrote:
But this woun´t work if the maildir has been modified outside of dovecot (i.e. webmail usage). Are there any simple interface I can use in this short snippet for noticing that the index is out of sync, and update it ?
With v2.0 you could use doveadm easily (you can also just use doveadm binary from v2.0 and keep using v1.2 elsewhere):
doveadm mailbox status unseen inbox
If you're actually running v2.0 you can also ask this information via UNIX/TCP socket.
On Fri, Jan 21, 2011 at 01:08:09AM +0200, Timo Sirainen wrote:
On Thu, 2011-01-20 at 23:50 +0100, Jan-Frode Myklebust wrote:
But this woun´t work if the maildir has been modified outside of dovecot (i.e. webmail usage). Are there any simple interface I can use in this short snippet for noticing that the index is out of sync, and update it ?
With v2.0 you could use doveadm easily (you can also just use doveadm binary from v2.0 and keep using v1.2 elsewhere):
doveadm mailbox status unseen inbox
This sounds great, but I'm struggeling to get it working... It complains about:
$ doveadm -v mailbox status -u user@example.com unseen inbox doveadm(user@example.com): Error: userdb lookup: connect(/usr/local/dovecot-2.0.9/var/run/dovecot/auth-userdb) failed: No such file or directory doveadm(user@example.com): Fatal: User lookup failed: Internal error occurred. Refer to server log for more information.
Will I need to have the dovecot-2 daemon running for this to work ?
My config was quickly converted from v1.2 by "dovecot -n > new.conf" and very little modifications..
################ dovecot -n ############################# # 2.0.9: /usr/local/dovecot-2.0.9/etc/dovecot/dovecot.conf # OS: Linux 2.6.9-89.0.9.ELsmp x86_64 Red Hat Enterprise Linux ES # release 4 (Nahant Update 8) auth_verbose = yes disable_plaintext_auth = no mail_gid = 3000 mail_uid = 3000 mmap_disable = yes namespace { inbox = yes location = prefix = INBOX. type = private } passdb { args = /usr/local/dovecot2/etc/dovecot/dovecot-ldap.conf driver = ldap } plugin { quota = maildir } protocols = imap pop3 service auth { unix_listener /var/run/dovecot/auth-master { group = atmail mode = 0660 user = root } user = dovecot-auth } service imap-login { inet_listener imap { address = * port = 143 } user = dovecot } service imap { executable = /usr/local/dovecot2/sbin/imap-wrapper.sh process_limit = 300 } service pop3-login { inet_listener pop3 { address = * port = 110 } user = dovecot } service pop3 { executable = /usr/local/dovecot2/sbin/pop-wrapper.sh process_limit = 300 } ssl = no userdb { args = /usr/local/dovecot2/etc/dovecot/dovecot-ldap.conf driver = ldap } protocol imap { imap_client_workarounds = delay-newmail mail_plugins = quota imap_quota } protocol pop3 { mail_plugins = quota pop3_client_workarounds = outlook-no-nuls oe-ns-eoh pop3_uidl_format = UID%u-%v } protocol lda { auth_socket_path = /var/run/dovecot/auth-master mail_plugins = quota postmaster_address = MAILER-DAEMON@example.com sendmail_path = /usr/sbin/sendmail } ################ /dovecot -n ############################
$ grep -v ^# /usr/local/dovecot2/etc/dovecot/dovecot-ldap.conf|grep -v ^$ hosts = ldapm1.example.com:389 ldapm2.example.com:389 auth_bind = yes auth_bind_userdn = uid=%n,ou=people,o=%d,o=ISP,o=example,c=com base = ou=people,o=%d,o=ISP,o=example,c=com deref = never scope = onelevel user_filter = (&(objectClass=mailPerson)(uid=%n)) user_attrs = mailMessageStore=mail=maildir:%$:INDEX=/indexes/%1u/%1.1u/%u,mailQuota=quota_rule=*:storage=%$
Also tried a minimal dovecot.conf:
$ ../../sbin/dovecot -n # 2.0.9: /usr/local/dovecot-2.0.9/etc/dovecot/dovecot.conf # OS: Linux 2.6.9-89.0.9.ELsmp x86_64 Red Hat Enterprise Linux ES # release 4 (Nahant Update 8) mail_gid = 3000 mail_uid = 3000 mmap_disable = yes ssl = no userdb { args = /usr/local/dovecot2/etc/dovecot/dovecot-ldap.conf driver = ldap }
But get the exact same errors..
-jf
On 21.1.2011, at 10.47, Jan-Frode Myklebust wrote:
doveadm mailbox status unseen inbox This sounds great, but I'm struggeling to get it working... It complains about:
$ doveadm -v mailbox status -u user@example.com unseen inbox doveadm(user@example.com): Error: userdb lookup: connect(/usr/local/dovecot-2.0.9/var/run/dovecot/auth-userdb) failed: No such file or directory
This needs to be able to connect to v1.2's auth-master socket. So first problem is to make it look in the correct directory:
base_dir = /var/run/dovecot
(or wherever your v1.2's base_dir is)
Then you'll also need to configure v1.2 to add auth-userdb socket on top of auth-master socket (if you didn't already have it). http://wiki.dovecot.org/LDA describes how to add auth-master socket. Just name it auth-userdb instead of auth-master.
On Fri, Jan 21, 2011 at 03:08:26PM +0200, Timo Sirainen wrote:
$ doveadm -v mailbox status -u user@example.com unseen inbox doveadm(user@example.com): Error: userdb lookup: connect(/usr/local/dovecot-2.0.9/var/run/dovecot/auth-userdb) failed: No such file or directory
Then you'll also need to configure v1.2 to add auth-userdb socket on top of auth-master socket (if you didn't already have it). http://wiki.dovecot.org/LDA describes how to add auth-master socket. Just name it auth-userdb instead of auth-master.
I already had a /var/run/dovecot/auth-master, so I just created a symlink to it from from /usr/local/dovecot-2.0.9/var/run/dovecot/auth-userdb and now doveadm works. Thanks again!
-jf
On 2011-01-20 6:08 PM, Timo Sirainen wrote:
On Thu, 2011-01-20 at 23:50 +0100, Jan-Frode Myklebust wrote:
But this woun´t work if the maildir has been modified outside of dovecot (i.e. webmail usage). Are there any simple interface I can use in this short snippet for noticing that the index is out of sync, and update it ?
With v2.0 you could use doveadm easily (you can also just use doveadm binary from v2.0 and keep using v1.2 elsewhere):
doveadm mailbox status unseen inbox
If you're actually running v2.0 you can also ask this information via UNIX/TCP socket.
Easiest would be to just use a webmail app that talks IMAP and let it talk directly to dovecot... ?
--
Best regards,
Charles
On Fri, Jan 21, 2011 at 10:36:11AM -0500, Charles Marcus wrote:
Easiest would be to just use a webmail app that talks IMAP and let it talk directly to dovecot... ?
Yes, we want to implement that as soon as possible. Looking forward to getting everything all maildirs completely managed by dovecot.
-jf
participants (3)
-
Charles Marcus
-
Jan-Frode Myklebust
-
Timo Sirainen