当前位置: 首页 > 工具软件 > OpenDKIM > 使用案例 >

Centos6.X 64位机器,自动安装postfix+opendkim,shell脚本

郤令
2023-12-01

PS:使用时需要注意把域名替换成自己的域名,我这里的域名是 ken.paipaibo.net


脚本正文:

#!/bin/bash



for num in {1..20};do


useradd ken$num


echo "douhap123" |passwd --stdin ken$num


done


yum -y install ca-certificates yum-fastestmirror vim


rpm -ivh http://mirrors.sohu.com/fedora-epel/6/\
x86_64/epel-release-6-8.noarch.rpm
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
sed -i '3s/^#//' /etc/yum.repos.d/epel.repo
sed -i '4s/^/#/' /etc/yum.repos.d/epel.repo


yum -y install postfix cyrus* opendkim


cd /etc/postfix
postconf -n > main.cf.test
mv main.cf main.cf.bak
mv main.cf.test main.cf


sed -i '9s/localhost/all/' main.cf


echo "
mydomain = ken.paipaibo.net
myhostname = ken.paipaibo.net
mynetworks = 192.168.0.0/24,127.0.0.0/8
message_size_limit = 5242880
mailbox_size_limit = 5242880
show_user_unknown_table_name = no
bounce_queue_lifetime = 1d
maximal_queue_lifetime = 1d
smtpd_recipient_restrictions = 
 permit_mynetworks,
 permit_sasl_authenticated,
 reject_non_fqdn_hostname,
 reject_non_fqdn_sender,
 reject_non_fqdn_recipient,
 reject_unauth_destination,
 reject_unauth_pipelining,
 reject_invalid_hostname,
 permit_sasl_authenticated,
 reject_unauth_destination,
smtpd_sender_restrictions = 
 permit_mynetworks,
 reject_unauthenticated_sender_login_mismatch,
smtpd_sender_login_maps = 
broken_sasl_auth_clients = yes
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous
smtpd_milters = inet:localhost:8891
non_smtpd_milters = inet:localhost:8891
milter_protocol = 2
milter_default_action = accept
" >> main.cf


echo -e "\n"


sed -i '39s/v/vs/' /etc/opendkim.conf


echo "Domain ken.paipaibo.net" >> /etc/opendkim.conf


echo "default._domainkey.ken.paipaibo.net \
ken.paipaibo.net:default:/etc/opendkim/keys/\
default.private" >> /etc/opendkim/KeyTable


echo "*@ken.paipaibo.net default._domainkey.\
ken.paipaibo.net" >> /etc/opendkim/SigningTable


cd /etc/opendkim/keys


opendkim-genkey -r -d ken.paipaibo.net


chown opendkim.opendkim default.private


cat default.txt


echo -e "\n"


echo "0 */5 * * * root postsuper -d \
ALL deferred" >> /etc/crontab


echo "0 */10 * * * root rm -rf \
/var/log/*-20*" >> /etc/crontab


echo "0 */10 * * * root echo ''>/var/log/maillog"\
 >> /etc/crontab


echo "0 */10 * * * root echo ''>/var/log/btmp"\
 >> /etc/crontab


echo "0 */10 * * * root echo ''>/var/spool/mail/root"\
 >> /etc/crontab


echo "The Postfix mail installing is finished"


/etc/init.d/postfix restart
/etc/init.d/saslauthd restart
/etc/init.d/iptables stop
setenforce 0
/etc/init.d/opendkim restart


chkconfig postfix on
chkconfig saslauthd on
chkconfig iptables off
chkconfig opendkim on


echo OK
 类似资料: