"Requirements":
Automatically complete installation postfix (enter host name, domain name and install path as prompted), Dovecot, SquirrelMail, basic configuration
"Hint":
This script continues as the installation of the lamp environment is complete (the Apache installation path is/usr/local/apache/and can be replaced with a different path by modifying the script start position httpd_dir variable value)
#!/bin/bash
Httpd_dir= "/usr/local/apache"
Ls/etc/postfix &>/dev/null
If [$?-ne 0]; Then
Yum-y Install Db*-devel cyrus-sasl-*
Service SendMail Stop &>/dev/null
Chkconfig--level SendMail off
grep postfix/etc/passwd &>/dev/null
If [$?-ne 0];then
GROUPADD-G 1200 Postdrop
GROUPADD-G 1000 Postfix
Useradd-m-u 1000-g postfix-g postdrop-s/sbin/nologin postfix
Fi
Postfixball= ' ls/usr/src/postfix*.gz '
Tar zxf $postfixball-C/USR/SRC
Dir= ' Ls-l/usr/src | grep ^d | grep postfix | awk ' {print $} '
cd/usr/src/$dir
Make makefiles ' Ccargs=-duse_sasl_auth-duse_cyrus_sasl-i/usr/include/sasl ' AUXLIBS=-L/USR/LIB/SASL2-LSASL2 ' & & Make && make install
Cd/etc/postfix
Postconf-n > Tmp.file
Back to the column page: http://www.bianceng.cnhttp://www.bianceng.cn/Servers/Mail/
Mv/etc/postfix/main.cf/etc/postfix/main.cf.bak
MV TMP.FILE/ETC/POSTFIX/MAIN.CF
ip= ' Ifconfig eth0 | grep "inet Addr:" | awk ' {print $} ' | Awk-f: ' {print $} '
Read-p "Myhostname of FQDN:" Myhostname
Read-p "MyDomain of Mail:" MyDomain
echo "Inet_interfaces= $ip, 127.0.0.1
Myhostname= $myhostname
mydomain= $mydomain
myorigin= $mydomain
mydestination= $mydomain, $myhostname
home_mailbox=maildir/">>/etc/postfix/main.cf
Postfix start
Fi
Ls/etc/dovecot &>/dev/null
If [$?-ne 0]; Then
Yum-y Install Pam-devel
grep dovecot/etc/passwd &>/dev/null
If [$?-ne 0]; Then
Useradd-m-s/sbin/nologin Dovecot
Useradd-m-s/sbin/nologin Dovenull
Fi
Dovecotball= ' ls/usr/src/dovecot*.gz '
Tar zxf $dovecotball-C/usr/src/
Dir= ' Ls-l/usr/src/| grep ^d | grep dovecot |awk ' {print $} '
cd/usr/src/$dir
./configure--sysconfdir=/etc && make && make install
CP Doc/dovecot-initd.sh/etc/init.d/dovecot
chmod +x/etc/init.d/dovecot
Chkconfig--add Dovecot
Chkconfig Dovecot on
Cp-r/usr/local/share/doc/dovecot/example-config/*/etc/dovecot
echo "#%pam-1.0
Auth Required pam_nologin.so
Auth include System-auth
Account include System-auth
Session include System-auth ">/etc/pam.d/dovecot
Sed-i ' s_include conf.d/\*.conf_include conf.d/10-auth.conf_ '/etc/dovecot/dovecot.conf
echo "Ssl=no
Disable_plaintext_auth=no
Mail_location=maildir:~/maildir ">>/etc/dovecot/dovecot.conf
Service Dovecot Start
Fi
if [!-f/usr/lib/sasl2/smtpd.conf]; Then
echo "PWCHECK_METHOD:SASLAUTHD" >/usr/lib/sasl2/smtpd.conf
Service SASLAUTHD start &>/dev/null
Chkconfig--level SASLAUTHD on
echo "Smtpd_sasl_auth_enable=yes
Smtpd_sasl_security_options=noanonymous
mynetworks=127.0.0.1
smtpd_recipient_restrictions=
Permit_mynetworks,
Permit_sasl_authenticated,
Reject_unauth_destination ">>/etc/postfix/main.cf
Postfix Reload
Fi
if [!-D $httpd _dir/htdocs/webmail]; Then
Squirrelball= ' ls/usr/src/squirrel*.gz '
Tar zxf $squirrelball-C/USR/SRC
Dir= ' Ls-l/usr/src | grep ^d |grep Squirrel | awk ' {print $} '
mv/usr/src/$dir $httpd _dir/htdocs/webmail
webmaildir= $httpd _dir/htdocs/webmail
Tar zxf/usr/src/zh_cn*.gz-c $webmaildir
CD $HTTPD _dir/htdocs/webmail
Mkdir-p Data Attach
Chown-r Daemon:daemon Data Attach
CP config/config_default.php config/config.php
Sed-i '/^ $data _dir =/d ' config/config.php
Sed-i '/^ $attachment _dir =/d ' config/config.php
Sed-i '/^ $squirrelmail _default_language=/d ' config/config.php
Sed-i '/^ $default _charset =/d ' config/config.php
echo "\ $data _dir = ' $webmaildir/data ';
\ $attachment _dir = ' $webmaildir/attach ';
\ $squirrelmail _default_language = ' ZH_CN ';
\ $default _charset = ' zh_cn. UTF-8 '; ' >> config/config.php
Fi
This article is from the "Soldier" blog, please be sure to keep this source http://ganbing.blog.51cto.com/7002794/1243667