Last active
August 29, 2015 14:12
-
-
Save bdamusis/f58912675a6885bd5018 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/sh | |
# | |
# Script to install Postgrey and SpamAssassin with ZPanel | |
# | |
# Tested on: | |
# - Centos 6.4 and ZPanel 10.1.0 | |
# - Centos 6.5 and ZPanel 10.1.1 | |
# | |
# Original post: http://goo.gl/5iG3LN | |
# | |
if which postgrey >/dev/null; then | |
echo "postgrey already exist" | |
else | |
echo "Installing postgrey" | |
yum -y install postgrey | |
sed -i '/^smtpd_recipient_restrictions =/ s/$/ check_policy_service inet:127.0.0.1:60000,/' /etc/zpanel/configs/postfix/main.cf | |
sed -i 's/options=\"--unix=\/var\/spool\/postfix\/postgrey\/socket\"/options=\"--inet=127.0.0.1:60000 --delay=150\"/g' /etc/init.d/postgrey | |
service postgrey start | |
service postfix reload | |
chkconfig postgrey on | |
echo "postgrey installed" | |
fi | |
# | |
if which spamassassin >/dev/null; then | |
echo "spamassassin already exist" | |
else | |
echo "Installing spamassassin" | |
yum -y install spamassassin | |
echo -e "\n" > /etc/mail/spamassassin/local.cf | |
sed -i '1s/^/required_hits 5.0\n/' /etc/mail/spamassassin/local.cf | |
sed -i '2s/^/report_safe 0\n/' /etc/mail/spamassassin/local.cf | |
sed -i '3s/^/required_score 5\n/' /etc/mail/spamassassin/local.cf | |
sed -i '4s/^/rewrite_header Subject ***SPAM***\n/' /etc/mail/spamassassin/local.cf | |
groupadd spamd | |
useradd -g spamd -s /bin/false -d /var/log/spamassassin spamd | |
chown spamd:spamd /var/log/spamassassin | |
sed -i '/^smtp inet/ s/$/ -o content_filter=spamassassin/' /etc/zpanel/configs/postfix/master.cf | |
sed -i '/^smtp inet/ s/$/ -o content_filter=spamassassin/' /etc/zpanel/configs/postfix/master.cf | |
sed -i '/^smtp inet/ s/$/ -o content_filter=spamassassin/' /etc/zpanel/configs/postfix/master.cf | |
sed -i '/^smtp inet/ s/$/ -o content_filter=spamassassin/' /etc/zpanel/configs/postfix/master.cf | |
echo -e "\nspamassassin unix - n n - - pipe flags=R user=spamd argv=/usr/bin/spamc -e /usr/sbin/sendmail.postfix -oi -f \${sender} \${recipient}\n" >> /etc/zpanel/configs/postfix/master.cf | |
/etc/init.d/postfix restart | |
/etc/init.d/spamassassin restart | |
echo "SpamAssassin installed, to test it send a mail from outside with the subject: XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X" | |
echo "Your first email will take about 150 seconds to arrive" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment