Created
October 20, 2015 14:34
-
-
Save serweb-labs/6a4f41138925a3aebf97 to your computer and use it in GitHub Desktop.
Script to install postgrey and spamassassin on Ubuntu with ZPanel / Sentora
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/sh | |
# | |
# Script to install postgrey and spamassassin on Ubuntu ZPanel system, arrogantly hacked from Centos 6.4 and ZPanel 10.1.0 script by acid | |
# | |
# Designed for ZPanel 10.1.1 & Ubuntu 12.04LTS | |
# | |
# Version 1 | |
# | |
if which postgrey >/dev/null; then | |
echo "postgrey already exist" | |
else | |
echo "Installing postgrey" | |
apt-get -y install postgrey | |
sed -i '/^smtpd_recipient_restrictions =/ s/$/ check_policy_service inet:127.0.0.1:10023,/' /etc/zpanel/configs/postfix/main.cf | |
sed -i 's/POSTGREY_OPTS=\"--inet=10023"/POSTGREY_OPTS=\"--inet=127.0.0.1:10023 --delay=150\"/g' /etc/default/postgrey | |
service postgrey start | |
service postfix reload | |
chkconfig postgrey on | |
echo "postgrey installed" | |
fi | |
# Install Spamassassin | |
if which spamassassin >/dev/null; then | |
echo "spamassassin already exist" | |
else | |
echo "Installing spamassassin" | |
apt-get -y install spamassassin spamc | |
# Enable | |
sed -i 's/ENABLED=0/ENABLED=1/g' /etc/default/spamassassin | |
# Set Home Directory | |
sed -i '/OPTIONS=/i \SAHOME="/var/log/spamassassin/"' /etc/default/spamassassin | |
# Set Options inc log | |
sed -i 's/OPTIONS="--create-prefs --max-children 5 --helper-home-dir"/OPTIONS="--create-prefs --max-children 2 --username spamd --helper-home-dir ${SAHOME} -s ${SAHOME}spamd.log"/g' /etc/default/spamassassin | |
# Setup sa user account | |
groupadd spamd | |
useradd -g spamd -s /bin/false -d /var/log/spamassassin spamd | |
mkdir /var/log/spamassassin | |
chown spamd:spamd /var/log/spamassassin | |
# Edit local file | |
sed -i '1s/^/required_hits 5.0\n/' /etc/spamassassin/local.cf | |
sed -i '2s/^/report_safe 0\n/' /etc/spamassassin/local.cf | |
sed -i '3s/^/required_score 5\n/' /etc/spamassassin/local.cf | |
sed -i '4s/^/rewrite_header Subject ***SPAM***\n/' /etc/spamassassin/local.cf | |
# Update 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 | |
sed -i '/^smtp inet/ s/$/ -o content_filter=spamassassin/' /etc/zpanel/configs/postfix/master.cf | |
echo "\nspamassassin unix - n n - - pipe flags=R user=spamd argv=/usr/bin/spamc -e /usr/sbin/sendmail -oi -f \${sender} \${recipient}\n" >> /etc/zpanel/configs/postfix/master.cf | |
service postfix restart | |
service 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