編寫安裝配置mail服務指令碼
編寫安裝配置mail服務指令碼
【要求】:
自動完成安裝postfix(根據提示輸入主機名、域名並確定安裝路徑)、dovecot、squirrelmail,基本配置
【提示】:
此指令碼是在lamp環境安裝完成的前提下繼續的操作(apache安裝路徑為/usr/local/apache/,可通過修改指令碼起始位置httpd_dir變數值以替換成其他路徑)
#!/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 35 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 $7}“
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
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 $2}` | awk -F: `{print $2}“
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 $7}“
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 35 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 $7}“
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
相關文章
- systemd 編寫服務管理指令碼指令碼
- shell編寫服務啟動指令碼指令碼
- Nginx服務安裝配置Nginx
- RabbitMQ服務安裝配置MQ
- 服務端常見服務安裝及配置服務端
- 1.安裝、配置、編寫、理解
- Kali Linux常用服務配置教程安裝及配置DHCP服務Linux
- CentOS6.7安裝配置nfs服務CentOSNFS
- linux下安裝、配置samba服務LinuxSamba
- gdb指令碼編寫指令碼
- Shell 指令碼編寫指令碼
- ubuntu系統samba服務的安裝配置UbuntuSamba
- centos8安裝和配置redis服務CentOSRedis
- CentOS7下RabbitMQ服務安裝配置CentOSMQ
- LINUX下VNC服務的安裝配置LinuxVNC
- linux下Samba服務配置與安裝LinuxSamba
- 從零開始系列-Laravel編寫api服務介面:1.安裝LaravelLaravelAPI
- 油猴指令碼編寫指令碼
- 編寫git指令碼.shGit指令碼
- Oracle安裝前的環境配置指令碼Oracle指令碼
- LAMP原始碼編譯安裝配置+wordpressLAMP原始碼編譯
- 服務自啟指令碼指令碼
- Nexus windows安裝,配置為系統服務Windows
- zabbix3.x服務端安裝和配置服務端
- MySQL5.6一鍵編譯安裝指令碼MySql編譯指令碼
- 《web-Mail服務的搭建》WebAI
- 原始碼包編譯安裝MySQL 5.6指令碼原始碼編譯MySql指令碼
- EA指令碼編寫要點指令碼
- 編寫執行R指令碼指令碼
- 編譯FFMPEG原始碼的指令碼編寫案例編譯原始碼指令碼
- Oracle 11g 安裝環境配置指令碼Oracle指令碼
- Oracle 10g 安裝環境配置指令碼Oracle 10g指令碼
- NFS介紹、NFS服務端安裝配置、NFS配置選項NFS服務端
- RHEL7原始碼安裝Apache服務原始碼Apache
- grpc套路服務端編寫RPC服務端
- CentOS.7下安裝配置FTP和SFTP服務CentOSFTP
- CentOS7.4安裝php配置php-fpm服務CentOSPHP
- Linux環境VNC服務安裝、配置與使用LinuxVNC