Instalare rapida server qmail/vpopmail debian bazat pe bill`s toaster

apt-get update
apt-get install nano mc links
apt-get install mysql-server
apt-get install phpmyadmin


apt-get install libgdbm-dev gcc g++ patch make libc-dev stunnel libssl-dev  wget bzip2 autoconf rpm

mkdir /var/lock/subsys

apt-get install libdigest-sha1-perl libnet-dns-perl \
libgeo-ipfree-perl razor pyzor libnet-ident-perl \
libio-socket-ssl-perl libarchive-tar-perl libio-zlib-perl \
libsys-hostname-long-perl libhtml-parser-perl

apt-get install mrtg clamav

mv /etc/cron.d/mrtg /root/mrtg

umask 0022
mkdir -p /usr/src/mail/tar
cd /usr/src/mail/tar

# stunnel -- openSuSE from 11.1 on needs to have stunnel added
#wget http://www.rickwidmer.com/software/stunnel-4.33.tar.gz

# qmail
wget http://www.rickwidmer.com/software/netqmail-1.06.tar.gz
wget http://www.rickwidmer.com/software/toaster-scripts-0.9.2.tar.gz
wget http://www.rickwidmer.com/software/libdomainkeys-0.69.tar.gz
wget http://www.rickwidmer.com/patches/libdomainkeys-0.69.diff

# ucspi-tcp
wget http://cr.yp.to/ucspi-tcp/ucspi-tcp-0.88.tar.gz
# If needed, get the 64 bit patch for ucspi-tcp
wget http://www.rickwidmer.com/patches/ucspi-tcp-64bit.patch

# 
wget http://cr.yp.to/daemontools/daemontools-0.76.tar.gz
wget http://dist.schmorp.de/libev/Attic/libev-3.53.tar.gz

# vpopmail
wget http://www.rickwidmer.com/software/vpopmail-5.4.32.tar.gz
wget http://www.rickwidmer.com/patches/qmail-toaster-0.9.2.patch.bz2
wget http://www.rickwidmer.com/patches/submission-0.9.2.patch

# Courier
wget http://www.rickwidmer.com/software/courier-imap-4.1.2.tar.bz2
wget http://www.rickwidmer.com/software/courier-authlib-0.59.1.tar.bz2
wget http://www.rickwidmer.com/patches/vpopmail_courier_cram-1.diff

# squirrelmail
wget http://www.rickwidmer.com/software/squirrelmail-1.4.21.tar.gz
wget http://www.rickwidmer.com/software/quota_usage-1.3.1-1.2.7.tar.gz

# autorespond
wget http://www.rickwidmer.com/software/autorespond-2.0.4.tar.gz
wget http://www.rickwidmer.com/patches/autorespond-2.0.4-2.0.5.patch

# ezmlm
wget http://cr.yp.to/software/ezmlm-0.53.tar.gz
wget http://www.rickwidmer.com/software/ezmlm-idx-0.443.tar.gz

# qmailadmin
wget http://www.rickwidmer.com/software/qmailadmin-1.2.13.tar.gz
wget http://www.rickwidmer.com/software/qmailadmin-help-1.0.8.tar.gz

# qmailmrtg
wget http://www.rickwidmer.com/software/qmailmrtg7-4.2.tar.gz
wget http://www.rickwidmer.com/patches/qmailmrtg7-4.2-cfg.patch

# qmail
groupadd -g 91 nofiles
useradd -u 91 -g nofiles -d /var/qmail/alias alias
useradd -u 92 -g nofiles -d /var/qmail qmaild
useradd -u 93 -g nofiles -d /var/qmail qmaill
useradd -u 94 -g nofiles -d /var/qmail qmailp
groupadd -g 92 qmail
useradd -u 95 -g qmail -d /var/qmail qmailq
useradd -u 96 -g qmail -d /var/qmail qmailr
useradd -u 97 -g qmail -d /var/qmail qmails

# vpopmail
groupadd -g 88 vchkpw
useradd -u 88 -g vchkpw vpopmail


# Create the destination directory
mkdir /var/qmail

cd /usr/src/mail
tar -xzf tar/netqmail-1.06.tar.gz
cd /usr/src/mail/netqmail-1.06
make
make setup check

cd /usr/src/mail
tar -xzf tar/libdomainkeys-0.69.tar.gz
cd libdomainkeys-0.69
patch -p0 < ../tar/libdomainkeys-0.69.diff
make

mkdir -p /package
chmod 1755 /package
cd /package
tar -xpzf /usr/src/mail/tar/daemontools-0.76.tar.gz
cd admin/daemontools-0.76
patch -p1 < /usr/src/mail/netqmail-1.06/other-patches/daemontools-0.76.errno.patch
package/install

####
cd /package/admin
mkdir clear
touch clear/down

cat > clear/run < /var/qmail/control/spfbehavior

# Setup the primary administrator's email address.
# This address will receive mail for root, postmaster, and mailer-daemon.
(cd ~alias; \
echo "postmaster@mmd12.multimediadesign.ro" > .qmail-postmaster ;\
echo "postmaster@mmd12.multimediadesign.ro" > .qmail-mailer-daemon ;\
echo "postmaster@mmd12.multimediadesign.ro" > .qmail-root )
chmod 644 ~alias/.qmail*

cd /usr/src/mail/netqmail-1.06
./config-fast mmd12.multimediadesign.ro

cd /usr/src/mail
cp toaster-scripts-0.9.2/rc /var/qmail/rc
chmod 755 /var/qmail/rc
mkdir /var/log/qmail
echo ./Maildir/ >/var/qmail/control/defaultdelivery
cp toaster-scripts-0.9.2/qmailctl /var/qmail/bin/
chmod 755 /var/qmail/bin/qmailctl
ln -s /var/qmail/bin/qmailctl /usr/bin
ln -s -f /var/qmail/bin/sendmail /usr/sbin/sendmail
ln -s -f /var/qmail/bin/sendmail /usr/lib/sendmail

# Now create the supervise directories/scripts for the qmail services:
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 /usr/src/mail/toaster-scripts-0.9.2/send.run /var/qmail/supervise/qmail-send/run
cp /usr/src/mail/toaster-scripts-0.9.2/send.log.run /var/qmail/supervise/qmail-send/log/run
cp /usr/src/mail/toaster-scripts-0.9.2/smtpd.run /var/qmail/supervise/qmail-smtpd/run
cp /usr/src/mail/toaster-scripts-0.9.2/smtpd.log.run /var/qmail/supervise/qmail-smtpd/log/run
cp /usr/src/mail/toaster-scripts-0.9.2/pop3d.run /var/qmail/supervise/qmail-pop3d/run
cp /usr/src/mail/toaster-scripts-0.9.2/pop3d.log.run /var/qmail/supervise/qmail-pop3d/log/run

cp /usr/src/mail/toaster-scripts-0.9.2/stunnel.conf /var/qmail/supervise/qmail-pop3ds/
cp /usr/src/mail/toaster-scripts-0.9.2/pop3ds.run /var/qmail/supervise/qmail-pop3ds/run
cp /usr/src/mail/toaster-scripts-0.9.2/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

mcedit /var/qmail/supervise/qmail-send/log/run
#pune /qmail/qmail-send la folder log

# allow daemontools to start qmail
ln -s /var/qmail/supervise/qmail-send /var/qmail/supervise/qmail-smtpd /service

# verify that it's running with qmailctl
sleep 5
qmailctl stat

#### maildrop
wget http://mesh.dl.sourceforge.net/sourceforge/courier/maildrop-2.0.4.tar.bz2
 tar -jxvf maildrop-2.0.4.tar.bz2
 cd maildrop-2.0.4/
 ./configure
 make
 make install
 cd ..

#### qmail-scanner
./configure --qs-user qscand --admin postmaster \
--domain ultramarintm.ro --admin-description "Mail admin" --notify recips \
--local-domains  "`cat /var/qmail/control/rcpthosts | tr "\n" ","`" \
--silent-viruses auto --virus-to-delete 0 --skip-text-msgs 1 \
--lang en_GB --debug 1 --add-dscr-hdrs yes --dscr-hdrs-text "X-Antivirus-UM" \
--normalize yes --archive 0 --settings-per-domain 1 \
--max-scan-size 100000000 --unzip 0 --max-zip-size 1000000000 --max-unpacked-files 10000 \
--redundant 1 --log-details syslog --log-crypto 0 --fix-mime 2 \
--ignore-eol-check 1 --sa-timeout 120 --sa-delta 0 --sa-alt 0 --sa-debug 0 \
--sa-report 0 --sa-quarantine 0 --sa-delete 5 --sa-reject 0 \
--scanners "clamdscan,verbose_spamassassin" --install 1
####Vpopmail
mysql -u root -p

#create database vpopmail;
#grant update, create, delete, insert, select on vpopmail.* to vpopmail_edit@localhost identified by "mirmugmmd12";
#mysql -h localhost -u vpopmail_edit -pmirmugmmd12 vpopmail 


cd /usr/src/mail
tar -xzf tar/vpopmail-5.4.32.tar.gz
cd vpopmail-5.4.32

cd /usr/src/mail
tar -xzf tar/vpopmail-5.4.32.tar.gz
cd vpopmail-5.4.32

./configure --enable-logging=v \

make
make install-strip

echo "localhost|0|vpopmail_edit|mirmugmmd12|vpopmail" > ~vpopmail/etc/vpopmail.mysql

chown vpopmail.vchkpw ~vpopmail/etc/vpopmail.mysql
chmod 640 ~vpopmail/etc/vpopmail.mysql
apt-get install libmysqlclient-dev     
#apt-get install zlib1g-de
make clean
echo '127.:allow,RELAYCLIENT=""' > ~vpopmail/etc/tcp.smtp
./configure --enable-roaming-users=y --enable-logging=y --enable-ip-alias-domains=y --enable-auth-module=mysql --enable-clear-passwd=n --enable-libdir=/usr/include/mysql/ --enable-tcpserver-path=/home/vpopmail/etc/ --enable-tcpserver-file=/home/vpopmail/etc/tcp.smtp --enable-qmail-ext --enable-logging=e --enable-tcprules-prog=/usr/local/bin/tcprules --enable-rebuild-tcpserver-file
make
make install-strip

###
cd /usr/src/mail
tar -xzf tar/libev-3.53.tar.gz
cd libev-3.53
./configure
make
make install

cd /usr/src/mail/vpopmail-5.4.32/vusaged
make
cp -f vusaged /home/vpopmail/bin/
cp -f etc/vusaged.conf /home/vpopmail/etc/
cd ../

echo '127.:allow,RELAYCLIENT=""' > ~vpopmail/etc/tcp.submission
/usr/bin/qmailctl cdb

# install the vpopmail start script
cp ../toaster-scripts-0.9.2/vpopmailctl /var/qmail/bin/vpopmailctl

chmod 755 /var/qmail/bin/vpopmailctl
ln -s /var/qmail/bin/vpopmailctl /usr/bin

# install the vusaged start script
cp vusaged/contrib/rc.vusaged /etc/init.d/vusaged
chmod 755 /etc/init.d/vusaged
mv /etc/init.d/vusaged /root/vusaged


cd /usr/src/mail/netqmail-1.06
bunzip2 -c ../tar/qmail-toaster-0.9.2.patch.bz2 | patch -p0
make clean
make

qmailctl stop
make setup check

# NOTE: the following command needs to be run after any future re-installs of qmail as it will chown this directory back to qmail

chown -R vpopmail:vchkpw /var/qmail/spam

####
# This may look a little messy on the screen, but it works...
make cert <<eof romania="" timis="" timisoara="" mmd="" email="" server="" mmd12.multimediadesign.ro="" postmaster@mmd12.multimediadesign.ro="" eof="" make="" tmprsadh="" #="" note:="" this="" may="" take="" a="" long="" time="" start="" qmail="" back="" up="" qmailctl="" allow="" daemontools="" to="" vpopmail="" ln="" -s="" var="" supervise="" qmail-pop3d="" qmail-pop3ds="" service="" verify="" that="" it's="" running="" with="" vpopmailctl="" sleep="" 5="" stat="" crontab="" -e="" #01="" 01="" *="" bin="" update_tmprsadh=""> /dev/null 2>&1

####SquirrelMail
cd /usr/src/mail
tar -xzf tar/squirrelmail-1.4.21.tar.gz
cd squirrelmail-1.4.21
cd plugins
tar -xzf ../../tar/quota_usage-1.3.1-1.2.7.tar.gz
cp quota_usage/config.php.sample quota_usage/config.php
cd ../
./configure

#go to Set pre-defined settings for specific IMAP servers (D), Select courier.
#From the main menu, go to General Options (4) and change:
#
#    Data Direcotry (1) to "/etc/apache2/squirrelmail-data/"
#    Attachment Directory (2) to "/etc/apache2/squirrelmail-attach"
#    Allow server thread sort (10) to y
#    Allow server-side sorting (11) to y.
#
#From the main menu, go to Plugins and enable the quota_usage plugin, along with any others you prefer
#Save settings
#quit
#   

# move the data directory into place and change permissions to the user:group that the web server runs as:
mv data /etc/apache2/squirrelmail-data                                                                    ####
chown -R www-data:www-data /etc/apache2/squirrelmail-data                                                 
                                                                                                          
# Create the directory for attachments.                                                                   
mkdir /etc/apache2/squirrelmail-attach                                                                    
chmod 733 /etc/apache2/squirrelmail-attach                                                                
chgrp www-data /etc/apache2/squirrelmail-attach                                                           
                                                                                                          ####                                                                                                       
# install squirrelmail                                                                                    
cd ../                                                                                                    
mv squirrelmail-1.4.21 /var/www/squirrelmail                                                              ####

####autorespond
cd /usr/src/mail
tar -xzf tar/autorespond-2.0.4.tar.gz
cd autorespond-2.0.4
patch -p1 < ../tar/autorespond-2.0.4-2.0.5.patch
make
make install

####ezmlm-idx
cd /usr/src/mail
tar -xzf tar/ezmlm-0.53.tar.gz
tar -xzf tar/ezmlm-idx-0.443.tar.gz
mv ezmlm-idx-0.443/* ezmlm-0.53/
cd ezmlm-0.53
patch -p0 < idx.patch
make
make setup

####QmailAdmin
####
cd /usr/src/mail/tar
links http://sourceforge.net/projects/qmailadmin/files/qmailadmin-stable/1.2.15/qmailadmin-1.2.15.tar.gz/download
cd /usr/src/mail
tar -xzf tar/qmailadmin-1.2.15.tar.gz
cd qmailadmin-1.2.15
./configure --enable-help \
--enable-domain-autofill \
--enable-htmldir=/var/www \
--enable-cgibindir=/usr/lib/cgi-bin \

make
make install-strip

cd /usr/src/mail
tar -xzf tar/qmailadmin-help-1.0.8.tar.gz
cd qmailadmin-help-1.0.8
mkdir /var/www/images/qmailadmin/help
cp -rp * /var/www/images/qmailadmin/help


####Test Drive
# Add the domain to vpopmail
/home/vpopmail/bin/vadddomain s17.linuxist.ro fSiY94vt77
/home/vpopmail/bin/vadduser -q 6MB mir@s17.linuxist.ro fSiY94vt77
/home/vpopmail/bin/vuserinfo mir@s17.linuxist.ro

mcedit /var/qmail/supervise/qmail-smtpd/run
#port 1025