#!/bin/sh # (c) Nico Schottelius 2003 # Last Modified: So Okt 2 17:07:44 CEST 2005 # install qmail # - now with netqmail patch # - tls/ssl # - "errno patch" # ##export DIETLIBC_HOME=/usr/packages/dietlibc QMAIL_HOME=/usr/packages/qmail-1.03-ssl UCSPI_TCP_HOME=/usr/packages/ucspi-tcp-0.88 TMP=/tmp/qmail-build # where to build, download WGET="wget -c" # qmail export HOSTNAME=creme.schottelius.org export POSTMASTER=nico-root@creme.schottelius.org export RELAYHOSTS="213.146.113.242" set -e # exit on error mkdir -p "${TMP}"; cd "${TMP}" ##echo "========= installing dietlibc =============" ##echo retrieving dietlibc.. ##cvs -d :pserver:cvs@cvs.fefe.de:/cvs -z9 co dietlibc ##cd dietlibc ##make prefix=${DIETLIBC_HOME} ##make prefix=${DIETLIBC_HOME} install ##ln -fs ${DIETLIBC_HOME}/bin/diet /usr/bin ##cd .. echo "========= installing qmail =============" # cleanup, double patching is bad! rm -rf qmail-1.03 echo retrieving qmail.. $WGET ftp://ftp.jp.qmail.org/qmail/qmail-1.03.tar.gz echo unpacking... tar xfz qmail-1.03.tar.gz echo retrieving netqmail-patch.. NETQMAILPATCH=qmail-1.03-netqmail-1.05-fefe3.diff.bz2 $WGET http://www.fefe.de/qmail/$NETQMAILPATCH echo patching... cd qmail-1.03 bunzip2 -c ../$NETQMAILPATCH | patch -p1 echo '#include ' > TMPFILE cat qmail-smtpd.c >> TMPFILE mv TMPFILE qmail-smtpd.c echo setting up dir... mkdir -p "$QMAIL_HOME" echo install qmail users/groups.. # may already exist set +e groupadd nofiles useradd -g nofiles -d $QMAIL_HOME/alias alias useradd -g nofiles -d $QMAIL_HOME qmaild useradd -g nofiles -d $QMAIL_HOME qmaill useradd -g nofiles -d $QMAIL_HOME qmailp groupadd qmail useradd -g qmail -d $QMAIL_HOME qmailq useradd -g qmail -d $QMAIL_HOME qmailr useradd -g qmail -d $QMAIL_HOME qmails set -e echo preparing qmail.. ##echo 'diet -Os gcc -O2 -I/usr/include/openssl' > conf-cc echo 'gcc -O2 -I/usr/include/openssl -include /usr/include/errno.h' > conf-cc echo 'gcc -s' > conf-ld echo "$QMAIL_HOME" > conf-qmail echo building qmail.. make setup check echo configuring qmail.. ./config-fast $HOSTNAME echo "&$POSTMASTER" > ~alias/.qmail-postmaster echo "&$POSTMASTER" > ~alias/.qmail-root echo "&$POSTMASTER" > ~alias/.qmail-mailer-daemon chmod 644 ~alias/.qmail* echo "PATH=\"$QMAIL_HOME/bin:\$PATH\" qmail-start ./Maildir/ splogger qmail &" > $QMAIL_HOME/rc chmod 750 $QMAIL_HOME/rc echo creating defaults for new users.. for dir in tmp cur new; do mkdir -p /etc/skel/Maildir/$dir done echo "./Maildir/" > /etc/skel/.qmail echo done with qmail...now setting up ucspi-tcp cd .. # ucspi echo "========= installing ucspi-tcp =============" echo retrieving ucspi-tcp.. $WGET http://cr.yp.to/ucspi-tcp/ucspi-tcp-0.88.tar.gz echo unpacking ucspi-tcp.. tar xfz ucspi-tcp-0.88.tar.gz echo building ucspi-tcp.. cd ucspi-tcp-0.88 echo "$UCSPI_TCP_HOME" > conf-home echo 'gcc -O2 -include /usr/include/errno.h' > conf-cc make setup check for bin in $UCSPI_TCP_HOME/bin/*; do ln -sf "$UCSPI_TCP_HOME/bin/$bin" /usr/bin done echo configurinc ucspi-tcp.. for hosts in $RELAYHOSTS; do echo "$hosts:allow,RELAYCLIENT=\"\"" >> /etc/tcp.smtp done tcprules /etc/tcp.smtp.cdb /etc/tcp.smtp.tmp < /etc/tcp.smtp # init script # header cat << EOF > /etc/init.d/qmail # # qmail init: autogenerated by install-qmail by Nico Schottelius # EOF echo MAILHOST="$HOSTNAME" >> /etc/init.d/qmail echo "QMAILD=`cat /etc/passwd|grep qmaild | awk -F':' '{ print $3 }'`" >> /etc/init.d/qmail echo "NOFILES=`cat /etc/group|grep nofiles | awk -F':' '{ print $3 }'`" >> /etc/init.d/qmail cat << EOF >> /etc/init.d/qmail case "\$1" in start) # ferne tcpserver -x /etc/tcp.smtp.cdb -v -u \$QMAILD -g \$NOFILES 0 smtp $QMAIL_HOME/bin/qmail-smtpd 2>&1 | $QMAIL_HOME/bin/splogger smtpd 3 & # lokal $QMAIL_HOME/rc # pop3 tcpserver 0 110 $QMAIL_HOME/bin/qmail-popup \$MAILHOST /bin/checkpassword $QMAIL_HOME/bin/qmail-pop3d Maildir & ;; stop) killall qmail-send tcpserver ;; esac EOF chmod 750 /etc/init.d/qmail echo "Installation done."