Created
May 13, 2015 19:56
-
-
Save hilotech/42f776c7d7cf36e05cca to your computer and use it in GitHub Desktop.
ConoHa [VPSでコラボ]Postfix+Dovecot構築スクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
set -u | |
MY_DOMAIN='example.com' | |
MY_ADDR='127.0.0.1' | |
yum -y install postfix dovecot | |
/sbin/iptables -I INPUT -p tcp --dport smtp -j ACCEPT | |
/sbin/iptables -I INPUT -p tcp --dport pop3 -j ACCEPT | |
/sbin/iptables -I INPUT -p tcp --dport imap -j ACCEPT | |
service iptables save && service iptables restart | |
mkdir -p /etc/skel/Maildir/{new,cur,tmp} | |
chmod -R 700 /etc/skel/Maildir | |
sed -i \ | |
-e 's|^\(inet_interfaces = localhost\)|\#\1|' \ | |
-e 's|^\(mydestination = $myhostname, localhost.$mydomain, localhost\)|\#\1|' \ | |
/etc/postfix/main.cf | |
CF_TEMP=`mktemp` | |
/bin/cp /etc/postfix/main.cf /etc/postfix/main.cf.org | |
cat /etc/postfix/main.cf >> $CF_TEMP | |
cat <<_EOF_ > /etc/postfix/main.cf | |
myhostname = $MY_DOMAIN | |
mydomain = $MY_DOMAIN | |
myorigin = $MY_DOMAIN | |
mynetworks = $MY_ADDR, 127.0.0.0/8 | |
mydestination = \$myhostname, localhost.\$mydomain, localhost, \$mydomain | |
inet_interfaces = all | |
smtpd_relay_restrictions = permit_mynetworks | |
home_mailbox = Maildir/ | |
_EOF_ | |
cat $CF_TEMP >> /etc/postfix/main.cf | |
/bin/rm $CF_TEMP | |
cat <<_EOF_ > /etc/dovecot/conf.d/99-mailstore.conf | |
mail_location = maildir:~/Maildir | |
_EOF_ | |
chkconfig postfix on | |
chkconfig dovecot on | |
service postfix restart | |
service dovecot start | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment