Life with qmail script

Publicado por Patrick Brandao 11/09/2004

[ Hits: 8.169 ]

Homepage: http://www.patrick.eti.br

Download lifewithqmail.sh




Instala servidor qmail de acordo com o tutorial Life with qmail, do site www.lifewithqmail.org, basta torna-lo executavel:

# chmod +x lifewithqmail.sh

e executa-lo:

# ./lifewithqmail.sh

Voce pode colocar uma copia de netqmail, ucspi-tcp, daemontools em /usr/local/src , caso contrario ele fará o download automaticamente.

Tempo para instalacao: 1minuto e 20 segundos em media.

Versao atualizada em: http://www.patrick.eti.br/downloads/lifewithqmail.sh

  



Esconder código-fonte

#!/bin/sh

# life with qmail script by patrick brandao - contato@patrick.eti.br - www.patrick.eti.br/qmail

# prepare
   mkdir -p /usr/local/src

# sis
   cd /usr/local/src

# download
   if [ ! -e netqmail-1.05.tar.gz ] ; then wget http://www.qmail.org/netqmail-1.05.tar.gz ; fi
   if [ ! -e ucspi-tcp-0.88.tar.gz ] ; then wget ftp://cr.yp.to/ucspi-tcp/ucspi-tcp-0.88.tar.gz ; fi
   if [ ! -e daemontools-0.76.tar.gz ] ; then wget ftp://cr.yp.to/daemontools/daemontools-0.76.tar.gz ; fi
exit 0
# prep packs
   umask 022
   mkdir -p /package
   mv daemontools-0.76.tar.gz /package
   chmod 1755 /package

# sis
   cd /usr/local/src

# prep netqmail
   tar xvzf netqmail-1.05.tar.gz
   cd netqmail-1.05
   ./collate.sh  # watch for errors here
   cd ..

# prep ucspi-tcp
   tar xvzf ucspi-tcp-0.88.tar.gz
   cd /package
   
# prep daemontools
   tar xvzf daemontools-0.76.tar.gz

# /var/qmail
   mkdir -p /var/qmail


# /etc/qmail
   if ! test -e /etc/qmail ; then
       mkdir -p /etc/qmail
       ln -s /etc/qmail /var/qmail/control
   else
       echo 'INFO: /etc/qmail existe'
   fi
# users qmail
   groupadd nofiles
   useradd qmaild -g nofiles -d /var/qmail -s /nonexistent
   useradd alias -g nofiles -d /var/qmail/alias -s /nonexistent
   useradd qmaill -g nofiles -d /var/qmail -s /nonexistent
   useradd qmailp -g nofiles -d /var/qmail -s /nonexistent
   groupadd qmail
   useradd qmailq -g qmail -d /var/qmail -s /nonexistent
   useradd qmailr -g qmail -d /var/qmail -s /nonexistent
   useradd qmails -g qmail -d /var/qmail -s /nonexistent

# sis
    cd /usr/local/src/netqmail-1.05/netqmail-1.05


# make qmail
   make setup check

# config host
   host=`head -1 /etc/HOSTNAME`
   ./config-fast $host

# install ucspi-tcp
    cd /usr/local/src/ucspi-tcp-0.88
    patch < /usr/local/src/netqmail-1.05/other-patches/ucspi-tcp-0.88.errno.patch
    make
    make setup check

# Install daemontools
    cd /package/admin/daemontools-0.76
    cd src
    patch < /usr/local/src/netqmail-1.05/other-patches/daemontools-0.76.errno.patch
    cd ..
    package/install


#-------------------------------------- scripts
# /var/qmail/rc ------------------------------------------
cat > /var/qmail/rc << EOF
#!/bin/sh

# Using stdout for logging
# Using control/defaultdelivery from qmail-local to deliver messages by default

exec env - PATH="/var/qmail/bin:\$PATH" \
qmail-start "\`cat /var/qmail/control/defaultdelivery\`"
EOF
   chmod 755 /var/qmail/rc

# qmailctl --------------------------------------------------
   wget http://www.lifewithqmail.org/qmailctl-script-dt70
   mv qmailctl-script-dt70 /var/qmail/bin/qmailctl
   chmod 755 /var/qmail/bin/qmailctl
   ln -s /var/qmail/bin/qmailctl /usr/bin


# supervise scripts

   mkdir -p /var/qmail/supervise/qmail-send/log
   mkdir -p /var/qmail/supervise/qmail-smtpd/log
   mkdir -p /var/qmail/supervise/qmail-pop3d/log

# qmail-send ------------------------------------------------
cat > /var/qmail/supervise/qmail-send/run << EOF
#!/bin/sh
exec /var/qmail/rc
EOF
cat > /var/qmail/supervise/qmail-send/log/run << EOF
#!/bin/sh
exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t /var/log/qmail
EOF

# qmail-smtpd -----------------------------------------------

cat > /var/qmail/supervise/qmail-smtpd/run << EOF
#!/bin/sh

