-------- Original Message --------
Subject: [qmailtoaster] QMT-CentOS6-12010.07.sh
Date: Tue, 04 Dec 2012 18:09:17 -0500
From: Dan McAllister <q...@it4soho.com>
Reply-To: qmailtoaster-list@qmailtoaster.com
To: qmailtoaster-list@qmailtoaster.com
Greetings all...
I've received a few requests lately from people wanting the latest
QMT-CentOS6 script... the latest of which is attached (with the file
extension changed to avoid being blocked by spam/av filters).
Save the file, remove the .TXT from the name and run it as a bash script
(as root: "*bash QMT-CentOS6-12.10.28.sh*")
Please provide feedback as to how well it works for you!
Thanks
Dan McAllister
--
IT4SOHO, LLC
PO Box 507
St. Petersburg, FL 33731-0507
CALL TOLL FREE:
877-IT4SOHO
We have support plans for QMail!
#!/bin/bash
# Version 2012-10-27 - Re-added EPEL & RPMforge for SpamAssassin support
# Version 2012-07-24 - ClamAV 0.97.5 has been fixed -- stop blocking updates
# Version 2012-07-11 - Switch source back to .com (.net is expired domain)
# Version 2012-02-03 - Update & cleanup for publication to QMT Community
# Move QTP install to near-end to remove yum-clean error messages
# Update source of current.txt to qmailtoaster.com (vs. org)
# Update source of packages to mirror list (mirrors.qmailtoaster.net vs com)
# Force workaround of ClamAV 0.97.3 -- it has a bad patch, use 0.97.2 instead
# -- Dan McAllister (IT4SOHO) d...@it4soho.com or +1-727-647-7646
# Version 2011-10-30 - New Build for CentOS 6
# -- Dan McAllister (IT4SOHO) d...@it4soho.com or +1-727-647-7646
#
# Check options --
# -t or -v turns on VERBOSE (shows yum output)
# -a or -d turns on DEBUG (which implies VERBOSE) and forces a re-install
# of ALL QMAIL-TOASTER packages
#
VERSION=2012.10.27
PACKAGES="
vpopmail-toaster vqadmin-toaster ucspi-tcp-toaster \
libsrs2-toaster libdomainkeys-toaster \
qmail-toaster squirrelmail-toaster spamassassin-toaster \
ripmime-toaster clamav-toaster simscan-toaster \
qmailmrtg-toaster ezmlm-toaster autorespond-toaster \
qmailadmin-toaster courier-authlib-toaster courier-imap-toaster \
maildrop-toaster control-panel-toaster isoqlog-toaster \
daemontools-toaster \
"
QMTSOURCE="http://mirrors.qmailtoaster.com/current/SRPMS"
REMOVE_FIRST=""
SKIP_LIST=""
DEPENDENCIES="
rpm-build wget openssh openssh-clients \
elfutils elfutils-libs file gdb libedit patch pkgconfig \
unzip xz xz-lzma-compat \
httpd httpd-tools httpd-manual crypto-utils mod_perl mod_ssl webalizer \
apr apr-util apr-util-ldap fontconfig freetype gd libX11 \
libX11-common libXau libXpm libjpeg libpng libxcb mailcap \
mysql mysql-devel mysql-server mysql-libs \
perl perl-ExtUtils-MakeMaker perl-TimeDate perl-NetAddr-IP perl-Error \
perl-Font-AFM perl-BSD-Resource perl-Newt perl-Digest-SHA1 \
perl-HTML-Parser perl-Net-DNS perl-Archive-Tar perl-IO-Zlib \
perl-Time-HiRes perl-Digest-SHA perl-IO-Socket-INET6 \
perl-IO-Socket-SSL perl-Mail-DKIM perl-Encode-Detect \
php php-common php-cli php-imap php-ldap php-pear \
gcc gcc-c++ gcc-java compat-gcc-34 compat-gcc-34-c++ make automake* \
alsa-lib atk autoconf avahi-libs cairo cloog-ppl cpp cups-libs \
ecj glibc-devel glibc-headers gnutls gtk2 hicolor-icon-theme \
jasper-libs java-1.5.0-gcj java_cup jpackage-utils \
kernel-headers libICE libSM libXcomposite libXcursor \
libXdamage libXext libXfixes libXft libXi libXinerama \
libXrandr libXrender libXtst libart_lgpl libgcj libgcj-devel \
libgomp libstdc++-devel libtasn1 libthai libtiff mpfr \
pango pixman ppl sinjdoc zip zlib-devel \
bzip2-devel bzip2-libs gmp-devel curl libcurl curl-devel \
libidn-devel ncurses-devel aspell procmail mrtg \
libtool libtool-ltdl libtool-ltdl-devel gdbm-devel expect tcl \
pcre pcre-devel \
"
PERLDEPSRPMFORGE="perl-IP-Country perl-DateTime-Format-HTTP \
\
"
PERLDEPSEPEL="perl-Mail-SPF razor-agents perl-Razor-Agent "
VERBOSE=-q
DEBUG=
MYSQLPW='IamQMail'
#
COL60="\\033[60G"
NORMAL="\\033[0;39m"
WHITE="\\033[1;39m"
GREEN="\\033[1;32m"
RED="\\033[1;31m"
YELLOW="\\033[1;33m"
BLUE="\\033[1;34m"
SHOWDWNLOAD="echo -en ${COL60}${BLUE}Downloading${NORMAL}"
SHOWREBUILD="echo -en ${COL60}${BLUE}Building...${NORMAL}"
SHOWINSTALL="echo -en ${COL60}${BLUE}Installing.${NORMAL}"
SHOWSKIP="echo -en ${COL60} ${WHITE}[${YELLOW} SKIP ${WHITE}] ${NORMAL} \n"
SHOWOK="echo -en ${COL60} ${WHITE}[${GREEN} -OK- ${WHITE}] ${NORMAL} \n"
SHOWDONE="echo -en ${COL60} ${WHITE}[${GREEN} DONE ${WHITE}] ${NORMAL} \n"
SHOWFAIL="echo -en ${COL60} ${WHITE}[${RED}FAILED${WHITE}] ${NORMAL} \n"
#
# You must run this script as root!
if [ "`id -u`" -ne "0" ] ; then
echo "$0: OOPS! You must be running this script as root..." 1>&2
echo " Try running: sudo $0" 1>&2
exit 1
fi
#
# Ensure OS is right
#
# Make sure we're in the right place
if ! grep ' 6\.' /etc/redhat-release > /dev/null 2>&1 ; then
echo "$0: OOPS! This script is for RHEL/CentOS 6, but this is `cat
/etc/redhat-release`" 1>&2
exit 2
fi
#
# Ensure architecture is right
#
# NOTE: Build RPMs have to be told that this is CNT5 because they don't
# know what to do with CNT6 yet -- this will be fixed in the future.
ARCH=`/bin/arch`
BDIR=redhat
if [ ${ARCH} == "x86_64" ] ; then
DISTRO=cnt5064
EXCLUDE="*.i386 *.i586 *.i686"
elif [ ${ARCH} == "i686" ] ; then
DISTRO=cnt50
EXCLUDE=""
elif [ ${ARCH} == "i386" ] ; then
DISTRO=cnt50
EXCLUDE=""
ARCH=i686
else
echo "$0: OOPS! This script is for RHEL/CentOS 6 on the 64-bit architecture
ONLY" 1>&2
exit 3
fi
#
# Process options
#
for OPT in $* ; do
if [ "$OPT" == "-t" ] || [ "$OPT" == "-v" ] ; then
VERBOSE=""
elif [ "$OPT" == "-a" ] || [ "$OPT" == "-d" ] ; then
VERBOSE=""
DEBUG=y
fi
done
#
TODAY=`/bin/date +%Y%m%d`
mkdir -p update-${TODAY}
cd "update-${TODAY}"
#
# Here we go
#
yum clean all > /dev/null 2>&1
echo QMailToaster UNOFFICIAL Build/Update for RHEL/CentOS 6 - Version $VERSION
echo "Building for $ARCH on `cat /etc/redhat-release`"
#
# First, remove any old (conflicting!) mail programs
#
echo -n "Removing conflicting mail packages..."
OLDMAIL="`rpm -qa | grep '^postfix'` `rpm -qa | grep '^sendmail'`"
if [ ! -z $OLDMAIL ] ; then
rpm -e --nodeps $OLDMAIL
if grep ^postfix /etc/passwd > /dev/null 2>&1 ; then
userdel postfix
echo -n " Postfix"
fi
if grep ^sendmail /etc/passwd > /dev/null 2>&1 ; then
userdel sendmail
echo -n " Sendmail"
fi
fi
${SHOWDONE}
#
# Next, update existing packages
#
echo -n "Updating existing packages..."
if yum update -y $VERBOSE ; then # returns 0 if successful
${SHOWDONE}
else
${SHOWERROR}
exit 10
fi
#
# Check EPEL Dependency
#
echo -n "Checking for EPEL repository..."
# no harm if its already there
if ! rpm -qa | grep "^epel-release" > /dev/null 2>&1 ; then
if ! wget http://mirror.pnl.gov/epel/6/i386/epel-release-6-7.noarch.rpm >
/dev/null 2>&1 ; then
${SHOWERROR}
echo "$0: Failed to download latest epel-release... update script & re-run"
1>&2
exit 12
fi
if ! rpm -ivh epel-release* > /dev/null 2>&1 ; then
${SHOWERROR}
echo ""
echo "$0: Failed to install latest epel-release... fix & re-run" 1>&2
exit 13
fi
# IFF we installed it, ensure EPEL is NOT enabled by default
sed 's/enabled *= *1/enabled = 0/' /etc/yum.repos.d/epel.repo >
/tmp/QMT-epel.repo
/bin/mv /tmp/QMT-epel.repo /etc/yum.repos.d/epel.repo
${SHOWOK}
else
${SHOWDONE}
fi
# Check RPMforge Dependency
#
echo -n "Checking for RPMforge/RepoForge..."
# no harm if its already there
rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt > /dev/null 2>&1
if ! yum install -y wget > /dev/null 2>&1 ; then
${SHOWERROR}
echo "$0: Failed to download wget -- check Internet connection & re-run"
1>&2
exit 11
fi
if ! rpm -qa | grep "^rpmforge-release" > /dev/null 2>&1 ; then
if ! wget
http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.${ARCH}.rpm
> /dev/null 2>&1 ; then
${SHOWERROR}
echo "$0: Failed to download latest rpmforge release... update script &
re-run" 1>&2
exit 12
fi
if ! rpm -ivh rpmforge-release* > /dev/null 2>&1 ; then
${SHOWERROR}
echo ""
echo "$0: Failed to install latest rpmforge release... fix & re-run" 1>&2
exit 13
fi
# IFF we installed it, ensure ReroForge/RPMforge is NOT enabled by default
sed 's/enabled *= *1/enabled = 0/' /etc/yum.repos.d/rpmforge.repo >
/tmp/QMT-rpmforge.repo
/bin/mv /tmp/QMT-rpmforge.repo /etc/yum.repos.d/rpmforge.repo
${SHOWOK}
else
${SHOWDONE}
fi
#
# Install CentOS Deps
#
echo -n "Verifying CentOS Dependencies..."
INSTALLED="`rpm -qa`"
INSTALL_LIST=
for TEST in $DEPENDENCIES ; do
if ! echo $INSTALLED | grep $TEST > /dev/null 2>&1 ; then
INSTALL_LIST="$INSTALL_LIST $TEST"
fi
done
if [ ! -z "$INSTALL_LIST" ] ; then
if ! yum install -y $VERBOSE $INSTALL_LIST ; then
echo $0: Exiting from YUM error 1>&2
exit 20
fi
${SHOWDONE}
else
${SHOWOK}
fi
#
# Install EPEL Deps
#
echo -n "Verifying Perl Dependencies in EPEL..."
INSTALL_LIST=
for TEST in $PERLDEPSEPEL ; do
if ! rpm -qa | grep "^$TEST" > /dev/null 2>&1 ; then
INSTALL_LIST="$INSTALL_LIST $TEST"
fi
done
if [ ! -z "$INSTALL_LIST" ] ; then
if ! yum install -y --enablerepo=epel $VERBOSE $INSTALL_LIST ; then
echo $0: Exiting from YUM error 1>&2
exit 21
fi
${SHOWDONE}
else
${SHOWOK}
fi
#
# Install RepoForge/RPMforge Deps
#
echo -n "Verifying Perl Dependencies in RepoForge..."
INSTALL_LIST=
for TEST in $PERLDEPSRPMFORGE ; do
if ! rpm -qa | grep "^$TEST" > /dev/null 2>&1 ; then
INSTALL_LIST="$INSTALL_LIST $TEST"
fi
done
if [ ! -z "$INSTALL_LIST" ] ; then
if ! yum install -y --enablerepo=rpmforge $VERBOSE $INSTALL_LIST ; then
echo $0: Exiting from YUM error 1>&2
exit 21
fi
${SHOWDONE}
else
${SHOWOK}
fi
#
# Prepare for RPMBUILD -- make this mimick CentOS 4 & 5 for now
mkdir -p /usr/src/redhat/RPMS
if [ ! -L ~/rpmbuild ] && [ ! -d ~/rpmbuild ] ; then
ln -s /usr/src/redhat/RPMS ~/rpmbuild
fi
#
# Get Download Items
QT_PACKAGES=`wget -qc -O - "http://mirror0.qmailtoaster.com/info/current.txt"`
#
# If list is unavailable, quit
if [ -z "${QT_PACKAGES}" ] ; then
echo "Package List unavailable, please check your connection and try again"
1>&2
exit 30
fi
# Check Package Lists...
#
for RPM in ${QT_PACKAGES} ; do
RPM=`echo ${RPM} | sed 's/-[0-9].*//'`
if ! echo "${PACKAGES}" | grep ${RPM} > /dev/null 2>&1 ; then
echo "Hmmm...Not sure what to do about ${RPM} -- its not in my install
list!"
echo -n "Shall I continue? [Yn] "
read REPLY
if [ "$REPLY" == "n" -o "$REPLY" == "N" ] ; then
echo "OK -- Bye!"
exit 0
else
echo "OK -- continuing on..."
fi
fi
done
for RPM in ${PACKAGES} ; do
RPM=`echo ${RPM} | sed 's/-[0-9].*//'`
if ! echo "${QT_PACKAGES}" | grep ${RPM} > /dev/null 2>&1 ; then
echo "Hmmm...Not sure what to do about ${RPM} -- its not in their install
list!"
echo -n "Shall I continue? [Yn] "
read REPLY
if [ "$REPLY" == "n" -o "$REPLY" == "N" ] ; then
echo "OK -- Bye!"
exit 0
else
echo "OK -- continuing on..."
fi
fi
done
#
# Before getting started, backup settings files (to preserve)
if ps -aef | grep -v grep | grep qmail > /dev/null 2>&1 ; then
echo -n "Stopping current QMail processes..."
if ! /usr/bin/qmailctl stop > /dev/null 2>&1 ; then
${SHOWERROR} # no need to exit
else
${SHOWOK}
fi
echo -n "Backing up current Qmail configs..."
if ! tar czf /tmp/qmail.control.tgz -C /var/qmail/control/ . ; then
${SHOWERROR} # no need to exit
else
${SHOWOK}
fi
fi
#
# Remove packages that may conflict with upgrades...
for PKG in ${REMOVE_FIRST} ; do
echo -n "Temporarily removing ${PKG}..."
if rpm -q ${PKG} > /dev/null 2>&1 ; then
if ! rpm -e --nodeps ${PKG} > /dev/null 2>&1 ; then
${SHOWERROR} # no need to exit
else
${SHOWOK}
fi
else
${SHOWDONE}
fi
done
#
#
# do these in MY order (not the downloaded file's order)
for RPM in ${PACKAGES} ; do
SRPM=`echo "${QT_PACKAGES}" | grep ${RPM}`
if [ -z "$SRPM" ] ; then
echo "Skipping missing $SRPM per your directions..."
else
echo -n "Checking ${SRPM} "
BASE=`echo ${SRPM} | sed 's/\.src.rpm$//'`
if rpm -qa | grep ${BASE} >/dev/null 2>&1 ; then
${SHOWOK}
elif echo ${SKIP_LIST} | grep -w "${RPM}" >/dev/null 2>&1 ; then
${SHOWSKIP}
else
RPM=`find /usr/src/${BDIR}/RPMS -name "${BASE}*rpm"`
if [ -z "${RPM}" ] ; then
# Clean up any OLD versions
CHECK=`echo ${BASE} | sed 's/[0-9].*//'`
find /usr/src/${BDIR}/RPMS -name "${CHECK}*" -exec rm -rf '{}' \;
rm -rf /tmp/${BASE}.log
# Get it (download it)
${SHOWDWNLOAD}
if ! wget -qc ${QMTSOURCE}/${SRPM} > /dev/null 2>&1 ; then
${SHOWFAIL}
echo "$0: ERROR downloading $SRPM"
exit 40
fi
# Build it
${SHOWREBUILD}
if ! rpmbuild --rebuild --with ${DISTRO} ${SRPM} > /tmp/${BASE}.log
2>&1 ; then
${SHOWFAIL}
echo "Check /tmp/${BASE}.log"
if [ "${BASE}" == "vqadmin-toaster-2.3.7-1.4.1" ] ; then
echo -n " -- Sigh -- getting pre-built vqadmin-toaster from Dan..."
if ! wget -qc
"http://stpfl.it4soho.com/vqadmin-toaster-2.3.7-1.4.1.x86_64.rpm" > /dev/null
2>&1 ; then
echo "$0: ERROR downloading pre-built RPM -- we're out of options
here..."
exit 40
fi
mv vqadmin-toaster-2.3.7-1.4.1.x86_64.rpm /usr/src/${BDIR}/RPMS/
else
exit 41
fi
else
rm -f /tmp/${BASE}.log
fi
fi
# find the built RPM
${SHOWINSTALL}
sleep 4
RPM=`find /usr/src/${BDIR}/RPMS -name "${BASE}*rpm"`
if [ -z ${RPM} ] ; then
${SHOWFAIL}
echo "$0: Error -- unable to find ${BASE} RPM"
exit 42
fi
if ! rpm -Uvh --nodeps --replacefiles --replacepkgs ${RPM} >>
/tmp/${BASE}.log 2>&1 ; then
${SHOWFAIL}
echo "Check /tmp/${BASE}.log"
exit 1
else
rm -f /tmp/${BASE}.log
fi
${SHOWDONE}
fi
fi
done
#
# remove the update directory
cd ..
rm -rf "update-${TODAY}"
#
# Install QMail Toaster Plus scripts (no deps)
echo -n "Installing QMail Toaster Plus scripts"
if ! rpm -qa | grep qmailtoaster-plus > /dev/null 2>&1 ; then
if ! rpm -ivh http://qtp.qmailtoaster.com/trac/downloads/1 > /dev/null 2>&1 ;
then
${SHOWERROR}
echo "$0: unable to get qmailtoaster-plus repo - fix & re-try" 1>&2
exit 50
fi
if ! yum install -y $VERBOSE qmailtoaster-plus ; then
${SHOWERROR}
echo "$0: unable to install qmailtoaster-plus - fix & re-try" 1>&2
exit 51
else
${SHOWDONE}
fi
else
${SHOWOK}
fi
#
# Verify that MySQL is running
#
echo -n "Verifying MySQL Installation"
if mysqladmin reload > /dev/null 2>&1 ; then
${SHOWOK}
else
chkconfig mysqld on ; service mysqld start > /dev/null 2>&1
if mysqladmin -uroot password "$MYSQLPW" > /dev/null 2>&1 ; then
${SHOWDONE}
echo "NOTE: Your MySQL root password is set to $MYSQLPW"
else # The above command fails if a root password was already set
${SHOWOK}
fi
fi
echo -n "Verifying VPopMail MySQL Database"
if [ -d /var/lib/mysql/vpopmail ] ; then
${SHOWOK}
else
mysqladmin create vpopmail -uroot -p$MYSQLPW
mysqladmin -uroot -p$MYSQLPW reload
mysqladmin -uroot -p$MYSQLPW refresh
echo "GRANT ALL PRIVILEGES ON vpopmail.* TO vpopmail@localhost IDENTIFIED BY
'SsEeCcRrEeTt'" | mysql -uroot -p$MYSQLPW
mysqladmin -uroot -p$MYSQLPW reload
mysqladmin -uroot -p$MYSQLPW refresh
${SHOWDONE}
fi
#
# Restart Qmail when appropriate
QMAILHOST="`cat /var/qmail/control/me`"
if [ ! -z ${QMAILHOST} ] && grep "$QMAILHOST" /etc/hosts > /dev/null 2>&2 ; then
if grep -i '^SELINUX=enforcing' /etc/selinux/config > /dev/null 2>&1 ; then
echo ""
echo "Your QMail Toaster is installed, but I did not start it because"
echo "you have SELinux enabled (and enforcing) on this system and our"
echo "install scripts to not (yet) support SELinux configurations"
else
/usr/bin/qmailctl start
fi
else
echo ""
echo "Your QMail Toaster is installed, but I did not start it because:"
echo " a) You haven't configured it yet, or"
echo " b) You have changed your host or domain name"
echo ""
echo "This is evidenced by the fact that the value in /var/qmail/control/me"
echo "is not found in your list of hostnames in /etc/hosts."
echo ""
echo "If you start QMail before fixing this, you will get a flood of error
messages"
echo "You have been warned!"
echo ""
fi
---------------------------------------------------------------------
To unsubscribe, e-mail: qmailtoaster-list-unsubscr...@qmailtoaster.com
For additional commands, e-mail: qmailtoaster-list-h...@qmailtoaster.com
---------------------------------------------------------------------
To unsubscribe, e-mail: qmailtoaster-list-unsubscr...@qmailtoaster.com
For additional commands, e-mail: qmailtoaster-list-h...@qmailtoaster.com