分类: LINUX
2008-06-16 10:02:48
One advantage of using a UNIX-like operating system such as (Linux or Mac OS X) with Kerio MailServer is the multitude of powerful UNIX tools available. This document is really just a place where I dump various scenarios and UNIX commands for dealing with them.
Windows Admins
If you are on Windows, all is not lost. There is a useful "bash prompt" utility available from which provides a lot of the tools used here. Cygwin must be configured during setup to include the "vi" editor and "Perl" to be compatible with the commands in this document. I have not tested the perl commands under cygwin yet.
Message Store
Many of these commands are exectued from the message store. When I refer to "store/mail" or the "message store" or the "mail store" I am referring to the directory that defaults to /opt/kerio/mailserver/store/mail on Linux, /usr/local/kerio/mailserver/store/mail on Mac OS X, and C:\Program Files\Kerio\MailServer\store\mail on Windows.
Re-Index the Entire Message Store
To re-index a folder, find a file called index.fld and rename it to index.bad. KMS will use the information in index.bad to create a new index.fld file that is valid.
Now, suppose you ran a virus scan on the message store, and some emails were deleted. To re-index all of the folders, you need perl. The following command will do it:
find . -name index.fld -exec perl -e '$i="{}"; $new=$i;$new=~s/fld$/bad/;rename $i, $new' \; |
Removing Blank Emails from the Message Store
Here is a command to remove all blank emails in the message store. Of course, you need to not only remove them, but also re-index the folders they are in. It will print the relative paths to the files that were removed.
find . -size 0c -a -name \*.eml -exec perl -e '$i="{}"; $i=~s/\#msgs.*/index.fld/; $i;$new=$i;$new=~s/fld$/bad/;rename $i, $new; print "{}\n"; unlink "{}"' \; |
Another variation of this command would remove all emails smaller than a specified size. The assumption is, any email that is only 55 bytes for example is only large enough for an empty return-path and date header. It would appear as a blank email in any mail client. To remove emails smaller than a specified size, try this command:
find . -size -56c -a -name \*.eml -exec perl -e '$i="{}"; $i=~s/\#msgs.*/index.fld/; $i;$new=$i;$new=~s/fld$/bad/;rename $i, $new; print "{}\n"; unlink "{}"' \; |
Counting the Number of Folders Per User
Sometimes a user might have an extremely high number of folders. Some users, for example, might have 3000 mail folders under there account. Or, perhaps there is some bug that is running away with folder creation. In either case, the following command run from the store/mail directory, will report on the number of folders each user has in their email accounts.
cd store/mail |
Changing domain names leaves wrong domain in your sub.fld files
Some customers attempt to rename a directory, which is not easy to do with the current versions of KMS. In the rather long process, they usually forget about the sub.fld files. This results in some mysterious errors, but no real problems.
If you are renaming a domain now, you can rename the domain names in your sub.fld files with something like the following:
cd store/mail/ |
If you already renamed a domain some time ago, and you are only now noticing strange errors, try removing the lines that are wrong in your sub.fld files as follows:
cd store/mail/newcompany.com |
Directories with .eml File Extentions
This is a problem that is sometimes caused by Entourage users to KMS running on any OS. It can cause blank emails to appear in a user's INBOX. The problem is, Entourage can cause directories with .eml as a filename extention to appear at the root level of a user's mail folder. So, in Webmail you might see INBOX, Calendar, Contacts, Meeting with Bob123487.eml as folder names. To detect this problem, go into the store/mail directory, and enter the following command:
ls -d */*/*.emlThat will check in all domains (first asterisk), all users (second asterisk), for any file or directory that ends with .eml. If it returns anything, that is why this user is receiving blank emails.