QMAILDUID=\`id -u qmaild\`
NOFILESGID=\`id -g qmaild\`
MAXSMTPD=\`cat /var/qmail/control/concurrencyincoming\`
LOCAL=\`head -1 /var/qmail/control/me\`

if [ -z "\$QMAILDUID" -o -z "\$NOFILESGID" -o -z "\$MAXSMTPD" -o -z "\$LOCAL" ]; then
    echo QMAILDUID, NOFILESGID, MAXSMTPD, or LOCAL is unset in
    echo /var/qmail/supervise/qmail-smtpd/run
    exit 1
fi

if [ ! -f /var/qmail/control/rcpthosts ]; then
    echo "No /var/qmail/control/rcpthosts!"
    echo "Refusing to start SMTP listener because it'll create an open relay"
    exit 1
fi

exec /usr/local/bin/softlimit -m 2000000 \\
    /usr/local/bin/tcpserver -v -R -l "\$LOCAL" -x /etc/tcp.smtp.cdb -c "\$MAXSMTPD" \\
        -u "\$QMAILDUID" -g "\$NOFILESGID" 0 smtp /var/qmail/bin/qmail-smtpd 2>&1
EOF

cat > /var/qmail/supervise/qmail-smtpd/log/run << EOF
#!/bin/sh
exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t /var/log/qmail/smtpd
EOF

# qmail-pop3d -----------------------------------------------

cat > /var/qmail/supervise/qmail-pop3d/run << EOF
#!/bin/sh
FQDN=\`head -1 /etc/HOSTNAME\`
SOFTLIMIT=2000000
exec /usr/local/bin/softlimit -m \$SOFTLIMIT \\
    /usr/local/bin/tcpserver -v -R -H -l 0 0 110 /var/qmail/bin/qmail-popup \\
   \$FQDN /bin/checkpassword /var/qmail/bin/qmail-pop3d Maildir 2>&1

# to use vpopmail, auth /vpopmailbindir/vchkpw
# include qmail-pop3d link in /service and start/stop command in qmailctl script
EOF

cat > /var/qmail/supervise/qmail-pop3d/log/run << EOF
#!/bin/sh
exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t /var/log/qmail/pop3d
EOF


# to execute
   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-pop4d/log/run

# log -------------------------------------------------------
   mkdir -p /var/log/qmail/smtpd
   mkdir -p /var/log/qmail/pop3d
   chown qmaill /var/log/qmail -R


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


# update cdb
   qmailctl stop
   echo '127.:allow,RELAYCLIENT=""' >>/etc/tcp.smtp
   qmailctl cdb

# kill sendmail
   mv /usr/lib/sendmail /usr/lib/sendmail.old           2>/dev/null # ignore errors
   mv /usr/bin/sendmail /usr/sbin/sendmail.old          2>/dev/null # ignore errors
   mv /usr/sbin/sendmail /usr/sbin/sendmail.old         2>/dev/null # ignore errors
   chmod 0 /usr/lib/sendmail.old /usr/sbin/sendmail.old 2>/dev/null # ignore errors
   ln -s /var/qmail/bin/sendmail /usr/lib
   ln -s /var/qmail/bin/sendmail /usr/sbin

# postamaster mail
   echo postmaster > /var/qmail/alias/.qmail-root
   echo postmaster > /var/qmail/alias/.qmail-postmaster
   ln -s .qmail-postmaster /var/qmail/alias/.qmail-mailer-daemon
   chmod 644 /var/qmail/alias/.qmail-root /var/qmail/alias/.qmail-postmaster


# configure qmail default
   echo 20 > /var/qmail/control/concurrencyincoming
   echo 1200 > timeoutsmtpd
   echo 1200 > timeoutremote
   echo 60 > timeoutconnect
   echo 20 > concurrencyremote
   echo 10 > concurrencylocal
   echo "quick mail at `cat /etc/HOSTNAME`" > smtpgreeting
   echo 604800 > queuelifetime
   echo './Maildir/' >/var/qmail/control/defaultdelivery
   chmod 644 /var/qmail/control/*

# test instalation
   wget http://lifewithqmail.org/inst_check
   mv inst_check /var/qmail/bin
   chmod +x /var/qmail/bin/inst_check
   result=`/var/qmail/bin/inst_check 2>&1`
   printf "\7"
   dialog --title "Instalador qmail de Patrick Brandao" --cr-wrap --infobox "Resultado:\n\n$result" 7 50



Scripts recomendados

POSTFIX AUTOMÁTICO COM MYSQL E IPTABLES - APAGANDO MSG ANTIGAS EM TODAS AS PASTAS DE UM USUÁRIO

Instalando docker

Firewall Pessoal (iptables)

Loadbalance

Instalação do Cisco Packettracer 7.2 no Debian 10


  

Comentários

Nenhum comentário foi encontrado.


Contribuir com comentário




Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts