免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1066 | 回复: 0
打印 上一主题 下一主题

Useful UNIX Commands for Administering Kerio [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-06-16 10:02 |只看该作者 |倒序浏览
Useful UNIX Commands for Administering Kerio MailServer
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
Cygwin
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
for u in `ls`; do if [ -d $u ]; then echo -n `find $u -name __keriomapi__STORE -prune -o -name \#msgs -print | wc -l`;echo "  $u"; fi done | sort -n
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/
mv oldcompany.com newcompany.com
cd newcompany.com
find . -maxdepth 2 -name sub.fld -exec sed -i -n 's/oldcompany\.com/newcompany.com/p' {} \;
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
find . -maxdepth 2 -name sub.fld -exec sed -i -n '/newcompany.com/p' {} \;
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 */*/*.eml
That 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.
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/52953/showart_1002507.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP