On Sun, 11 Nov 2007, Matt wrote:
Is there anyway I can get Dovecot to update mtime on dovecot.index everytime a user successfully checks there email?
Postlogin scripting would work like Benjamin said. Another possibility would be to check atime if you haven't disabled atime updates.
atime is updated everytime I do a backup which is once a week.
protocol imap { # ... mail_executable = /full/path/to/loginscript.sh
I imagine I would need to put this in pop3 section as well?
Yes. I would do it via symlinks, then have loginscript.sh exec the appropriate dovecot process based on how it was called.
e.g.:
protocol imap { mail_executable = /full/path/to/imap ... protocol pop3 { mail_executable = /full/path/to/pop3
with imap and pop3 each a symlink to loginscript.sh. Then, replace the
exec in loginscript.sh with:
exec /usr/libexec/dovecot/basename $0
#!/bin/sh touch $HOME/.dovecot-lastlogin exec /usr/libexec/dovecot/imap
Can I just touch the dovecot.index instead?
Maybe. Not sure what environment variable holds its location, though. And I'm not 100% sure it always exists or whether you'd have to special-case the first-time login. (Will 'touch' creating a zero-length index cause trouble for dovecot? I suspect not.) It might also be nice to just have it as a separate file with an obvious name, rather than relying on nothing else changing dovecot.index. (I think, for example, you can have dovecot's deliver update dovecot.index... or maybe that was just on someone's wishlist.)
Also, I am bit confused. Why must the script exec imap?
mail_executable tells dovecot what to run after a successful login. Usually that's 'imap'. So, when you replace imap with loginscript.sh, you need to be sure that it eventually turns into 'imap', which handles the actual IMAP connection after your script makes its tweaks.
I imagine $HOME will contain the path to the home directory of the pop3/imap user that just successfully logged in?
Yes.
Best, Ben