Thursday, 6 March 2008

Installing Dovecot IMAP server

It's time to replace my good old Exchange server with something more open source. Dovecot seemed a pretty stable and secure IMAP server.

Dovecot requires some tweaking. First, the logs are placed into syslog. If you don't like it (like myself) you have to change the location of the logfile. In the configuration file /etc/dovecot/dovecot.conf enter (or change if set):
log_path = /var/log/dovecot.log
This will produce a log file that grows in size without any restriction. I didn't like this so I added a script that rotates the log files on a daily basis:
# dovecot SIGUSR1: Re-opens the log files.
/var/log/dovecot*.log {
/bin/kill -USR1 `cat /var/run/dovecot/
2>/dev/null` 2> /dev/null || true
Name this file /etc/logrotate.d/dovecot and place it into the correct directory.

I also changed the greeting string in /etc/dovecot/dovecot.conf to:
login_greeting = *
as I do not want Dovecot to notify every weired spammer about who it is.

There is a caveat in dovecot. If your server adjusts the system time regularly and your system clock runs slightly faster than the NTP server, dovecot will terminate itself with an error message:
dovecot: 2008-03-06 23:59:54 Fatal: Time just moved backwards by 9 seconds. This might cause a lot of problems, so I'll just kill myself now.

As the wiki states, there is no easy way around this. I created a cron job to restart dovecot each day at 0:02. If the server terminated, the script will start the daemon. If the server is running, restarting it will not harm the system.

This is a dirty workaround. I shall have to get through to installing ntpd later.

No comments: