#!/bin/bash


LANG=C


# postfix-2.10.2.tar.gz

INST_DIR=/usr/src


/etc/init.d/sendmail stop &> /dev/null

chkconfig sendmail off

yum -y install db4-devel cyrus-sasl-devel

yum -y install pam-devel

yum -y install libtool-ltdl-devel expect

yum -y remove postfix  

userdel -r postfix

groupdel  postdrop

groupadd -g 1200 postdrop 

groupadd -g 1000 postfix 

useradd -M -u 1000 -g 1000 -G 1200 -s /sbin/nologin postfix

yum install -y cyrus-sasl-md5 cyrus-sasl-lib cyrus-sasl-plain cyrus-sasl cyrus-sasl-devel  

cd $INST_DIR

tar zxf postfix-2.10.2.tar.gz -C /usr/src/

cd /usr/src/postfix-2.10.2/

make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/include/mysql -DUSE_CYRUS_SASL -DUSE_SASL_AUTH -I/usr/local/include/sasl' 'AUXLIBS=-L/usr/lib64/mysql -lmysqlclient -lm -lz -L/usr/local/lib -lsasl2' 2> $INST_DIR/postfix.error

ln -s `find / -name sasl2` /usr/local/lib 

ln -s /usr/include/sasl/* /usr/local/include/

make 2>> $INST_DIR/postfix.error

make install 2>> $INST_DIR/postfix.error