Dec
1
好久没有上开源邮件技术论坛 了。今天刚好路过,看到上次回帖说可以提供qmail_2.9.tar.gz包,一直没空。今晚就借这里放上来吧,附带把一个自己写的安装脚本放上来。
1、安装包
和原来的qmail_2.9.tar.gz有点不一样(所以改了名字),这里提供的包括了我下面脚本里面使用到的部分文件。但包里面的其他文件和qmail_2.9.tar.gz是一样的。
点击下载
2、脚本
下面是脚本的代码,由于工作忙,没有进行太多的测试。而且,好像并没有完成Webmail管理部分的编写。
已经测试过在红旗 DC 5.0、AsianUX 2.0、CentOS 4.2系统(x86版)。
由于提示部分我用了中文,建议在XWin下面编译,和使用ssh连接到服务器上进行。若在字符界面上运行,需要加载zhcon。
时间匆忙,若有问题,请到论坛提出,谢谢!
#!/bin/bash
#2005-10-20 第一次编写
#2005-10-26 增加输入域的提示
#2005-10-27 修改提示输入的方式,错误后不退出系统,只是提示重新输入
#2005-10-28 修正Maildrop设置文件的错误,增加日志文件报告
#2005-11-03 增加iGeuis 2.0的安装
#作者:Qkboy
#版本:v1.1
#变量:
#DOMAIN为域名、HOST为主机名、OLDPASSWD为mysql管理员用户root的旧密码、MYSQLPASSWD为mysql管理员用户root的密码
#USER、PASSWORD为用于vpopmail的mysql数据库用户和密码,数据库固定是vpopmail
touch /tmp/install.tmp
##提示输入域名##
DOMAIN=`grep "DOMAIN" /tmp/install.tmp|sed -e "s/^DOMAIN=//"`
if [ "$DOMAIN" == "" ]; then
echo "请输入Domain名称,例如:example.com,此将作为邮件服务的默认域名。"
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
read DOMAIN
echo "您输入的Domain名称是:$DOMAIN,请确认(y|n)?"
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认Domain名称后,重新输入:"
else
echo "DOMAIN=$DOMAIN" >> /tmp/install.tmp
echo "您使用的Domain名称为:$DOMAIN"
fi
done
else
echo "您使用的Domain名称为:$DOMAIN"
fi
##提示输入主机名##
HOST=`grep "HOST" /tmp/install.tmp|sed -e "s/^HOST=//"`
if [ "$HOST" == "" ]; then
echo "请输入邮件主机的名称,例如:mail.example.com"
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
read HOST
echo "您输入的邮件主机名称是:$HOST,请确认(y|n)?"
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认邮件主机名称后,重新输入:"
else
echo "HOST=$HOST" >> /tmp/install.tmp
echo "您使用的邮件主机名称为:$HOST"
fi
done
else
echo "您使用的邮件主机名称为:$HOST"
fi
##提示输入mysql管理员用户root的密码##
RETVAL=`cat /tmp/install.tmp|grep "vpopmail"|grep "igenus"|grep "successfully"`
if [ "$RETVAL" == "" ]; then
echo "你是否已经配置好mysql程序呢?Y/y表示已经完成,N/n表示还没有设置!"
read YN
if [ "$YN" == "Y" ]; then
$YN=y
fi
if [ "$YN" == "N" ]; then
$YN=n
fi
case $YN in
y)
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
echo "请输入mysql管理员用户root的密码"
read MYSQLPASSWD
mysqladmin -uroot -p$MYSQLPASSWD version 1> /dev/null 2>&1
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
INPUT="y"
echo "mysql管理员root密码输入正确!"
else
echo "mysql管理员密码错误,请重新输入!"
INPUT="n"
fi
done
;;
n)
RETVAL=3
until [ "$RETVAL" -eq 0 ]
do
echo "请输入mysql管理员用户root的旧密码,新安装的请直接按回车"
read OLDPASSWD
echo "请输入mysql管理员用户root的新密码"
read MYSQLPASSWD
if [ "$OLDPASSWD" == "" ]; then
mysqladmin -uroot password $MYSQLPASSWD 1> /dev/null 2>&1
service mysqld start
else
mysqladmin -uroot -p$OLDPASSWD password $MYSQLPASSWD 1> /dev/null 2>&1
service mysqld restart
fi
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo "mysql管理员root密码设置成功!"
else
echo "mysql管理员密码设置失败,请重新输入!"
fi
done
;;
*)
echo "输入有误,请重新运行程序!"
exit 1
esac
fi
##提示输入用于vpopmail的mysql数据库用户和密码##
USER=`grep "USER" /tmp/install.tmp|sed -e "s/^USER=//"`
if [ "$USER" == "" ]; then
echo "请输入用于vpopmail的mysql数据库用户,例如:vpopmail"
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
read USER
echo "请输入$USER用户的密码"
read PASSWORD
echo "您输入的用于vpopmail的mysql数据库用户是:$USER,密码:$PASSWORD,请确认(y|n)?"
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认用于vpopmail的mysql数据库用户后,重新输入:"
else
echo "USER=$USER" >> /tmp/install.tmp
echo "PASSWORD=$PASSWORD" >> /tmp/install.tmp
echo "您用于vpopmail的mysql数据库用户为:$USER,密码:$PASSWORD"
fi
done
else
PASSWORD=`grep "PASSWORD" /tmp/install.tmp|sed -e "s/^PASSWORD=//"`
echo "您用于vpopmail的mysql数据库用户为:$USER,密码:$PASSWORD"
fi
##判断sendmail是否已经启动##
echo "##判断sendmail是否在启动?##"
STRING=`rpm -q sendmail`
if [ "$STRING" != "package sendmail is not installed" ] ; then #判断系统是否安装有sendmail
/etc/rc.d/init.d/sendmail status
RETVAL=$?
if [ $RETVAL -eq 3 ]; then
echo "sendmail已经停止!!"
rpm -e --nodeps sendmail
rpm -e --nodeps sendmail-cf-8.13.1-2
rpm -e --nodeps sendmail-doc-8.13.1-2
rpm -e --nodeps sendmail-devel-8.13.1-2
else
echo "sendmail已经启动了,下面将其停止!"
/etc/rc.d/init.d/sendmail stop
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo "sendmail 停止成功。"
rpm -e --nodeps sendmail
rpm -e --nodeps sendmail-cf-8.13.1-2
rpm -e --nodeps sendmail-doc-8.13.1-2
rpm -e --nodeps sendmail-devel-8.13.1-2
else
echo "sendmail 停止有问题。请删除/var/lock/subsys/sendmail文件,再试试!"
fi
fi
else
echo "sendmail 已经卸载!"
fi
##开始准备工作##
echo "##开始准备工作!##"
if [ -f /tmp/install.tmp ]; then
RETVAL=`grep "standby" /tmp/install.tmp`
if [ "$RETVAL" == "" ]; then
cd /home
cp /root/pkg_2.9.tar.gz /home/
tar xzf pkg_2.9.tar.gz
chmod 755 -R pkg
cd pkg
tar xzf netqmail-1.05.tar.gz
cd netqmail-1.05
./collate.sh
echo "standby ready!" >> /tmp/install.tmp
echo "准备工作已经完成!"
else
echo "准备工作已经做过!"
fi
fi
##开始安装daemontools##
echo "##开始安装daemontools!##"
if [ -f /tmp/install.tmp ]; then
RETVAL=`cat /tmp/install.tmp|grep "daemontools"|grep "successfully"`
if [ "$RETVAL" == "" ]; then
cd /home/pkg
tar -zxf daemontools-0.76.tar.gz
cd admin/daemontools-0.76
patch -p1 < /home/pkg/netqmail-1.05/other-patches/daemontools-0.76.errno.patch
package/install
sleep 5
STATE=`ps ax|grep svscan|grep -v "grep svscan"`
if [ "$STATE" != "" ]; then
echo "daemontools运行正常!"
echo "daemontools has installed successfully!" >> /tmp/install.tmp
echo "daemontools已经安装完成!"
else
echo "daemontools安装完毕,但运行似乎有问题,请重新检查svscan进程!"
fi
else
echo "daemontools已经安装过了!"
fi
fi
##开始安装ucspi-tcp##
echo "##开始安装ucspi-tcp!##"
if [ -f /tmp/install.tmp ]; then
RETVAL=`cat /tmp/install.tmp|grep "ucspi-tcp"|grep "successfully"`
if [ "$RETVAL" == "" ]; then
cd /home/pkg
tar zxf ucspi-tcp-0.88.tar.gz
cd ucspi-tcp-0.88
patch -p1 < ../ucspi-tcp-0.88.errno.patch
make
make setup check
echo "ucspi-tcp has installed successfully!" >> /tmp/install.tmp
echo "ucspi-tcp已经安装完成!"
else
echo "ucspi-tcp已经安装过了!"
fi
fi
##开始创建原始qmail环境##
echo "##开始创建原始qmail环境!##"
if [ -f /tmp/install.tmp ]; then
RETVAL=`cat /tmp/install.tmp|grep "qmail"|grep "successfully"`
if [ "$RETVAL" == "" ]; then
mkdir /var/qmail
groupadd nofiles
useradd alias -g nofiles -d /var/qmail/alias -s /sbin/nologin
useradd qmaild -g nofiles -d /var/qmail -s /sbin/nologin
useradd qmaill -g nofiles -d /var/qmail -s /sbin/nologin
useradd qmailp -g nofiles -d /var/qmail -s /sbin/nologin
groupadd qmail
useradd qmailq -g qmail -d /var/qmail -s /sbin/nologin
useradd qmailr -g qmail -d /var/qmail -s /sbin/nologin
useradd qmails -g qmail -d /var/qmail -s /sbin/nologin
NUM=`grep "89" /etc/passwd` #如果系统原来存在uid为89的帐号,将其屏蔽
if [ $NUM != "" ]; then
sed -i "s/postfix/#&/" /etc/passwd /etc/group
fi
groupadd vchkpw -g 89
useradd vpopmail -u 89 -g vchkpw
echo "用户创建完毕!,下面进行Qmail的安装!"
cd /home/pkg
tar -xzf toaster-scripts-0.7.tar.gz
cd netqmail-1.05/netqmail-1.05/
#下面的sed是修正了一个无效提示的错误
sed -i "/straynewline/{ s/451/533/; }" qmail-smtpd.c
#部分版本需要添加include的链接
ln -s /usr/kerberos/include/com_err.h /usr/include/
rm -rf /usr/sbin/sendmail
make
make setup check
./config-fast $HOST
echo "设置管理员信箱!"
cd /var/qmail/alias
echo "admin@$DOMAIN" > .qmail-postmaster
echo "admin@$DOMAIN" > .qmail-mailer-daemon
echo "admin@$DOMAIN" > .qmail-root
chmod 644 /var/qmail/alias/.qmail*
echo "开启SPF设置!"
echo ./Maildir/ >/var/qmail/control/defaultdelivery
echo 3 > /var/qmail/control/spfbehavior
echo "添加qmail的帮助手册!"
echo MANPATH /var/qmail/man >> /etc/man.config
echo "为qmail服务建立监控目录和日志文件!"
mkdir -p /var/qmail/supervise/qmail-send/log
mkdir -p /var/qmail/supervise/qmail-smtpd/log
mkdir -p /var/qmail/supervise/qmail-pop3d/log
mkdir -p /var/qmail/supervise/qmail-pop3ds/log
cp /home/pkg/toaster-scripts-0.7/send.run /var/qmail/supervise/qmail-send/run
cp /home/pkg/toaster-scripts-0.7/send.log.run /var/qmail/supervise/qmail-send/log/run
cp /home/pkg/toaster-scripts-0.7/smtpd.run /var/qmail/supervise/qmail-smtpd/run
cp /home/pkg/toaster-scripts-0.7/smtpd.log.run /var/qmail/supervise/qmail-smtpd/log/run
cp /home/pkg/toaster-scripts-0.7/pop3d.run /var/qmail/supervise/qmail-pop3d/run
cp /home/pkg/toaster-scripts-0.7/pop3d.log.run /var/qmail/supervise/qmail-pop3d/log/run
cp /home/pkg/toaster-scripts-0.7/pop3ds.run /var/qmail/supervise/qmail-pop3ds/run
cp /home/pkg/toaster-scripts-0.7/pop3ds.log.run /var/qmail/supervise/qmail-pop3ds/log/run
echo 20 > /var/qmail/control/concurrencyincoming
chmod 644 /var/qmail/control/concurrencyincoming
chmod 755 /var/qmail/supervise/qmail-send/run
chmod 755 /var/qmail/supervise/qmail-send/log/run
chmod 755 /var/qmail/supervise/qmail-smtpd/run
chmod 755 /var/qmail/supervise/qmail-smtpd/log/run
chmod 755 /var/qmail/supervise/qmail-pop3d/run
chmod 755 /var/qmail/supervise/qmail-pop3d/log/run
chmod 755 /var/qmail/supervise/qmail-pop3ds/run
chmod 755 /var/qmail/supervise/qmail-pop3ds/log/run
mkdir -p /var/log/qmail/smtpd
mkdir -p /var/log/qmail/pop3d
mkdir -p /var/log/qmail/pop3ds
chown -R qmaill /var/log/qmail
echo "生成启动脚本!"
cd /home/pkg
cp toaster-scripts-0.7/rc /var/qmail/rc
chmod 755 /var/qmail/rc
cp toaster-scripts-0.7/qmailctl /var/qmail/bin/
chmod 755 /var/qmail/bin/qmailctl
ln -s /var/qmail/bin/qmailctl /usr/bin
ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail
rm -rf /usr/lib/sendmail
ln -s /var/qmail/bin/sendmail /usr/lib/sendmail
echo "设置用daemontools来启动qmail-send和qmail-smtpd!"
ln -s /var/qmail/supervise/qmail-send /var/qmail/supervise/qmail-smtpd /service
echo "启动qmail服务!"
echo "qmailctl start|stop|restart|doqueue|flush|reload|stat|pause|cont|cdb|queue|help"
echo "qmail has installed successfully!" >> /tmp/install.tmp
echo "原始的qmail程序已经安装完成!"
else
echo "qmail已经安装过了!"
fi
fi
##开始安装vpopmail##
echo "##开始安装vpopmail!##"
if [ -f /tmp/install.tmp ]; then
RETVAL=`cat /tmp/install.tmp|grep "vpopmail"|grep "successfully"`
if [ "$RETVAL" == "" ]; then
mkdir -p /home/vpopmail/etc
echo "$DOMAIN" > /home/vpopmail/etc/defaultdomain
echo "127.0.0.1:allow,RELAYCLIENT=""" > /home/vpopmail/etc/tcp.smtp
cd /home/vpopmail/etc ; tcprules tcp.smtp.cdb tcp.smtp.tmp < tcp.smtp
#设置MySQL信息,其中vpopmail是数据库名称
echo "localhost|0|$USER|$PASSWORD|vpopmail" > /home/vpopmail/etc/vpopmail.mysql
chmod 640 /home/vpopmail/etc/vpopmail.mysql
chown -R vpopmail.vchkpw /home/vpopmail/etc
cd /home/pkg/
#建立用于vpopmail的mysql数据库的脚本
echo "CREATE DATABASE vpopmail;" > vpopmail.sql
echo "GRANT select,insert,update,delete,create,drop ON vpopmail.*" >> vpopmail.sql
echo "TO $USER@localhost IDENTIFIED BY "$PASSWORD";" >> vpopmail.sql
echo "FLUSH PRIVILEGES;" >> vpopmail.sql
echo "QUIT" >> vpopmail.sql
#建立vpopmail数据库
mysql -uroot -p$MYSQLPASSWD < vpopmail.sql
tar xzf vpopmail-5.4.10.tar.gz
cd vpopmail-5.4.10
#编译并安装
./configure --enable-incdir=/usr/include/mysql --enable-libdir=/usr/lib/mysql --disable-roaming-users --enable-logging=p --disable-passwd --enable-clear-passwd --disable-domain-quotas --enable-auth-module=mysql --enable-auth-logging --enable-sql-logging --disable-valias --disable-mysql-limits --enable-learn-passwords
make
make install-strip
echo "export PATH=$PATH:/home/vpopmail/bin" >> /etc/profile
source /etc/profile
#建立初始域,admin是默认的域管理密码
#然后建立一个default用户做测试,后面的default是密码
vadddomain $DOMAIN admin
vadduser -q 10485760S default@$DOMAIN default
vmoduser -c 默认用户 default@$DOMAIN
#设置警告信息
cat /home/pkg/.quotawarn.msg > /home/vpopmail/domains/.quotawarn.msg
sed -i "s/domain.com/rfgz.com/g" /home/vpopmail/domains/.quotawarn.msg
echo "邮件被拒绝,用户的邮箱空间已满." > /home/vpopmail/domains/.over-quota.msg
#设置启动脚本
cp /home/pkg/toaster-scripts-0.7/vpopmailctl /var/qmail/bin
ln -s /var/qmail/bin/vpopmailctl /usr/bin
chmod 755 /var/qmail/bin/vpopmailctl
#打上qmail的补丁
cd /home/pkg/netqmail-1.05/netqmail-1.05
bunzip2 -c /home/pkg/qmail-toaster-0.7.2.patch.bz2 | patch -p0 -t
make clean
make
qmailctl stop
make setup check
chown -R vpopmail:vchkpw /var/qmail/spam
#生成SSL信息
echo "请根据提示,输入生成SSL需要的信息"
make cert
make tmprsadh
chown -R vpopmail:qmail /var/qmail/control/clientcert.pem /var/qmail/control/servercert.pem
#重启启动qmail服务
qmailctl start
ln -s /var/qmail/supervise/qmail-pop3d /service
ln -s /var/qmail/supervise/qmail-pop3ds /service
echo "vpopmailctl start|stop|restart|stat|pause|cont|help"
echo "vpopmail has installed successfully!" >> /tmp/install.tmp
echo "vpopmail程序已经安装完成!"
else
echo "vpopmail已经安装过了!"
fi
fi
##开始安装igenus##
echo "##开始安装igenus!##"
if [ -f /tmp/install.tmp ]; then
RETVAL=`cat /tmp/install.tmp|grep "igenus"|grep "successfully"`
if [ "$RETVAL" == "" ]; then
cd /home/pkg
tar zxf igenus_2.0.2_20040901_release.tgz -C /var/www/
cd /var/www/
rm -rf html/
mv igenus html
#准备一些必要的文件夹
mkdir /tmp/temp
chmod -R 0755 /tmp/temp
chown -R vpopmail:vchkpw /tmp/temp
mkdir /home/netdisk
chmod -R 0755 /home/netdisk
chown -R vpopmail:vchkpw /home/netdisk
chmod -R 0755 /var/www/html/
chown -R vpopmail:vchkpw /var/www/html/
#修改配置文件
cd /var/www/html/config
sed -i -e "/^$CFG_BASEPATH/{ s@/home/www/igenus@/var/www/html/@; }" config_inc.php
sed -i -e "/^$CFG_MYSQL_USER/{ s@vpopmail@$USER@; }" config_inc.php
sed -i -e "/^$CFG_MYSQL_PASS/{ s@vpopmail@$PASSWORD@; }" config_inc.php
sed -i -e "/^$CFG_TEMP =/d" -e "/^$CFG_TEMP_MOD/i $CFG_TEMP ="/tmp/temp/";" config_inc.php
#删除原来的数据库,新建一个
vdeldomain $DOMAIN
echo "use vpopmail;" > /home/pkg/drop_vpopmail.sql
echo "drop table lastauth;" >> /home/pkg/drop_vpopmail.sql
echo "drop table vpopmail;" >> /home/pkg/drop_vpopmail.sql
echo "quit" >> /home/pkg/drop_vpopmail.sql
mysql -uroot -p$MYSQLPASSWD < /home/pkg/drop_vpopmail.sql
sed -i -e "/^CREATE TABLE `address`/i use vpopmail;" /var/www/html/docs/iGENUS.sql
sed -i -e "/`pw_shell` varchar(20) default NULL,/a `pw_clear_passwd` varchar(16) default NULL," /var/www/html/docs/iGENUS.sql
mysql -uroot -p$MYSQLPASSWD </var/www/html/docs/iGENUS.sql
#建立虚拟主机
sed -i -e "/^register_globals/{ s/Off/On/; }" /etc/php.ini
sed -i -e "/^session.bug_compat_warn/{ s/1/0/; }" /etc/php.ini
sed -i -e "/^sendmail_path/{ s@/usr/sbin/sendmail -t -i@/var/qmail/bin/qmail-inject@ }" /etc/php.ini
echo "AddType application/x-httpd-php .php" >> /etc/httpd/conf/httpd.conf
echo "AddType application/x-httpd-php-source .phps" >> /etc/httpd/conf/httpd.conf
echo "DirectoryIndex index.php index.html" >> /etc/httpd/conf/httpd.conf
echo "NameVirtualHost *:80" >> /etc/httpd/conf/httpd.conf
echo "<VirtualHost *:80>" >> /etc/httpd/conf/httpd.conf
echo "ServerName $DOMAIN" >> /etc/httpd/conf/httpd.conf
echo "DocumentRoot /var/www/html" >> /etc/httpd/conf/httpd.conf
echo "</VirtualHost>" >> /etc/httpd/conf/httpd.conf
chmod 777 /var/lib/php/session/ -R
service httpd restart
#重新增加域
vadddomain $DOMAIN admin
vadduser -q 10485760S default@$DOMAIN default
vmoduser -c 默认用户 default@$DOMAIN
echo "igenus has installed successfully!" >> /tmp/install.tmp
echo "igenus程序已经安装完成!"
else
echo "igenus已经安装过了!"
fi
fi
##开始安装courier-imap##
echo "##开始安装courier-imap!##"
if [ -f /tmp/install.tmp ]; then
RETVAL=`cat /tmp/install.tmp|grep "courier-imap"|grep "successfully"`
if [ "$RETVAL" == "" ]; then
cd /home/pkg
tar -xjf courier-authlib-0.55.tar.bz2
cd courier-authlib-0.55
./configure --prefix=/usr/local --exec-prefix=/usr/local --with-authvchkpw --without-authldap --without-authmysql --disable-root-check --with-ssl --with-authchange pwdir=/usr/local/libexec/authlib --with-redhat
make
make install
make install-configure
sed -i "/^authmodulelist/{ s/authuserdb authpam authpgsql authcustom //; }" /usr/local/etc/authlib/authdaemonrc
sed -i "/^daemons=/{ s/5/2/; }" /usr/local/etc/authlib/authdaemonrc
#启动courier-authdaemond进程
/usr/local/sbin/authdaemond start
#判断服务是否运行正常
/usr/local/sbin/authtest default@$DOMAIN default
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
#设置开机自动启动
cp /usr/local/sbin/authdaemond /etc/init.d/
ln -s /etc/init.d/authdaemond /etc/rc.d/rc3.d/S80authdaemond
ln -s /etc/init.d/authdaemond /etc/rc.d/rc5.d/S80authdaemond
echo "courier-authlib安装成功!"
fi
#开始安装courier-imap
cd /home/pkg
tar -xjf courier-imap-4.0.2.tar.bz2
cd courier-imap-4.0.2
chown -R vpopmail:vchkpw ../courier-imap-4.0.2
su vpopmail -c "./configure --with-redhat;make" #使用vpopmail用户进行编译
make install-strip
make install-configure
cp courier-imap.sysvinit /etc/rc.d/init.d/courier-imap
#设置开机自动启动
chmod 755 /etc/rc.d/init.d/courier-imap
chkconfig --add courier-imap
chkconfig --level 35 courier-imap on
if ! [ -f /usr/lib/courier-imap/etc/authdaemonrc ]; then
ln -s /usr/local/etc/authlib/authdaemonrc /usr/lib/courier-imap/etc/authdaemonrc
fi
#根据实际情况,修改配置文件
sed -i -e "s/^IMAPDSTART=/#&/" -e "/^#IMAPDSTART=/a IMAPDSTART=YES" /usr/lib/courier-imap/etc/imapd
sed -i -e "s/^IMAPDSSLSTART=/#&/" -e "/^#IMAPDSSLSTART=/a IMAPDSSLSTART=YES" /usr/lib/courier-imap/etc/imapd-ssl
sed -i "/^CN/{ s/localhost/$DOMAIN/; }" /usr/lib/courier-imap/etc/imapd.cnf
sed -i "/^emailAddress/{ s/(postmaster@)example.com/1$DOMAIN/; }" /usr/lib/courier-imap/etc/imapd.cnf
sed -i "/^CN/{ s/localhost/$DOMAIN/; }" /usr/lib/courier-imap/etc/pop3d.cnf
sed -i "/^emailAddress/{ s/(postmaster@)example.com/1$DOMAIN/; }" /usr/lib/courier-imap/etc/pop3d.cnf
#启动courier-imap进程
/etc/rc.d/init.d/courier-imap start
echo "courier-imap has installed successfully!" >> /tmp/install.tmp
echo "courier-imap已经安装完成!"
else
echo "courier-imap已经安装过了!"
fi
fi
##开始安装autorespond##
echo "##开始安装autorespond!##"
if [ -f /tmp/install.tmp ]; then
RETVAL=`cat /tmp/install.tmp|grep "autorespond"|grep "successfully"`
if [ "$RETVAL" == "" ]; then
cd /home/pkg
tar -xzf autorespond-2.0.5.tar.gz
cd autorespond-2.0.5
make
make install
echo "autorespond has installed successfully!" >> /tmp/install.tmp
echo "autorespond已经安装完成!"
else
echo "autorespond已经安装过了!"
fi
fi
##开始安装ezmlm##
echo "##开始安装ezmlm!##"
if [ -f /tmp/install.tmp ]; then
RETVAL=`cat /tmp/install.tmp|grep "ezmlm"|grep "successfully"`
if [ "$RETVAL" == "" ]; then
cd /home/pkg
tar -xzf ezmlm-0.53.tar.gz
tar -xzf ezmlm-idx-0.42.tar.gz
cp -rf ezmlm-idx-0.42/* ezmlm-0.53/
cd ezmlm-0.53
patch < idx.patch
chmod u+x makelang
make
make man
make ch_GB
make setup
echo "ezmlm has installed successfully!" >> /tmp/install.tmp
echo "ezmlm已经安装完成!"
else
echo "ezmlm已经安装过了!"
fi
fi
##开始安装qmailadmin##
echo "##开始安装qmailadmin!##"
if [ -f /tmp/install.tmp ]; then
RETVAL=`cat /tmp/install.tmp|grep "qmailadmin"|grep "successfully"`
if [ "$RETVAL" == "" ]; then
cd /home/pkg
tar -xzf qmailadmin-1.2.3.tar.gz
cd qmailadmin-1.2.3
./configure --enable-htmldir=/var/www/html --enable-cgibindir=/var/www/cgi-bin --enable-vpopuser=vpopmail --enable-autoresponder-bin=/usr/bin --disable-ezmlm-mysql --enable-maxusersperpage=20 --enable-maxaliasesperpage=20 --enable-modify-quota --enable-domain-autofill
make
make install-strip
cd /usr/local/share/qmailadmin/lang
mv en en.bak
cp zh-cn en
echo "qmailadmin has installed successfully!" >> /tmp/install.tmp
echo "qmailadmin已经安装完成!"
else
echo "qmailadmin已经安装过了!"
fi
fi
##开始安装vqadmin##
echo "##开始安装vqadmin!##"
if [ -f /tmp/install.tmp ]; then
RETVAL=`cat /tmp/install.tmp|grep "vqadmin"|grep "successfully"`
if [ "$RETVAL" == "" ]; then
cd /home/pkg
tar -zxf vqadmin-2.3.6.tar.gz
cd vqadmin-2.3.6
sed -i "/*user/{ s/my_user/$USER/ }" db_owner.c
sed -i "/*passwd/{ s/my_password/$PASSWORD/ }" db_owner.c
sed -i "/*db/{ s/my_database/vpopmail/ }" db_owner.c
./configure
make
make install
#添加apache中vqadmin的域
echo "<Directory "/var/www/cgi-bin/vqadmin">" >> /etc/httpd/conf/httpd.conf
echo "deny from all" >> /etc/httpd/conf/httpd.conf
echo "Options ExecCGI" >> /etc/httpd/conf/httpd.conf
echo "AllowOverride AuthConfig" >> /etc/httpd/conf/httpd.conf
echo "Order deny,allow" >> /etc/httpd/conf/httpd.conf
echo "</Directory> " >> /etc/httpd/conf/httpd.conf
cd /var/www/cgi-bin/vqadmin
chown nobody .htaccess
chmod 600 .htaccess
#创建默认的管理帐号
htpasswd -bc /etc/httpd/conf/vqadmin.passwd admin admin
echo "请留意,vqadmin默认管理帐号:admin,密码:admin!"
chown vpopmail.vchkpw /etc/httpd/conf/vqadmin.passwd
chmod 644 /etc/httpd/conf/vqadmin.passwd
#配置apache环境
sed -i -e "s/^User apache/#&/" -e "s/^Group apache/#&/" -e "/^#Group apache/a User vpopmail
Group vchkpw" /etc/httpd/conf/httpd.conf
sed -i -e "s/^AddDefaultCharset/#&/" -e "/^#AddDefaultCharset/a AddDefaultCharset GB2312" /etc/httpd/conf/httpd.conf
chown -R vpopmail.vchkpw /var/www/cgi-bin
sed -i -e "/^AuthUserFile/d" -e "/^AuthType Basic/a AuthUserFile /etc/httpd/conf/vqadmin.passwd" .htaccess
service httpd status 1>/dev/null 2>&1
HTTPSTAT=$?
if [ $HTTPSTAT -eq 3 ]; then
service httpd start
else
service httpd restart
fi
echo "vqadmin has installed successfully!" >> /tmp/install.tmp
echo "vqadmin已经安装完成!"
else
echo "vqadmin已经安装过了!"
fi
fi
##开始安装spamassassin##
echo "##开始安装spamassassin!##"
if [ -f /tmp/install.tmp ]; then
RETVAL=`cat /tmp/install.tmp|grep "spamassassin"|grep "successfully"`
if [ "$RETVAL" == "" ]; then
cd /home/pkg
rpm -Uvh spamassassin-3.0.2-2.1.el3.rf.i386.rpm
rpm -Uvh perl-Razor-Agent-2.40-2.i386.rpm
#修改配置文件
sed -i -e "s/^SPAMDOPTIONS=/#&/" -e "/^#SPAMDOPTIONS=/a SPAMDOPTIONS="-d -c -m5 -H -x spamd -v"" /etc/init.d/spamassassin
sed -i -e "s/^SPAMDOPTIONS=/#&/" -e "/^#SPAMDOPTIONS=/a SPAMDOPTIONS="-d -c -m5 -H -x spamd -v"" /etc/sysconfig/spamassassin
rm -rf /etc/mail/spamassassin/local.cf
tar xzf /home/pkg/spamassassin.local.cf.tar.gz -C /etc/mail/spamassassin/
chkconfig --level 35 spamassassin on
#启动spamassain
tar xzf /home/pkg/spamassassin.Chinese_rules.tar.gz /usr/share/spamassassin/
service spamassassin start
sa-learn --sync -D -p user_prefs
echo "spamassassin has installed successfully!" >> /tmp/install.tmp
echo "spamassassin已经安装完成!"
else
echo "spamassassin已经安装过了!"
fi
fi
##开始安装clamav##
echo "##开始安装clamav!##"
if [ -f /tmp/install.tmp ]; then
RETVAL=`cat /tmp/install.tmp|grep "clamav"|grep "successfully"`
if [ "$RETVAL" == "" ]; then
groupadd clamav
useradd -g clamav -s /bin/false clamav
cd /home/pkg
tar -xzf clamav-0.83.tar.gz
cd clamav-0.83
./configure --disable-zlib-vcheck
make check
make install
#修改配置文件
sed -i -e "s/^Example/#&/" -e "s@^#(UpdateLogFile /var/log/freshclam.log)@1@" -e "s/^#(LogSyslog)/1/" -e "s@^#(PidFile /var/run/freshclam.pid)@1@" /usr/local/etc/freshclam.conf
sed -i -e "s/^Example/#&/" -e "s@^#LogFile /tmp/clamd.log@LogFile /var/log/clamav/clamd.log@" -e "s@^#(LogFileMaxSize 2M)@1@" -e "s@^#(LogTime)@1@" /usr/local/etc/clamd.conf
sed -i -e "s@^#(PidFile /var/run/clamd.pid)@1@" -e "s@^#(LogSyslog)@1@" -e "s@^#(ScanMail)@1@" /usr/local/etc/clamd.conf
#创建freshclam日志记录文件
touch /var/log/freshclam.log
chmod 644 /var/log/freshclam.log
chown clamav:clamav /var/log/freshclam.log
mkdir /var/lib/clamav
chown clamav:clamav /var/lib/clamav
#创建clamv日志记录文件
mkdir -p /var/log/clamav
touch /var/log/clamav/clamd.log
chown clamav.clamav -R /var/log/clamav/
chmod 644 -R /var/log/clamav/
tar xzf /home/pkg/clamav.sh.tar.gz -C /etc/init.d/
chmod 755 /etc/init.d/clamav
ln -s /etc/init.d/clamav /etc/rc.d/rc3.d/S88clamav
ln -s /etc/init.d/clamav /etc/rc.d/rc5.d/S88clamav
echo "clamav has installed successfully!" >> /tmp/install.tmp
echo "clamav已经安装完成!"
else
echo "clamav已经安装过了!"
fi
fi
##开始安装maildrop和TNEF reader##
echo "##开始安装maildrop和TNEF reader!##"
if [ -f /tmp/install.tmp ]; then
RETVAL=`cat /tmp/install.tmp|grep "maildrop"|grep "TNEF reader"|grep "successfully"`
if [ "$RETVAL" == "" ]; then
#安装maildrop
cd /home/pkg
tar -xjf maildrop-1.8.0.tar.bz2
cd maildrop-1.8.0
./configure
make
make install-strip
make install-man
#安装TNEF reader
cd /home/pkg
tar -xzf tnef-1.2.3.1.tar.gz
cd tnef-1.2.3.1
./configure
make
make install
#使用Maildrop调用SpamAssassin
tar xzf /home/pkg/mailfilter.tar.gz -C /home/vpopmail/domains/$DOMAIN
cd /home/vpopmail/domains/$DOMAIN
chown vpopmail:vchkpw mailfilter
chmod 700 mailfilter
echo "| preline /usr/local/bin/maildrop mailfilter" >> .qmail-default
echo "maildrop & TNEF reader has installed successfully!" >> /tmp/install.tmp
echo "maildrop和TNEF reader已经安装完成!"
else
echo "maildrop和TNEF reader已经安装过了!"
fi
fi
##开始安装qmail-scanner和qms-analog##
echo "##qmail-scanner和qms-analog!##"
if [ -f /tmp/install.tmp ]; then
RETVAL=`cat /tmp/install.tmp|grep "qmail-scanner"|grep "qms-analog"|grep "successfully"`
if [ "$RETVAL" == "" ]; then
cd /home/pkg
rpm -Uvh perl-suidperl-5.8.5-12.1.1.i386.rpm
tar zxf qmail-scanner-1.25.tgz
tar zxf qms-analog-0.4.2.tar.gz
cd qms-analog-0.4.2
make all
cp qmail-scanner-1.25-st-qms-20050219.patch /home/pkg/qmail-scanner-1.25
cd /home/pkg/qmail-scanner-1.25
patch -p1 < qmail-scanner-1.25-st-qms-20050219.patch
groupadd qscand
useradd -g qscand -s /bin/false qscand
sed -i -e "s/yourdomain.com/$DOMAIN/" -e "s/,yourotherdomain.com//" qms-config
sed -i -e "/--qms-monitor no/a --lang en_GB
--debug no
--unzip yes
--scanners clamscan,verbose_spamassassin " qms-config
chmod 755 qms-config
echo "请留意屏幕提示,都按y确认即可!"
./qms-config install
setuidgid qscand /var/qmail/bin/qmail-scanner-queue.pl -z
setuidgid qscand /var/qmail/bin/qmail-scanner-queue.pl -r
setuidgid qscand /var/qmail/bin/qmail-scanner-queue.pl -g
chown qscand:qscand /var/qmail/bin/qmail-scanner-queue.pl
chmod 4755 /var/qmail/bin/qmail-scanner-queue.pl
chown -R qscand:qscand /var/spool/qmailscan
sed -i -e "/softlimit/{ s/8000000/40000000/ }" /var/qmail/supervise/qmail-smtpd/run
qmailctl stop
qmailctl start
echo "qmail-scanner & qms-analog has installed successfully!" >> /tmp/install.tmp
echo "qmail-scanner和qms-analog已经安装完成!"
else
echo "qmail-scanner和qms-analog已经安装过了!"
fi
fi
##开始安装qmailanalog和qlogtools##
echo "##qmailanalog和qlogtools!##"
if [ -f /tmp/install.tmp ]; then
RETVAL=`cat /tmp/install.tmp|grep "qmailanalog"|grep "qlogtools"|grep "successfully"`
if [ "$RETVAL" == "" ]; then
#安装qmailanalog
cd /home/pkg/
tar zxf qmailanalog-0.70.tar.gz
cd qmailanalog-0.70
patch < /home/pkg/qmailanalog-0.70.errno.patch
make && make setup check
#安装qlogtools
cd /home/pkg/
tar zxf qlogtools-3.1.tar.gz
cd qlogtools-3.1
patch < /home/pkg/qlogtools_errno.patch
make
./installer
#设置配置文件
tar xzf /home/pkg/qmailstats.tar.gz -C /var/qmail/bin/
sed -i -e "s/<your_postmaster>@yourdomain.com/postmaster@$DOMAIN/" /var/qmail/bin/qmailstats
chmod 750 /var/qmail/bin/qmailstats
/var/qmail/bin/qmailstats
echo "qmailanalog & qlogtools has installed successfully!" >> /tmp/install.tmp
echo "qmailanalog和qlogtools已经安装完成!"
echo "所有程序已经安装完成!请保留/home/pkg/admin目录,其他的可以删除!"
else
echo "qmailanalog和qlogtools已经安装过了!"
fi
fi
下载点击
1、安装包
和原来的qmail_2.9.tar.gz有点不一样(所以改了名字),这里提供的包括了我下面脚本里面使用到的部分文件。但包里面的其他文件和qmail_2.9.tar.gz是一样的。
点击下载
2、脚本
下面是脚本的代码,由于工作忙,没有进行太多的测试。而且,好像并没有完成Webmail管理部分的编写。
已经测试过在红旗 DC 5.0、AsianUX 2.0、CentOS 4.2系统(x86版)。
由于提示部分我用了中文,建议在XWin下面编译,和使用ssh连接到服务器上进行。若在字符界面上运行,需要加载zhcon。
时间匆忙,若有问题,请到论坛提出,谢谢!
#!/bin/bash
#2005-10-20 第一次编写
#2005-10-26 增加输入域的提示
#2005-10-27 修改提示输入的方式,错误后不退出系统,只是提示重新输入
#2005-10-28 修正Maildrop设置文件的错误,增加日志文件报告
#2005-11-03 增加iGeuis 2.0的安装
#作者:Qkboy
#版本:v1.1
#变量:
#DOMAIN为域名、HOST为主机名、OLDPASSWD为mysql管理员用户root的旧密码、MYSQLPASSWD为mysql管理员用户root的密码
#USER、PASSWORD为用于vpopmail的mysql数据库用户和密码,数据库固定是vpopmail
touch /tmp/install.tmp
##提示输入域名##
DOMAIN=`grep "DOMAIN" /tmp/install.tmp|sed -e "s/^DOMAIN=//"`
if [ "$DOMAIN" == "" ]; then
echo "请输入Domain名称,例如:example.com,此将作为邮件服务的默认域名。"
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
read DOMAIN
echo "您输入的Domain名称是:$DOMAIN,请确认(y|n)?"
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认Domain名称后,重新输入:"
else
echo "DOMAIN=$DOMAIN" >> /tmp/install.tmp
echo "您使用的Domain名称为:$DOMAIN"
fi
done
else
echo "您使用的Domain名称为:$DOMAIN"
fi
##提示输入主机名##
HOST=`grep "HOST" /tmp/install.tmp|sed -e "s/^HOST=//"`
if [ "$HOST" == "" ]; then
echo "请输入邮件主机的名称,例如:mail.example.com"
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
read HOST
echo "您输入的邮件主机名称是:$HOST,请确认(y|n)?"
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认邮件主机名称后,重新输入:"
else
echo "HOST=$HOST" >> /tmp/install.tmp
echo "您使用的邮件主机名称为:$HOST"
fi
done
else
echo "您使用的邮件主机名称为:$HOST"
fi
##提示输入mysql管理员用户root的密码##
RETVAL=`cat /tmp/install.tmp|grep "vpopmail"|grep "igenus"|grep "successfully"`
if [ "$RETVAL" == "" ]; then
echo "你是否已经配置好mysql程序呢?Y/y表示已经完成,N/n表示还没有设置!"
read YN
if [ "$YN" == "Y" ]; then
$YN=y
fi
if [ "$YN" == "N" ]; then
$YN=n
fi
case $YN in
y)
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
echo "请输入mysql管理员用户root的密码"
read MYSQLPASSWD
mysqladmin -uroot -p$MYSQLPASSWD version 1> /dev/null 2>&1
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
INPUT="y"
echo "mysql管理员root密码输入正确!"
else
echo "mysql管理员密码错误,请重新输入!"
INPUT="n"
fi
done
;;
n)
RETVAL=3
until [ "$RETVAL" -eq 0 ]
do
echo "请输入mysql管理员用户root的旧密码,新安装的请直接按回车"
read OLDPASSWD
echo "请输入mysql管理员用户root的新密码"
read MYSQLPASSWD
if [ "$OLDPASSWD" == "" ]; then
mysqladmin -uroot password $MYSQLPASSWD 1> /dev/null 2>&1
service mysqld start
else
mysqladmin -uroot -p$OLDPASSWD password $MYSQLPASSWD 1> /dev/null 2>&1
service mysqld restart
fi
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo "mysql管理员root密码设置成功!"
else
echo "mysql管理员密码设置失败,请重新输入!"
fi
done
;;
*)
echo "输入有误,请重新运行程序!"
exit 1
esac
fi
##提示输入用于vpopmail的mysql数据库用户和密码##
USER=`grep "USER" /tmp/install.tmp|sed -e "s/^USER=//"`
if [ "$USER" == "" ]; then
echo "请输入用于vpopmail的mysql数据库用户,例如:vpopmail"
INPUT="n"
until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
do
read USER
echo "请输入$USER用户的密码"
read PASSWORD
echo "您输入的用于vpopmail的mysql数据库用户是:$USER,密码:$PASSWORD,请确认(y|n)?"
read INPUT
if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
echo "请确认用于vpopmail的mysql数据库用户后,重新输入:"
else
echo "USER=$USER" >> /tmp/install.tmp
echo "PASSWORD=$PASSWORD" >> /tmp/install.tmp
echo "您用于vpopmail的mysql数据库用户为:$USER,密码:$PASSWORD"
fi
done
else
PASSWORD=`grep "PASSWORD" /tmp/install.tmp|sed -e "s/^PASSWORD=//"`
echo "您用于vpopmail的mysql数据库用户为:$USER,密码:$PASSWORD"
fi
##判断sendmail是否已经启动##
echo "##判断sendmail是否在启动?##"
STRING=`rpm -q sendmail`
if [ "$STRING" != "package sendmail is not installed" ] ; then #判断系统是否安装有sendmail
/etc/rc.d/init.d/sendmail status
RETVAL=$?
if [ $RETVAL -eq 3 ]; then
echo "sendmail已经停止!!"
rpm -e --nodeps sendmail
rpm -e --nodeps sendmail-cf-8.13.1-2
rpm -e --nodeps sendmail-doc-8.13.1-2
rpm -e --nodeps sendmail-devel-8.13.1-2
else
echo "sendmail已经启动了,下面将其停止!"
/etc/rc.d/init.d/sendmail stop
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo "sendmail 停止成功。"
rpm -e --nodeps sendmail
rpm -e --nodeps sendmail-cf-8.13.1-2
rpm -e --nodeps sendmail-doc-8.13.1-2
rpm -e --nodeps sendmail-devel-8.13.1-2
else
echo "sendmail 停止有问题。请删除/var/lock/subsys/sendmail文件,再试试!"
fi
fi
else
echo "sendmail 已经卸载!"
fi
##开始准备工作##
echo "##开始准备工作!##"
if [ -f /tmp/install.tmp ]; then
RETVAL=`grep "standby" /tmp/install.tmp`
if [ "$RETVAL" == "" ]; then
cd /home
cp /root/pkg_2.9.tar.gz /home/
tar xzf pkg_2.9.tar.gz
chmod 755 -R pkg
cd pkg
tar xzf netqmail-1.05.tar.gz
cd netqmail-1.05
./collate.sh
echo "standby ready!" >> /tmp/install.tmp
echo "准备工作已经完成!"
else
echo "准备工作已经做过!"
fi
fi
##开始安装daemontools##
echo "##开始安装daemontools!##"
if [ -f /tmp/install.tmp ]; then
RETVAL=`cat /tmp/install.tmp|grep "daemontools"|grep "successfully"`
if [ "$RETVAL" == "" ]; then
cd /home/pkg
tar -zxf daemontools-0.76.tar.gz
cd admin/daemontools-0.76
patch -p1 < /home/pkg/netqmail-1.05/other-patches/daemontools-0.76.errno.patch
package/install
sleep 5
STATE=`ps ax|grep svscan|grep -v "grep svscan"`
if [ "$STATE" != "" ]; then
echo "daemontools运行正常!"
echo "daemontools has installed successfully!" >> /tmp/install.tmp
echo "daemontools已经安装完成!"
else
echo "daemontools安装完毕,但运行似乎有问题,请重新检查svscan进程!"
fi
else
echo "daemontools已经安装过了!"
fi
fi
##开始安装ucspi-tcp##
echo "##开始安装ucspi-tcp!##"
if [ -f /tmp/install.tmp ]; then
RETVAL=`cat /tmp/install.tmp|grep "ucspi-tcp"|grep "successfully"`
if [ "$RETVAL" == "" ]; then
cd /home/pkg
tar zxf ucspi-tcp-0.88.tar.gz
cd ucspi-tcp-0.88
patch -p1 < ../ucspi-tcp-0.88.errno.patch
make
make setup check
echo "ucspi-tcp has installed successfully!" >> /tmp/install.tmp
echo "ucspi-tcp已经安装完成!"
else
echo "ucspi-tcp已经安装过了!"
fi
fi
##开始创建原始qmail环境##
echo "##开始创建原始qmail环境!##"
if [ -f /tmp/install.tmp ]; then
RETVAL=`cat /tmp/install.tmp|grep "qmail"|grep "successfully"`
if [ "$RETVAL" == "" ]; then
mkdir /var/qmail
groupadd nofiles
useradd alias -g nofiles -d /var/qmail/alias -s /sbin/nologin
useradd qmaild -g nofiles -d /var/qmail -s /sbin/nologin
useradd qmaill -g nofiles -d /var/qmail -s /sbin/nologin
useradd qmailp -g nofiles -d /var/qmail -s /sbin/nologin
groupadd qmail
useradd qmailq -g qmail -d /var/qmail -s /sbin/nologin
useradd qmailr -g qmail -d /var/qmail -s /sbin/nologin
useradd qmails -g qmail -d /var/qmail -s /sbin/nologin
NUM=`grep "89" /etc/passwd` #如果系统原来存在uid为89的帐号,将其屏蔽
if [ $NUM != "" ]; then
sed -i "s/postfix/#&/" /etc/passwd /etc/group
fi
groupadd vchkpw -g 89
useradd vpopmail -u 89 -g vchkpw
echo "用户创建完毕!,下面进行Qmail的安装!"
cd /home/pkg
tar -xzf toaster-scripts-0.7.tar.gz
cd netqmail-1.05/netqmail-1.05/
#下面的sed是修正了一个无效提示的错误
sed -i "/straynewline/{ s/451/533/; }" qmail-smtpd.c
#部分版本需要添加include的链接
ln -s /usr/kerberos/include/com_err.h /usr/include/
rm -rf /usr/sbin/sendmail
make
make setup check
./config-fast $HOST
echo "设置管理员信箱!"
cd /var/qmail/alias
echo "admin@$DOMAIN" > .qmail-postmaster
echo "admin@$DOMAIN" > .qmail-mailer-daemon
echo "admin@$DOMAIN" > .qmail-root
chmod 644 /var/qmail/alias/.qmail*
echo "开启SPF设置!"
echo ./Maildir/ >/var/qmail/control/defaultdelivery
echo 3 > /var/qmail/control/spfbehavior
echo "添加qmail的帮助手册!"
echo MANPATH /var/qmail/man >> /etc/man.config
echo "为qmail服务建立监控目录和日志文件!"
mkdir -p /var/qmail/supervise/qmail-send/log
mkdir -p /var/qmail/supervise/qmail-smtpd/log
mkdir -p /var/qmail/supervise/qmail-pop3d/log
mkdir -p /var/qmail/supervise/qmail-pop3ds/log
cp /home/pkg/toaster-scripts-0.7/send.run /var/qmail/supervise/qmail-send/run
cp /home/pkg/toaster-scripts-0.7/send.log.run /var/qmail/supervise/qmail-send/log/run
cp /home/pkg/toaster-scripts-0.7/smtpd.run /var/qmail/supervise/qmail-smtpd/run
cp /home/pkg/toaster-scripts-0.7/smtpd.log.run /var/qmail/supervise/qmail-smtpd/log/run
cp /home/pkg/toaster-scripts-0.7/pop3d.run /var/qmail/supervise/qmail-pop3d/run
cp /home/pkg/toaster-scripts-0.7/pop3d.log.run /var/qmail/supervise/qmail-pop3d/log/run
cp /home/pkg/toaster-scripts-0.7/pop3ds.run /var/qmail/supervise/qmail-pop3ds/run
cp /home/pkg/toaster-scripts-0.7/pop3ds.log.run /var/qmail/supervise/qmail-pop3ds/log/run
echo 20 > /var/qmail/control/concurrencyincoming
chmod 644 /var/qmail/control/concurrencyincoming
chmod 755 /var/qmail/supervise/qmail-send/run
chmod 755 /var/qmail/supervise/qmail-send/log/run
chmod 755 /var/qmail/supervise/qmail-smtpd/run
chmod 755 /var/qmail/supervise/qmail-smtpd/log/run
chmod 755 /var/qmail/supervise/qmail-pop3d/run
chmod 755 /var/qmail/supervise/qmail-pop3d/log/run
chmod 755 /var/qmail/supervise/qmail-pop3ds/run
chmod 755 /var/qmail/supervise/qmail-pop3ds/log/run
mkdir -p /var/log/qmail/smtpd
mkdir -p /var/log/qmail/pop3d
mkdir -p /var/log/qmail/pop3ds
chown -R qmaill /var/log/qmail
echo "生成启动脚本!"
cd /home/pkg
cp toaster-scripts-0.7/rc /var/qmail/rc
chmod 755 /var/qmail/rc
cp toaster-scripts-0.7/qmailctl /var/qmail/bin/
chmod 755 /var/qmail/bin/qmailctl
ln -s /var/qmail/bin/qmailctl /usr/bin
ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail
rm -rf /usr/lib/sendmail
ln -s /var/qmail/bin/sendmail /usr/lib/sendmail
echo "设置用daemontools来启动qmail-send和qmail-smtpd!"
ln -s /var/qmail/supervise/qmail-send /var/qmail/supervise/qmail-smtpd /service
echo "启动qmail服务!"
echo "qmailctl start|stop|restart|doqueue|flush|reload|stat|pause|cont|cdb|queue|help"
echo "qmail has installed successfully!" >> /tmp/install.tmp
echo "原始的qmail程序已经安装完成!"
else
echo "qmail已经安装过了!"
fi
fi
##开始安装vpopmail##
echo "##开始安装vpopmail!##"
if [ -f /tmp/install.tmp ]; then
RETVAL=`cat /tmp/install.tmp|grep "vpopmail"|grep "successfully"`
if [ "$RETVAL" == "" ]; then
mkdir -p /home/vpopmail/etc
echo "$DOMAIN" > /home/vpopmail/etc/defaultdomain
echo "127.0.0.1:allow,RELAYCLIENT=""" > /home/vpopmail/etc/tcp.smtp
cd /home/vpopmail/etc ; tcprules tcp.smtp.cdb tcp.smtp.tmp < tcp.smtp
#设置MySQL信息,其中vpopmail是数据库名称
echo "localhost|0|$USER|$PASSWORD|vpopmail" > /home/vpopmail/etc/vpopmail.mysql
chmod 640 /home/vpopmail/etc/vpopmail.mysql
chown -R vpopmail.vchkpw /home/vpopmail/etc
cd /home/pkg/
#建立用于vpopmail的mysql数据库的脚本
echo "CREATE DATABASE vpopmail;" > vpopmail.sql
echo "GRANT select,insert,update,delete,create,drop ON vpopmail.*" >> vpopmail.sql
echo "TO $USER@localhost IDENTIFIED BY "$PASSWORD";" >> vpopmail.sql
echo "FLUSH PRIVILEGES;" >> vpopmail.sql
echo "QUIT" >> vpopmail.sql
#建立vpopmail数据库
mysql -uroot -p$MYSQLPASSWD < vpopmail.sql
tar xzf vpopmail-5.4.10.tar.gz
cd vpopmail-5.4.10
#编译并安装
./configure --enable-incdir=/usr/include/mysql --enable-libdir=/usr/lib/mysql --disable-roaming-users --enable-logging=p --disable-passwd --enable-clear-passwd --disable-domain-quotas --enable-auth-module=mysql --enable-auth-logging --enable-sql-logging --disable-valias --disable-mysql-limits --enable-learn-passwords
make
make install-strip
echo "export PATH=$PATH:/home/vpopmail/bin" >> /etc/profile
source /etc/profile
#建立初始域,admin是默认的域管理密码
#然后建立一个default用户做测试,后面的default是密码
vadddomain $DOMAIN admin
vadduser -q 10485760S default@$DOMAIN default
vmoduser -c 默认用户 default@$DOMAIN
#设置警告信息
cat /home/pkg/.quotawarn.msg > /home/vpopmail/domains/.quotawarn.msg
sed -i "s/domain.com/rfgz.com/g" /home/vpopmail/domains/.quotawarn.msg
echo "邮件被拒绝,用户的邮箱空间已满." > /home/vpopmail/domains/.over-quota.msg
#设置启动脚本
cp /home/pkg/toaster-scripts-0.7/vpopmailctl /var/qmail/bin
ln -s /var/qmail/bin/vpopmailctl /usr/bin
chmod 755 /var/qmail/bin/vpopmailctl
#打上qmail的补丁
cd /home/pkg/netqmail-1.05/netqmail-1.05
bunzip2 -c /home/pkg/qmail-toaster-0.7.2.patch.bz2 | patch -p0 -t
make clean
make
qmailctl stop
make setup check
chown -R vpopmail:vchkpw /var/qmail/spam
#生成SSL信息
echo "请根据提示,输入生成SSL需要的信息"
make cert
make tmprsadh
chown -R vpopmail:qmail /var/qmail/control/clientcert.pem /var/qmail/control/servercert.pem
#重启启动qmail服务
qmailctl start
ln -s /var/qmail/supervise/qmail-pop3d /service
ln -s /var/qmail/supervise/qmail-pop3ds /service
echo "vpopmailctl start|stop|restart|stat|pause|cont|help"
echo "vpopmail has installed successfully!" >> /tmp/install.tmp
echo "vpopmail程序已经安装完成!"
else
echo "vpopmail已经安装过了!"
fi
fi
##开始安装igenus##
echo "##开始安装igenus!##"
if [ -f /tmp/install.tmp ]; then
RETVAL=`cat /tmp/install.tmp|grep "igenus"|grep "successfully"`
if [ "$RETVAL" == "" ]; then
cd /home/pkg
tar zxf igenus_2.0.2_20040901_release.tgz -C /var/www/
cd /var/www/
rm -rf html/
mv igenus html
#准备一些必要的文件夹
mkdir /tmp/temp
chmod -R 0755 /tmp/temp
chown -R vpopmail:vchkpw /tmp/temp
mkdir /home/netdisk
chmod -R 0755 /home/netdisk
chown -R vpopmail:vchkpw /home/netdisk
chmod -R 0755 /var/www/html/
chown -R vpopmail:vchkpw /var/www/html/
#修改配置文件
cd /var/www/html/config
sed -i -e "/^$CFG_BASEPATH/{ s@/home/www/igenus@/var/www/html/@; }" config_inc.php
sed -i -e "/^$CFG_MYSQL_USER/{ s@vpopmail@$USER@; }" config_inc.php
sed -i -e "/^$CFG_MYSQL_PASS/{ s@vpopmail@$PASSWORD@; }" config_inc.php
sed -i -e "/^$CFG_TEMP =/d" -e "/^$CFG_TEMP_MOD/i $CFG_TEMP ="/tmp/temp/";" config_inc.php
#删除原来的数据库,新建一个
vdeldomain $DOMAIN
echo "use vpopmail;" > /home/pkg/drop_vpopmail.sql
echo "drop table lastauth;" >> /home/pkg/drop_vpopmail.sql
echo "drop table vpopmail;" >> /home/pkg/drop_vpopmail.sql
echo "quit" >> /home/pkg/drop_vpopmail.sql
mysql -uroot -p$MYSQLPASSWD < /home/pkg/drop_vpopmail.sql
sed -i -e "/^CREATE TABLE `address`/i use vpopmail;" /var/www/html/docs/iGENUS.sql
sed -i -e "/`pw_shell` varchar(20) default NULL,/a `pw_clear_passwd` varchar(16) default NULL," /var/www/html/docs/iGENUS.sql
mysql -uroot -p$MYSQLPASSWD </var/www/html/docs/iGENUS.sql
#建立虚拟主机
sed -i -e "/^register_globals/{ s/Off/On/; }" /etc/php.ini
sed -i -e "/^session.bug_compat_warn/{ s/1/0/; }" /etc/php.ini
sed -i -e "/^sendmail_path/{ s@/usr/sbin/sendmail -t -i@/var/qmail/bin/qmail-inject@ }" /etc/php.ini
echo "AddType application/x-httpd-php .php" >> /etc/httpd/conf/httpd.conf
echo "AddType application/x-httpd-php-source .phps" >> /etc/httpd/conf/httpd.conf
echo "DirectoryIndex index.php index.html" >> /etc/httpd/conf/httpd.conf
echo "NameVirtualHost *:80" >> /etc/httpd/conf/httpd.conf
echo "<VirtualHost *:80>" >> /etc/httpd/conf/httpd.conf
echo "ServerName $DOMAIN" >> /etc/httpd/conf/httpd.conf
echo "DocumentRoot /var/www/html" >> /etc/httpd/conf/httpd.conf
echo "</VirtualHost>" >> /etc/httpd/conf/httpd.conf
chmod 777 /var/lib/php/session/ -R
service httpd restart
#重新增加域
vadddomain $DOMAIN admin
vadduser -q 10485760S default@$DOMAIN default
vmoduser -c 默认用户 default@$DOMAIN
echo "igenus has installed successfully!" >> /tmp/install.tmp
echo "igenus程序已经安装完成!"
else
echo "igenus已经安装过了!"
fi
fi
##开始安装courier-imap##
echo "##开始安装courier-imap!##"
if [ -f /tmp/install.tmp ]; then
RETVAL=`cat /tmp/install.tmp|grep "courier-imap"|grep "successfully"`
if [ "$RETVAL" == "" ]; then
cd /home/pkg
tar -xjf courier-authlib-0.55.tar.bz2
cd courier-authlib-0.55
./configure --prefix=/usr/local --exec-prefix=/usr/local --with-authvchkpw --without-authldap --without-authmysql --disable-root-check --with-ssl --with-authchange pwdir=/usr/local/libexec/authlib --with-redhat
make
make install
make install-configure
sed -i "/^authmodulelist/{ s/authuserdb authpam authpgsql authcustom //; }" /usr/local/etc/authlib/authdaemonrc
sed -i "/^daemons=/{ s/5/2/; }" /usr/local/etc/authlib/authdaemonrc
#启动courier-authdaemond进程
/usr/local/sbin/authdaemond start
#判断服务是否运行正常
/usr/local/sbin/authtest default@$DOMAIN default
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
#设置开机自动启动
cp /usr/local/sbin/authdaemond /etc/init.d/
ln -s /etc/init.d/authdaemond /etc/rc.d/rc3.d/S80authdaemond
ln -s /etc/init.d/authdaemond /etc/rc.d/rc5.d/S80authdaemond
echo "courier-authlib安装成功!"
fi
#开始安装courier-imap
cd /home/pkg
tar -xjf courier-imap-4.0.2.tar.bz2
cd courier-imap-4.0.2
chown -R vpopmail:vchkpw ../courier-imap-4.0.2
su vpopmail -c "./configure --with-redhat;make" #使用vpopmail用户进行编译
make install-strip
make install-configure
cp courier-imap.sysvinit /etc/rc.d/init.d/courier-imap
#设置开机自动启动
chmod 755 /etc/rc.d/init.d/courier-imap
chkconfig --add courier-imap
chkconfig --level 35 courier-imap on
if ! [ -f /usr/lib/courier-imap/etc/authdaemonrc ]; then
ln -s /usr/local/etc/authlib/authdaemonrc /usr/lib/courier-imap/etc/authdaemonrc
fi
#根据实际情况,修改配置文件
sed -i -e "s/^IMAPDSTART=/#&/" -e "/^#IMAPDSTART=/a IMAPDSTART=YES" /usr/lib/courier-imap/etc/imapd
sed -i -e "s/^IMAPDSSLSTART=/#&/" -e "/^#IMAPDSSLSTART=/a IMAPDSSLSTART=YES" /usr/lib/courier-imap/etc/imapd-ssl
sed -i "/^CN/{ s/localhost/$DOMAIN/; }" /usr/lib/courier-imap/etc/imapd.cnf
sed -i "/^emailAddress/{ s/(postmaster@)example.com/1$DOMAIN/; }" /usr/lib/courier-imap/etc/imapd.cnf
sed -i "/^CN/{ s/localhost/$DOMAIN/; }" /usr/lib/courier-imap/etc/pop3d.cnf
sed -i "/^emailAddress/{ s/(postmaster@)example.com/1$DOMAIN/; }" /usr/lib/courier-imap/etc/pop3d.cnf
#启动courier-imap进程
/etc/rc.d/init.d/courier-imap start
echo "courier-imap has installed successfully!" >> /tmp/install.tmp
echo "courier-imap已经安装完成!"
else
echo "courier-imap已经安装过了!"
fi
fi
##开始安装autorespond##
echo "##开始安装autorespond!##"
if [ -f /tmp/install.tmp ]; then
RETVAL=`cat /tmp/install.tmp|grep "autorespond"|grep "successfully"`
if [ "$RETVAL" == "" ]; then
cd /home/pkg
tar -xzf autorespond-2.0.5.tar.gz
cd autorespond-2.0.5
make
make install
echo "autorespond has installed successfully!" >> /tmp/install.tmp
echo "autorespond已经安装完成!"
else
echo "autorespond已经安装过了!"
fi
fi
##开始安装ezmlm##
echo "##开始安装ezmlm!##"
if [ -f /tmp/install.tmp ]; then
RETVAL=`cat /tmp/install.tmp|grep "ezmlm"|grep "successfully"`
if [ "$RETVAL" == "" ]; then
cd /home/pkg
tar -xzf ezmlm-0.53.tar.gz
tar -xzf ezmlm-idx-0.42.tar.gz
cp -rf ezmlm-idx-0.42/* ezmlm-0.53/
cd ezmlm-0.53
patch < idx.patch
chmod u+x makelang
make
make man
make ch_GB
make setup
echo "ezmlm has installed successfully!" >> /tmp/install.tmp
echo "ezmlm已经安装完成!"
else
echo "ezmlm已经安装过了!"
fi
fi
##开始安装qmailadmin##
echo "##开始安装qmailadmin!##"
if [ -f /tmp/install.tmp ]; then
RETVAL=`cat /tmp/install.tmp|grep "qmailadmin"|grep "successfully"`
if [ "$RETVAL" == "" ]; then
cd /home/pkg
tar -xzf qmailadmin-1.2.3.tar.gz
cd qmailadmin-1.2.3
./configure --enable-htmldir=/var/www/html --enable-cgibindir=/var/www/cgi-bin --enable-vpopuser=vpopmail --enable-autoresponder-bin=/usr/bin --disable-ezmlm-mysql --enable-maxusersperpage=20 --enable-maxaliasesperpage=20 --enable-modify-quota --enable-domain-autofill
make
make install-strip
cd /usr/local/share/qmailadmin/lang
mv en en.bak
cp zh-cn en
echo "qmailadmin has installed successfully!" >> /tmp/install.tmp
echo "qmailadmin已经安装完成!"
else
echo "qmailadmin已经安装过了!"
fi
fi
##开始安装vqadmin##
echo "##开始安装vqadmin!##"
if [ -f /tmp/install.tmp ]; then
RETVAL=`cat /tmp/install.tmp|grep "vqadmin"|grep "successfully"`
if [ "$RETVAL" == "" ]; then
cd /home/pkg
tar -zxf vqadmin-2.3.6.tar.gz
cd vqadmin-2.3.6
sed -i "/*user/{ s/my_user/$USER/ }" db_owner.c
sed -i "/*passwd/{ s/my_password/$PASSWORD/ }" db_owner.c
sed -i "/*db/{ s/my_database/vpopmail/ }" db_owner.c
./configure
make
make install
#添加apache中vqadmin的域
echo "<Directory "/var/www/cgi-bin/vqadmin">" >> /etc/httpd/conf/httpd.conf
echo "deny from all" >> /etc/httpd/conf/httpd.conf
echo "Options ExecCGI" >> /etc/httpd/conf/httpd.conf
echo "AllowOverride AuthConfig" >> /etc/httpd/conf/httpd.conf
echo "Order deny,allow" >> /etc/httpd/conf/httpd.conf
echo "</Directory> " >> /etc/httpd/conf/httpd.conf
cd /var/www/cgi-bin/vqadmin
chown nobody .htaccess
chmod 600 .htaccess
#创建默认的管理帐号
htpasswd -bc /etc/httpd/conf/vqadmin.passwd admin admin
echo "请留意,vqadmin默认管理帐号:admin,密码:admin!"
chown vpopmail.vchkpw /etc/httpd/conf/vqadmin.passwd
chmod 644 /etc/httpd/conf/vqadmin.passwd
#配置apache环境
sed -i -e "s/^User apache/#&/" -e "s/^Group apache/#&/" -e "/^#Group apache/a User vpopmail
Group vchkpw" /etc/httpd/conf/httpd.conf
sed -i -e "s/^AddDefaultCharset/#&/" -e "/^#AddDefaultCharset/a AddDefaultCharset GB2312" /etc/httpd/conf/httpd.conf
chown -R vpopmail.vchkpw /var/www/cgi-bin
sed -i -e "/^AuthUserFile/d" -e "/^AuthType Basic/a AuthUserFile /etc/httpd/conf/vqadmin.passwd" .htaccess
service httpd status 1>/dev/null 2>&1
HTTPSTAT=$?
if [ $HTTPSTAT -eq 3 ]; then
service httpd start
else
service httpd restart
fi
echo "vqadmin has installed successfully!" >> /tmp/install.tmp
echo "vqadmin已经安装完成!"
else
echo "vqadmin已经安装过了!"
fi
fi
##开始安装spamassassin##
echo "##开始安装spamassassin!##"
if [ -f /tmp/install.tmp ]; then
RETVAL=`cat /tmp/install.tmp|grep "spamassassin"|grep "successfully"`
if [ "$RETVAL" == "" ]; then
cd /home/pkg
rpm -Uvh spamassassin-3.0.2-2.1.el3.rf.i386.rpm
rpm -Uvh perl-Razor-Agent-2.40-2.i386.rpm
#修改配置文件
sed -i -e "s/^SPAMDOPTIONS=/#&/" -e "/^#SPAMDOPTIONS=/a SPAMDOPTIONS="-d -c -m5 -H -x spamd -v"" /etc/init.d/spamassassin
sed -i -e "s/^SPAMDOPTIONS=/#&/" -e "/^#SPAMDOPTIONS=/a SPAMDOPTIONS="-d -c -m5 -H -x spamd -v"" /etc/sysconfig/spamassassin
rm -rf /etc/mail/spamassassin/local.cf
tar xzf /home/pkg/spamassassin.local.cf.tar.gz -C /etc/mail/spamassassin/
chkconfig --level 35 spamassassin on
#启动spamassain
tar xzf /home/pkg/spamassassin.Chinese_rules.tar.gz /usr/share/spamassassin/
service spamassassin start
sa-learn --sync -D -p user_prefs
echo "spamassassin has installed successfully!" >> /tmp/install.tmp
echo "spamassassin已经安装完成!"
else
echo "spamassassin已经安装过了!"
fi
fi
##开始安装clamav##
echo "##开始安装clamav!##"
if [ -f /tmp/install.tmp ]; then
RETVAL=`cat /tmp/install.tmp|grep "clamav"|grep "successfully"`
if [ "$RETVAL" == "" ]; then
groupadd clamav
useradd -g clamav -s /bin/false clamav
cd /home/pkg
tar -xzf clamav-0.83.tar.gz
cd clamav-0.83
./configure --disable-zlib-vcheck
make check
make install
#修改配置文件
sed -i -e "s/^Example/#&/" -e "s@^#(UpdateLogFile /var/log/freshclam.log)@1@" -e "s/^#(LogSyslog)/1/" -e "s@^#(PidFile /var/run/freshclam.pid)@1@" /usr/local/etc/freshclam.conf
sed -i -e "s/^Example/#&/" -e "s@^#LogFile /tmp/clamd.log@LogFile /var/log/clamav/clamd.log@" -e "s@^#(LogFileMaxSize 2M)@1@" -e "s@^#(LogTime)@1@" /usr/local/etc/clamd.conf
sed -i -e "s@^#(PidFile /var/run/clamd.pid)@1@" -e "s@^#(LogSyslog)@1@" -e "s@^#(ScanMail)@1@" /usr/local/etc/clamd.conf
#创建freshclam日志记录文件
touch /var/log/freshclam.log
chmod 644 /var/log/freshclam.log
chown clamav:clamav /var/log/freshclam.log
mkdir /var/lib/clamav
chown clamav:clamav /var/lib/clamav
#创建clamv日志记录文件
mkdir -p /var/log/clamav
touch /var/log/clamav/clamd.log
chown clamav.clamav -R /var/log/clamav/
chmod 644 -R /var/log/clamav/
tar xzf /home/pkg/clamav.sh.tar.gz -C /etc/init.d/
chmod 755 /etc/init.d/clamav
ln -s /etc/init.d/clamav /etc/rc.d/rc3.d/S88clamav
ln -s /etc/init.d/clamav /etc/rc.d/rc5.d/S88clamav
echo "clamav has installed successfully!" >> /tmp/install.tmp
echo "clamav已经安装完成!"
else
echo "clamav已经安装过了!"
fi
fi
##开始安装maildrop和TNEF reader##
echo "##开始安装maildrop和TNEF reader!##"
if [ -f /tmp/install.tmp ]; then
RETVAL=`cat /tmp/install.tmp|grep "maildrop"|grep "TNEF reader"|grep "successfully"`
if [ "$RETVAL" == "" ]; then
#安装maildrop
cd /home/pkg
tar -xjf maildrop-1.8.0.tar.bz2
cd maildrop-1.8.0
./configure
make
make install-strip
make install-man
#安装TNEF reader
cd /home/pkg
tar -xzf tnef-1.2.3.1.tar.gz
cd tnef-1.2.3.1
./configure
make
make install
#使用Maildrop调用SpamAssassin
tar xzf /home/pkg/mailfilter.tar.gz -C /home/vpopmail/domains/$DOMAIN
cd /home/vpopmail/domains/$DOMAIN
chown vpopmail:vchkpw mailfilter
chmod 700 mailfilter
echo "| preline /usr/local/bin/maildrop mailfilter" >> .qmail-default
echo "maildrop & TNEF reader has installed successfully!" >> /tmp/install.tmp
echo "maildrop和TNEF reader已经安装完成!"
else
echo "maildrop和TNEF reader已经安装过了!"
fi
fi
##开始安装qmail-scanner和qms-analog##
echo "##qmail-scanner和qms-analog!##"
if [ -f /tmp/install.tmp ]; then
RETVAL=`cat /tmp/install.tmp|grep "qmail-scanner"|grep "qms-analog"|grep "successfully"`
if [ "$RETVAL" == "" ]; then
cd /home/pkg
rpm -Uvh perl-suidperl-5.8.5-12.1.1.i386.rpm
tar zxf qmail-scanner-1.25.tgz
tar zxf qms-analog-0.4.2.tar.gz
cd qms-analog-0.4.2
make all
cp qmail-scanner-1.25-st-qms-20050219.patch /home/pkg/qmail-scanner-1.25
cd /home/pkg/qmail-scanner-1.25
patch -p1 < qmail-scanner-1.25-st-qms-20050219.patch
groupadd qscand
useradd -g qscand -s /bin/false qscand
sed -i -e "s/yourdomain.com/$DOMAIN/" -e "s/,yourotherdomain.com//" qms-config
sed -i -e "/--qms-monitor no/a --lang en_GB
--debug no
--unzip yes
--scanners clamscan,verbose_spamassassin " qms-config
chmod 755 qms-config
echo "请留意屏幕提示,都按y确认即可!"
./qms-config install
setuidgid qscand /var/qmail/bin/qmail-scanner-queue.pl -z
setuidgid qscand /var/qmail/bin/qmail-scanner-queue.pl -r
setuidgid qscand /var/qmail/bin/qmail-scanner-queue.pl -g
chown qscand:qscand /var/qmail/bin/qmail-scanner-queue.pl
chmod 4755 /var/qmail/bin/qmail-scanner-queue.pl
chown -R qscand:qscand /var/spool/qmailscan
sed -i -e "/softlimit/{ s/8000000/40000000/ }" /var/qmail/supervise/qmail-smtpd/run
qmailctl stop
qmailctl start
echo "qmail-scanner & qms-analog has installed successfully!" >> /tmp/install.tmp
echo "qmail-scanner和qms-analog已经安装完成!"
else
echo "qmail-scanner和qms-analog已经安装过了!"
fi
fi
##开始安装qmailanalog和qlogtools##
echo "##qmailanalog和qlogtools!##"
if [ -f /tmp/install.tmp ]; then
RETVAL=`cat /tmp/install.tmp|grep "qmailanalog"|grep "qlogtools"|grep "successfully"`
if [ "$RETVAL" == "" ]; then
#安装qmailanalog
cd /home/pkg/
tar zxf qmailanalog-0.70.tar.gz
cd qmailanalog-0.70
patch < /home/pkg/qmailanalog-0.70.errno.patch
make && make setup check
#安装qlogtools
cd /home/pkg/
tar zxf qlogtools-3.1.tar.gz
cd qlogtools-3.1
patch < /home/pkg/qlogtools_errno.patch
make
./installer
#设置配置文件
tar xzf /home/pkg/qmailstats.tar.gz -C /var/qmail/bin/
sed -i -e "s/<your_postmaster>@yourdomain.com/postmaster@$DOMAIN/" /var/qmail/bin/qmailstats
chmod 750 /var/qmail/bin/qmailstats
/var/qmail/bin/qmailstats
echo "qmailanalog & qlogtools has installed successfully!" >> /tmp/install.tmp
echo "qmailanalog和qlogtools已经安装完成!"
echo "所有程序已经安装完成!请保留/home/pkg/admin目录,其他的可以删除!"
else
echo "qmailanalog和qlogtools已经安装过了!"
fi
fi
下载点击
建议你转到EMOS环境中,其安装、配置、使用都简单和方便很多。本博客中有下载。