Exec'ing a script from Cyrus when imapd has a client

Russell Jackson raj at csub.edu
Thu Nov 12 20:46:20 EST 2009


Xavier Bestel wrote:
> Hi,
> 
> I have a small install with cyrus-imapd 2.3.14, which reads some of its
> mails with fetchmail. To limit the delay in mail delivery, fetchmail
> awakes each minute to get mails.
> What I would like is let fetchmail do that only when there's a client
> actually reading its mails, i.e. an MUA actually connected to imapd.
> 
> So, my question: how to hook a script each time a client
> connects/disconnects from imapd ?
>

Check /var/imap/proc for files. If any are present, then a client is connected. Write a
polling script to run out of cron that checks for this and runs fetchmail if appropriate.
I'll let other's comment on the soundness of this.

Semi-pseudo code.

#/bin/sh
if [ $(find /var/imap/proc -type f | wc -l) -gt 0 ]; then
  fetchmail
fi

For bonus points, you could parse the proc files and only run fetch mail for the users
actually connected.

find /var/imap/proc -type f | \
  xargs awk 'BEGIN{FS="\t"}{if (length($2)) print $2}' | \
  sort -u | \
  xargs <dispatch_command>

-- 
Russell A. Jackson <raj at csub.edu>
Network Analyst
California State University, Bakersfield


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
Url : http://lists.andrew.cmu.edu/pipermail/info-cyrus/attachments/20091112/91eb0b46/attachment.bin 


More information about the Info-cyrus mailing list