Courier IMAP and daemontools
The DJB way
We're going to throw out imap.rc and use supervise.
We're going to toss out courierlogger and use multilog.
We're going to kick out couriertcpd and use tcpserver.
We're going to lose the config files and use envdir.
Like so:
authdaemond
/service/authdaemond/run:
#!/bin/bash exec 2>&1 /opt/courier/libexec/courier-authlib/authdaemond
/service/authdaemond/log/run:
#!/bin/bash exec setuidgid daemon multilog t s10458760 n100 /var/log/authdaemond
imapd
With STARTTLS available (but not required).
/service/imap/run:
#!/bin/bash exec 2>&1 tcpserver -R -v 0 143 \ envdir env \ /opt/courier/sbin/imaplogin \ /opt/courier/bin/imapd maildir
/service/imap/env:
COURIERTLS:/opt/courier/bin/couriertls IMAP_ACL:1 IMAP_CAPABILITY:IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE IMAP_CAPABILITY_TLS:IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE LOGIN=PLAIN IMAP_CHECK_ALL_FOLDERS:1 IMAP_EMTPYTRASH:0 IMAP_ENHANCEDIDLE:1 IMAP_KEYWORDS:1 IMAP_MOVE_EXPUNGE_TO_TRASH:1 IMAP_STARTTLS:YES IMAP_TLS:1 IMAP_USELOCKS:1 TLS_CERTFILE:/opt/courier/certs/imap.pem TLS_PROTOCOL:TLS1 TLS_VERIFYPEER:NONE
/service/imap/log/run:
#!/bin/bash exec setuidgid daemon multilog t s10458760 n100 /var/log/imap
imapssl
With SSL only.
/service/imapssl/run:
#!/bin/bash exec 2>&1 tcpserver -R -x /etc/tcp/imapssl.cdb -X -v 0 993 \ envdir /service/imap/env envdir env \ /opt/courier/bin/couriertls -tcpd -server \ /opt/courier/sbin/imaplogin \ /opt/courier/bin/imapd maildir
/service/imap/env:
TLS_PROTOCOL:SSL3
/service/imapssl/log/run:
#!/bin/bash exec setuidgid daemon multilog t s10458760 n100 /var/log/imap
envdir
A quick note on envdir for anyone unfamiliar with it. The idea is that each file in the env directory is read and the contents are stored in the environment variable named after the file. So if you did this:
echo http://iain.cx/ > env/URL
Then envdir env would export URL=http://iain.cx/.
Hence in the settings above, you should set, for example
echo YES > /service/imap/env/IMAP_STARTTLS
But why do we set these environment variables?
Jump to a section
intro | part 1: The courier way | part 2: The DJB way | part 3: Environment