|
#!/bin/sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
# Qmail Setup Script v1.5.3
# 2003-02-28 10 :17
# compile by iceblood
# Copyright (C) 2003 by iceblood
# E-mail:[email protected]
# Warning !! This script only for FreeBSD or Linux,not use other system.
# Please set your system,default is FreeBSD,more have Linux
_OS="Linux"
# Please set your language,default is EN,more have CN
_LANG="CN"
# If you don't need install apache
# Please set the _INSTALLAPACHE="NO"
# if you want change the apache install
# path, you can modify the _APACHEPATH
_INSTALLAPACHE="NO"
# If Qmail Users Already exist
# Please set the ADDQMAILUSERS="NO"
_ADDQMAILUSERS="YES"
# Domain Name
_DOMAIN=localhost.localdomain
# MailAdmin Password
_MAILPASSWD=1234
# set you CGI Path
_CGIBIN=/var/www/cgi-bin
# set you Html Path
_HTMLPATH=/var/www/html
###########--------Advanced set--------#################
# "n" disables quotas, or # where # is a number in bytes NOT y, do not use "Y", "y" is BAD
_MAILSIZE=n
# enable virutal domain lookup via reverse ip address lookup for virtual domains. "y" and "n"
_USERCRUISE=n
# apache install path
_APACHEPATH=/usr/local/httpd
# do you use system password. "y" and "n"
_SYSTEMPASS=n
# install vpopmail "YES" or "NO"
_VPOPMAIL="YES"
# install ezmlm "YES" or "NO"
_EZMLMIN="YES"
# ezmlm coding
_EZMLM=ch_GB
# install autorespond "YES" or "NO"
_AUTORESPOND="YES"
# install QmailAdmin "YES" or "NO"
_QMAILADMIN="YES"
##########--------SqWebMail set--------#############
# install webmail "YES" or "NO"
_WEBMAIL="YES"
# webmail coding set.have "iso","gb2312","big5" and more.
_MIMESET=utf8
# webmail use SSL,"YES" or "NO"
_WEBHTTPS="NO"
##########--------SQL set---------################
# use mysql,default is no,if you use mysql for set "y"
_SQL=n
# mysql host
_SQLHOST=localhost
# mysql user
_SQLUSER=root
# mysql passwd
_SQLPASS=*****
# include path
_INCDIR=/usr/include/mysql
# lib file path
_LIBDIR=/usr/lib/mysql
###########--------install scripts------Please don't change for here!!!! ############
########---------Check software-------------################
OS=`uname -s`
if [ "$OS" != "$_OS" ]; then
echo "Your system is $OS"
echo "Please set _OS for $OS."
exit 0
fi
echo "Checking...for root"
QUID=`whoami`
if [ "$QUID" != "root" ]; then
echo 'Sorry,Please su to "root"'
exit 0
fi
echo "Checking...for gcc"
which gcc
if [ "$?" = 1 ]; then
echo 'Sorry,Your system not "gcc" program!'
exit 0
fi
echo "Checking...for g++"
which g++
if [ "$?" = 1 ]; then
echo 'Sorry,Your system not "g++" program!'
exit 0
fi
echo "Checking...for make"
which make
if [ "$?" = 1 ]; then
echo 'Sorry,Your system not "make" program!'
exit 0
fi
echo "Checking...for perl"
which perl
if [ "$?" = 1 ]; then
echo 'Sorry,Your system not "perl" program!'
exit 0
fi
if [ "$_SQL" = "y" ]; then
echo "Checking...for mysql"
SQLID=`ps -ax |grep mysql |grep -v grep`
if [ "$SQLID" = "" ]; then
echo "Sorry,You not run MySQL Services..."
exit 0
fi
SQLLIB=`find $_LIBDIR -name libmysqlclient.so.10`
if [ "$SQLLIB" = "" ]; then
echo "Sorrt,You not have libmysqlclient.so.10 in $SQLLIB"
exit 0
fi
cp $SQLLIB /usr/lib
fi
echo "# Qmail Setup Script v1.5.3"
echo "# 2002-09-02 10 :17"
echo "# compile by iceblood"
echo "# Copyright (C) 2002 by iceblood"
echo "# E-mail:[email protected]"
mkdir -p /etc/qmail
mkdir -p /tmp/iceblood/Qmail_setup
mkdir -p /var/uninstall
echo >/var/uninstall/qmailinstall.log 2>&1
echo "##### -- Now Copy Files ---####"
cp -rp ./* /tmp/iceblood/Qmail_setup
cd /tmp/iceblood/Qmail_setup
if [ "$_INSTALLAPACHE" = "YES" ]; then
[ ! -n "$_APACHEPATH" ] && _APACHEPATH=/usr/local/httpd
echo "##########---------- Apache install-----------#############" >>/var/uninstall/qmailinstall.log 2>&1
echo "Installing Apache,Please waiting..."
sh /tmp/iceblood/Qmail_setup/iceblood/sleep.sh &
EID=$!
echo "###---- Apache's path is $_APACHEPATH ----###"
mkdir -p $_APACHEPATH >/dev/null 2>&1
tar xzf httpd-2.0.40.tar.gz
cd httpd-2.0.40
./configure --prefix=$_APACHEPATH >>/var/uninstall/qmailinstall.log 2>&1
make >>/var/uninstall/qmailinstall.log 2>&1
make install >>/var/uninstall/qmailinstall.log 2>&1
perl -i -pe 's/#AddHandler\ cgi-script\ .cgi/Addhandler\ cgi-script\ .cgi\ .pl/' $_APACHEPATH/conf/httpd.conf
perl -i -pe "s/AddDefaultCharset ISO-8859-1/AddDefaultCharset $_MIMESET/" $_APACHEPATH/conf/httpd.conf
echo "$_APACHEPATH/bin/apachectl start">/etc/qmail/start
kill $EID >/dev/null 2>&1
echo "Apache Install Done."
fi
cd /tmp/iceblood/Qmail_setup
echo "##########----------Qmail install-----------##############" >>/var/uninstall/qmailinstall.log 2>&1
echo "Installing Qmail,Please waiting..."
sh /tmp/iceblood/Qmail_setup/iceblood/sleep.sh &
EID=$!
cd /tmp/iceblood/Qmail_setup
mkdir -p /usr/local/qmail
if [ "$_ADDQMAILUSERS" = "YES" ]; then
if [ "$_OS" = "FreeBSD" ]; then
echo "##########------Now Add Qmail Users-----##############"
ln -s /usr/home /home >/dev/null 2>&1
pw userdel alias >/dev/null 2>&1
pw userdel qmaild >/dev/null 2>&1
pw userdel qmaill >/dev/null 2>&1
pw userdel qmailp >/dev/null 2>&1
pw userdel qmailq >/dev/null 2>&1
pw userdel qmailr >/dev/null 2>&1
pw userdel qmails >/dev/null 2>&1
pw groupdel nofiles >/dev/null 2>&1
pw groupdel qmail >/dev/null 2>&1
pw groupadd nofiles
pw useradd alias -g nofiles -d /usr/local/qmail/alias -s /nonexistent
pw useradd qmaild -g nofiles -d /usr/local/qmail -s /nonexistent
pw useradd qmaill -g nofiles -d /usr/local/qmail -s /nonexistent
pw useradd qmailp -g nofiles -d /usr/local/qmail -s /nonexistent
pw groupadd qmail
pw useradd qmailq -g qmail -d /usr/local/qmail -s /nonexistent
pw useradd qmailr -g qmail -d /usr/local/qmail -s /nonexistent
pw useradd qmails -g qmail -d /usr/local/qmail -s /nonexistent
fi
if [ "$_OS" = "Linux" ]; then
userdel alias >/dev/null 2>&1
userdel qmaild >/dev/null 2>&1
userdel qmaill >/dev/null 2>&1
userdel qmailp >/dev/null 2>&1
userdel qmailq >/dev/null 2>&1
userdel qmailr >/dev/null 2>&1
userdel qmails >/dev/null 2>&1
groupdel nofiles >/dev/null 2>&1
groupdel qmail >/dev/null 2>&1
groupadd nofiles
useradd -g nofiles -d /usr/local/qmail/alias alias
useradd -g nofiles -d /usr/local/qmail qmaild
useradd -g nofiles -d /usr/local/qmail qmaill
useradd -g nofiles -d /usr/local/qmail qmailp
groupadd qmail
useradd -g qmail -d /usr/local/qmail qmailq
useradd -g qmail -d /usr/local/qmail qmailr
useradd -g qmail -d /usr/local/qmail qmails
fi
echo "##########------Add Qmail Users Successful-----##############"
fi
mkdir -p /usr/local/qmail
tar xzf qmail-1.03.tar.gz
patch -p0 < qmail-103.patch >>/var/uninstall/qmailinstall.log 2>&1
cd qmail-1.03
make setup check >>/var/uninstall/qmailinstall.log 2>&1
./config-fast $_DOMAIN >>/var/uninstall/qmailinstall.log 2>&1
cd /usr/local/qmail/alias
touch .qmail-postmaster .qmail-mailer-daemon .qmail-root
chmod 644 /usr/local/qmail/alias/.qmail*
cp /usr/local/qmail/boot/home /usr/local/qmail/rc
perl -i -pe 's/Mailbox/Maildir/' /usr/local/qmail/rc
if ["$_OS" = "FreeBSD" ]; then
perl -i -pe 's/sendmail_enable="YES"/sendmail_enable="NO"/' /etc/rc.conf
perl -i -pe 's/sendmail_submit_enable="YES"/sendmail_submit_enable="NO"/' /etc/defaults/rc.conf
perl -i -pe 's/sendmail_outbound_enable="YES"/sendmail_outbound_enable="NO"/' /etc/defaults/rc.conf
perl -i -pe 's/sendmail_msp_queue_enable="YES"/sendmail_msp_queue_enable="NO"/' /etc/defaults/rc.conf
fi
killall sendmail >/dev/null 2>&1
rpm -e fetchmail >/dev/null 2>&1
rpm -e mutt >/dev/null 2>&1
rpm -e sendmail >/dev/null 2>&1
chmod 0 /usr/lib/sendmail >/dev/null 2>&1
chmod 0 /usr/sbin/sendmail >/dev/null 2>&1
chmod 0 /usr/lib/sendmail.mx >/dev/null 2>&1
mv /usr/lib/sendmail /usr/lib/sendmail.bak >/dev/null 2>&1
mv /usr/sbin/sendmail /usr/sbin/sendmail.bak >/dev/null 2>&1
ln -s /usr/local/qmail/bin/sendmail /usr/lib/sendmail
ln -s /usr/local/qmail/bin/sendmail /usr/sbin/sendmail
echo "csh -cf '/usr/local/qmail/rc &'">>/etc/qmail/start
echo "/etc/qmail/smtp.sh">>/etc/qmail/start
kill $EID >/dev/null 2>&1
echo "Qmail Install done."
cd /tmp/iceblood/Qmail_setup
echo "##########----------ucspi-tcp-0.88 install---------############" >>/var/uninstall/qmailinstall.log 2>&1
echo "Installing ucspi-tcp,Please waiting..."
sh /tmp/iceblood/Qmail_setup/iceblood/sleep.sh &
EID=$!
cd /tmp/iceblood/Qmail_setup
tar zxf ucspi-tcp-0.88.tar.gz
cd ucspi-tcp-0.88
make >>/var/uninstall/qmailinstall.log 2>&1
make setup check >>/var/uninstall/qmailinstall.log 2>&1
QMAILDUID=`/usr/bin/id -u qmaild`
NOFILESGID=`/usr/bin/id -g qmaild`
echo "/usr/local/qmail/bin/tcpserver -H -R -l $_DOMAIN -t 1 -c 100 -v -p -x/etc/qmail/tcp.smtp.cdb -u $QMAILDUID -g $NOFILESGID 0 smtp /usr/local/qmail/bin/qmail-smtpd /home/vpopmail/bin/vchkpw /usr/bin/true /usr/local/qmail/bin/cmd5checkpw /usr/bin/true 2>&1 | /usr/local/qmail/bin/splogger &">/etc/qmail/smtp.sh
chmod 755 /etc/qmail/smtp.sh
echo "127.0.0.1:allow,RELAYCLIENT="\"\" > /etc/qmail/tcp.smtp
#echo ":allow">>/etc/qmail/tcp.smtp
/usr/local/qmail/bin/tcprules /etc/qmail/tcp.smtp.cdb /etc/qmail/tcp.smtp.tmp < /etc/qmail/tcp.smtp
kill $EID >/dev/null 2>&1
echo "Ucspi-tcp Install done."
cd /tmp/iceblood/Qmail_setup
echo "#########---------cmd5checkpw install ---------##############" >>/var/uninstall/qmailinstall.log 2>&1
echo "Installing cmd5checkpw,Please waiting..."
sh /tmp/iceblood/Qmail_setup/iceblood/sleep.sh &
EID=$!
cd /tmp/iceblood/Qmail_setup
tar xzf cmd5checkpw-0.22.tar.gz
mkdir -p /usr/local/qmail/man/man8
cd cmd5checkpw-0.22
make >>/var/uninstall/qmailinstall.log 2>&1
make install >>/var/uninstall/qmailinstall.log 2>&1
kill $EID >/dev/null 2>&1
echo "cmd5checkpw Install Done."
cd /tmp/iceblood/Qmail_setup
if [ "$_VPOPMAIL" = "YES" ]; then
echo "#########----------vpopmail install----------##############" >>/var/uninstall/qmailinstall.log 2>&1
echo "Installing vpopmail,Please waiting..."
sh /tmp/iceblood/Qmail_setup/iceblood/sleep.sh &
EID=$!
cd /tmp/iceblood/Qmail_setup
if [ "$_OS" = "FreeBSD" ]; then
pw userdel vpopmail >/dev/null 2>&1
pw groupdel vchkpw >/dev/null 2>&1
pw groupadd vchkpw
pw useradd vpopmail -g vchkpw -d /home/vpopmail
echo "/etc/qmail/start">>/etc/rc.local
fi
if [ "$_OS" = "Linux" ]; then
userdel vpopmail
groupdel vchkpw
groupadd vchkpw
useradd -g vchkpw -d /home/vpopmail vpopmail
echo "/etc/qmail/start">>/etc/rc.d/rc.local
fi
mkdir -p /home/vpopmail/etc
echo "127.0.0.1:allow,RELAYCLIENT="\"\" > /home/vpopmail/etc/tcp.smtp
tar xzf vpopmail-5.2.1.tar.gz
perl mysql.pl ./vpopmail-5.2.1/vmysql.h
cd vpopmail-5.2.1
if [ "$_SQL" = "y" ]; then
./configure --enable-default-domain=$_DOMAIN --enable-clear-passwd=n --enable-passwd=$_SYSTEMPASS --enable-tcprules-prog=/usr/local/qmail/bin/tcprules --enable-ip-alias-domains=$_USERCRUISE --enable-defaultquota=$_MAILSIZE --enable-sqwebmail-pass=y --enable-qmaildir=/usr/local/qmail --enable-roaming-users=$_SQL --enable-mysql=$_SQL --enable-incdir=$_INCDIR --enable-libdir=$_LIBDIR >>/var/uninstall/qmailinstall.log 2>&1
else
./configure --enable-default-domain=$_DOMAIN --enable-clear-passwd=n --enable-passwd=$_SYSTEMPASS --enable-tcprules-prog=/usr/local/qmail/bin/tcprules --enable-ip-alias-domains=$_USERCRUISE --enable-defaultquota=$_MAILSIZE --enable-sqwebmail-pass=y --enable-qmaildir=/usr/local/qmail >>/var/uninstall/qmailinstall.log 2>&1
fi
make >>/var/uninstall/qmailinstall.log 2>&1
make install-strip >>/var/uninstall/qmailinstall.log 2>&1
QMAILDUID=`/usr/bin/id -u qmaild`
NOFILESGID=`/usr/bin/id -g qmaild`
echo "/usr/local/qmail/bin/tcpserver -c 100 -v -l $_DOMAIN -U -H -R 0 pop3 /usr/local/qmail/bin/qmail-popup $_DOMAIN /home/vpopmail/bin/vchkpw /usr/local/qmail/bin/qmail-pop3d Maildir 2>&1 | /usr/local/qmail/bin/splogger &">/etc/qmail/pop.sh
chmod 755 /etc/qmail/pop.sh
echo "/etc/qmail/pop.sh">>/etc/qmail/start
chmod 6755 /home/vpopmail/bin/vchkpw
~vpopmail/bin/vadddomain $_DOMAIN $_MAILPASSWD
kill $EID >/dev/null 2>&1
echo "vpopmail Install Done."
cd /tmp/iceblood/Qmail_setup
fi
if [ "$_EZMLMIN" = "YES" ]; then
echo "#########----------ezmlm install---------############" >>/var/uninstall/qmailinstall.log 2>&1
echo "Installing ezmlm,Please waiting..."
sh /tmp/iceblood/Qmail_setup/iceblood/sleep.sh &
EID=$!
tar zxf ezmlm-0.53.tar.gz
cd ezmlm-0.53
patch < idx.patch >>/var/uninstall/qmailinstall.log 2>&1
if [ "$_SQL" = "y" ]; then
if [ "$_OS" = "FreeBSD" ]; then
echo "-I$_INCDIR" > sub_mysql/conf-sqlcc
echo "-L$_LIBDIR -lmysqlclient -lm -lz" > sub_mysql/conf-sqlld
else
echo "-I$_INCDIR" > sub_mysql/conf-sqlcc
echo "-L$_LIBDIR -lmysqlclient -lnsl -lm -lz" > sub_mysql/conf-sqlld
fi
make mysql >>/var/uninstall/qmailinstall.log 2>&1
make man >>/var/uninstall/qmailinstall.log 2>&1
make $_EZMLM >>/var/uninstall/qmailinstall.log 2>&1
make setup >>/var/uninstall/qmailinstall.log 2>&1
else
make >>/var/uninstall/qmailinstall.log 2>&1
make man >>/var/uninstall/qmailinstall.log 2>&1
make $_EZMLM >>/var/uninstall/qmailinstall.log 2>&1
make setup >>/var/uninstall/qmailinstall.log 2>&1
fi
kill $EID >/dev/null 2>&1
echo "ezmlm Install Done."
cd /tmp/iceblood/Qmail_setup
fi
if [ "$_AUTORESPOND" = "YES" ]; then
echo "#########-----------autorespond install-----###########" >>/var/uninstall/qmailinstall.log 2>&1
echo "Installing autorespond,Please waiting..."
sh /tmp/iceblood/Qmail_setup/iceblood/sleep.sh &
EID=$!
cd /tmp/iceblood/Qmail_setup
if [ "$_OS" = "FreeBSD" ]; then
mv /usr/include/string.h /usr/include/string.h.bak
cp string.h /usr/include/
fi
tar xzf autorespond-2.0.2.tar.gz
cd autorespond-2.0.2
make >>/var/uninstall/qmailinstall.log 2>&1
make install >>/var/uninstall/qmailinstall.log 2>&1
mv /usr/include/string.h.bak /usr/include/string.h
kill $EID >/dev/null 2>&1
echo "autorespond Install Done."
cd /tmp/iceblood/Qmail_setup
fi
if [ "$_QMAILADMIN" = "YES" ]; then
echo "#########-----------Qmailadmin install------############" >>/var/uninstall/qmailinstall.log 2>&1
echo "Installing Qmailadmin,Please waiting..."
sh /tmp/iceblood/Qmail_setup/iceblood/sleep.sh &
EID=$!
cd /tmp/iceblood/Qmail_setup
tar xzf qmailadmin-1.0.6.tar.gz
if [ "$_LANG" = "CN" ]; then
cp iceblood/en-us qmailadmin-1.0.6/html/en
cp iceblood/en-us qmailadmin-1.0.6/html/en-us
fi
cd qmailadmin-1.0.6
./configure --with-htmllibdir=/usr/local/qmail/qmailadmin --enable-qmaildir=/usr/local/qmail --enable-autoresponder-bin=/usr/local/qmail/bin --enable-ezmlmdir=/usr/local/qmail/bin/ezmlm --enable-cgibindir=$_CGIBIN --enable-htmldir=$_HTMLPATH >>/var/uninstall/qmailinstall.log 2>&1
make >>/var/uninstall/qmailinstall.log 2>&1
make install-strip >>/var/uninstall/qmailinstall.log 2>&1
kill $EID >/dev/null 2>&1
echo "QmailAdmin Install Done."
cd /tmp/iceblood/Qmail_setup
fi
if [ "$_WEBMAIL" = "YES" ]; then
echo "#########----------sqwebmail install--------#########" >>/var/uninstall/qmailinstall.log 2>&1
echo "Installing Sqwebmail,Please waiting..."
sh /tmp/iceblood/Qmail_setup/iceblood/sleep.sh &
EID=$!
cd /tmp/iceblood/Qmail_setup
mkdir -p /usr/local/qmail/webmail
tar xzf sqwebmail-3.3.7.20020910.tar.gz
cd sqwebmail-3.3.7.20020910
if [ "$_LANG" = "CN" ]; then
cp /tmp/iceblood/Qmail_setup/iceblood/sqwebmailcn/*.html sqwebmail/html/en-us
fi
if [ "$_WEBHTTPS" = "YES" ]; then
./configure --prefix=/usr/local/qmail/webmail --with-authvchkpw --enable-webpass=vpopmail --enable-cgibindir=$_CGIBIN --enable-imagedir=$_HTMLPATH/webmail --enable-mimetypes=$_HTMLPATH --enable-mimecharset=$_MIMESET --enable-https --enable-default-domain=$_DOMAIN >>/var/uninstall/qmailinstall.log 2>&1
else
./configure --prefix=/usr/local/qmail/webmail --with-authvchkpw --enable-webpass=vpopmail --enable-cgibindir=$_CGIBIN --enable-imagedir=$_HTMLPATH/webmail --enable-mimetypes=$_HTMLPATH --enable-mimecharset=$_MIMESET --enable-default-domain=$_DOMAIN >>/var/uninstall/qmailinstall.log 2>&1
fi
make configure-check >>/var/uninstall/qmailinstall.log 2>&1
make >>/var/uninstall/qmailinstall.log 2>&1
make check >>/var/uninstall/qmailinstall.log 2>&1
make install-strip >>/var/uninstall/qmailinstall.log 2>&1
make install-configure >>/var/uninstall/qmailinstall.log 2>&1
cp /tmp/iceblood/Qmail_setup/iceblood/*.gif $_HTMLPATH/webmail
echo "/usr/local/qmail/webmail/libexec/authlib/authdaemond start">>/etc/qmail/start
kill $EID >/dev/null 2>&1
echo "Sqwebmail Install Done."
fi
chmod 755 /etc/qmail/start
/etc/qmail/start
cp /tmp/iceblood/Qmail_setup/qmail /usr/sbin/qmail
chmod 755 /usr/sbin/qmail
echo '###############------------The End----------#################'
echo '# #'
echo '# qmailadmin URL is http://x.x.x.x/cgi-bin/qmailadmin #'
echo '# webmail URL is http://x.x.x.x/cgi-bin/sqwebmail #'
echo '# run /usr/sbin/qmail manage your qmail server. #'
echo '# #'
echo '# This script is written and maintained by iceblood, #'
echo '# can be distributed under iceblood license. #'
echo '# #'
echo '# Wellcom send E-mail to me.My E-mail:[email protected] #'
echo '# #'
echo '# Please run "/usr/sbin/qmail" commands. #'
echo '#############################################################'
cd /
echo "Deleting temp files......"
/usr/bin/perl /tmp/iceblood/Qmail_setup/iceblood/qmailcheck
rm -rf /tmp/iceblood |
|