#!/bin/sh
#
# Install QmailToaster packages
#
# *** USE AT YOUR OWN RISK ***
#
# do: rpm -qa | grep toaster | sort to be sure that all
# the packages installed correctly . . .
#
# Nick Hemmesch <nick@ndhsoft.com>
# June 5, 2005
#
# Updated wildcards by Erik Espinoza
# July 28, 2005
#


# Edit to add your distro switch, build directory and architecture

DISTRO=cnt40
ARCH=i386
BDIR=redhat

VQAD=`ls vqadmin-toaster-*.src.rpm|tail -n1`
VPOP=`ls vpopmail-toaster-*.src.rpm|tail -n1`
UCSP=`ls ucspi-tcp-toaster-*.src.rpm|tail -n1`
SQML=`ls squirrelmail-toaster-*.src.rpm|tail -n1`
SPAM=`ls spamassassin-toaster-*.src.rpm|tail -n1`
SIMS=`ls simscan-toaster-*.src.rpm|tail -n1`
MRTG=`ls qmailmrtg-toaster-*.src.rpm|tail -n1`
MDRP=`ls maildrop-toaster-*.src.rpm|tail -n1`
ADMN=`ls qmailadmin-toaster-*.src.rpm|tail -n1`
QMLT=`ls qmail-toaster-*.src.rpm|tail -n1`
ISOQ=`ls isoqlog-toaster-*.src.rpm|tail -n1`
EZML=`ls ezmlm-toaster-*.src.rpm|tail -n1`
DAEM=`ls daemontools-toaster-*.src.rpm|tail -n1`
IMAP=`ls courier-imap-toaster-*.src.rpm|tail -n1`
CPNL=`ls control-panel-toaster-*.src.rpm|tail -n1`
CLAM=`ls clamav-toaster-*.src.rpm|tail -n1`
AUTO=`ls autorespond-toaster-*.src.rpm|tail -n1`
ZLIB=`ls zlib-*.src.rpm|tail -n1`

rpmbuild --rebuild $ZLIB || { echo -e "\n\n*** ERROR\n";exit; }
rpm -Uvh --replacefiles --replacepkgs /usr/src/$BDIR/RPMS/$ARCH/zlib*.rpm || { echo -e "\n\n*** ERROR\n";exit; }

rpmbuild --rebuild --with $DISTRO $DAEM || { echo -e "\n\n*** ERROR\n";exit; }
rpm -Uvh --replacefiles --replacepkgs /usr/src/$BDIR/RPMS/$ARCH/daemontools-toaster*.rpm || { echo -e "\n\n*** ERROR\n";exit; }

rpmbuild --rebuild --with $DISTRO $UCSP || { echo -e "\n\n*** ERROR\n";exit; }
rpm -Uvh --replacefiles --replacepkgs /usr/src/$BDIR/RPMS/$ARCH/ucspi-tcp-toaster*.rpm || { echo -e "\n\n*** ERROR\n";exit; }

rpmbuild --rebuild --with $DISTRO $VPOP || { echo -e "\n\n*** ERROR\n";exit; }
rpm -Uvh --replacefiles --replacepkgs /usr/src/$BDIR/RPMS/$ARCH/vpopmail-toaster*.rpm || { echo -e "\n\n*** ERROR\n";exit; }

rpmbuild --rebuild --with $DISTRO $QMLT || { echo -e "\n\n*** ERROR\n";exit; }
rpm -Uvh --replacefiles --replacepkgs /usr/src/$BDIR/RPMS/$ARCH/qmail-toaster*.rpm || { echo -e "\n\n*** ERROR\n";exit; }
rpm -Uvh --replacefiles --replacepkgs /usr/src/$BDIR/RPMS/$ARCH/qmail-pop3d*.rpm || { echo -e "\n\n*** ERROR\n";exit; }

rpmbuild --rebuild --with $DISTRO $IMAP || { echo -e "\n\n*** ERROR\n";exit; }
rpm -Uvh --replacefiles --replacepkgs /usr/src/$BDIR/RPMS/$ARCH/courier-imap-toaster*.rpm || { echo -e "\n\n*** ERROR\n";exit; }

rpmbuild --rebuild --with $DISTRO $AUTO || { echo -e "\n\n*** ERROR\n";exit; }
rpm -Uvh --replacefiles --replacepkgs /usr/src/$BDIR/RPMS/$ARCH/autorespond-toaster*.rpm || { echo -e "\n\n*** ERROR\n";exit; }

rpmbuild --rebuild --with $DISTRO $CPNL || { echo -e "\n\n*** ERROR\n";exit; }
rpm -Uvh --replacefiles --replacepkgs /usr/src/$BDIR/RPMS/noarch/control-panel-toaster*.rpm || { echo -e "\n\n*** ERROR\n";exit; }

rpmbuild --rebuild --with $DISTRO $EZML || { echo -e "\n\n*** ERROR\n";exit; }
rpm -Uvh --replacefiles --replacepkgs /usr/src/$BDIR/RPMS/$ARCH/ezmlm*.rpm || { echo -e "\n\n*** ERROR\n";exit; }

rpmbuild --rebuild --with $DISTRO $ADMN || { echo -e "\n\n*** ERROR\n";exit; }
rpm -Uvh --replacefiles --replacepkgs /usr/src/$BDIR/RPMS/$ARCH/qmailadmin-toaster*.rpm || { echo -e "\n\n*** ERROR\n";exit; }

rpmbuild --rebuild --with $DISTRO $MRTG || { echo -e "\n\n*** ERROR\n";exit; }
rpm -Uvh --replacefiles --replacepkgs /usr/src/$BDIR/RPMS/$ARCH/qmailmrtg-toaster*.rpm || { echo -e "\n\n*** ERROR\n";exit; }

rpmbuild --rebuild --with $DISTRO $MDRP || { echo -e "\n\n*** ERROR\n";exit; }
rpm -Uvh --replacefiles --replacepkgs /usr/src/$BDIR/RPMS/$ARCH/maildrop-toaster*.rpm || { echo -e "\n\n*** ERROR\n";exit; }

rpmbuild --rebuild --with $DISTRO $ISOQ || { echo -e "\n\n*** ERROR\n";exit; }
rpm -Uvh --replacefiles --replacepkgs /usr/src/$BDIR/RPMS/$ARCH/isoqlog-toaster*.rpm || { echo -e "\n\n*** ERROR\n";exit; }

rpmbuild --rebuild --with $DISTRO $VQAD || { echo -e "\n\n*** ERROR\n";exit; }
rpm -Uvh --replacefiles --replacepkgs /usr/src/$BDIR/RPMS/$ARCH/vqadmin-toaster*.rpm || { echo -e "\n\n*** ERROR\n";exit; }

rpmbuild --rebuild --with $DISTRO $SQML || { echo -e "\n\n*** ERROR\n";exit; }
rpm -Uvh --replacefiles --replacepkgs /usr/src/$BDIR/RPMS/noarch/squirrelmail-toaster*.rpm || { echo -e "\n\n*** ERROR\n";exit; }

rpmbuild --rebuild --with $DISTRO $SPAM || { echo -e "\n\n*** ERROR\n";exit; }
rpm -Uvh --replacefiles --replacepkgs --nodeps /usr/src/$BDIR/RPMS/$ARCH/spamassassin-toaster*.rpm || { echo -e "\n\n*** ERROR\n";exit; }

rpmbuild --rebuild --with $DISTRO $CLAM || { echo -e "\n\n*** ERROR\n";exit; }
rpm -Uvh --replacefiles --replacepkgs /usr/src/$BDIR/RPMS/$ARCH/clamav-toaster*.rpm || { echo -e "\n\n*** ERROR\n";exit; }

rpmbuild --rebuild --with $DISTRO $SIMS || { echo -e "\n\n*** ERROR\n";exit; }
rpm -Uvh --replacefiles --replacepkgs /usr/src/$BDIR/RPMS/$ARCH/simscan-toaster*.rpm || { echo -e "\n\n*** ERROR\n";exit; }
