Guest User

Postgrey & Spamassassin installation ubuntu 12.04lts

a guest
Oct 3rd, 2014
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.57 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3. # Script to install postgrey and spamassassin on Ubuntu ZPanel system, arrogantly hacked from Centos 6.4 and ZPanel 10.1.0 script by acid
  4. #
  5. # Designed for ZPanel 10.1.1 & Ubuntu 12.04LTS
  6. #
  7. # Version 1
  8. #
  9. if which postgrey >/dev/null; then
  10. echo "postgrey already exist"
  11. else
  12. echo "Installing postgrey"
  13. apt-get -y install postgrey
  14. sed -i '/^smtpd_recipient_restrictions =/ s/$/ check_policy_service inet:127.0.0.1:10023,/' /etc/zpanel/configs/postfix/main.cf
  15. sed -i 's/POSTGREY_OPTS=\"--inet=10023"/POSTGREY_OPTS=\"--inet=127.0.0.1:10023 --delay=150\"/g' /etc/default/postgrey
  16. service postgrey start
  17. service postfix reload
  18. chkconfig postgrey on
  19. echo "postgrey installed"
  20. fi
  21. # Install Spamassassin
  22. if which spamassassin >/dev/null; then
  23. echo "spamassassin already exist"
  24. else
  25. echo "Installing spamassassin"
  26. apt-get -y install spamassassin spamc
  27. # Enable
  28. sed -i 's/ENABLED=0/ENABLED=1/g' /etc/default/spamassassin
  29. # Set Home Directory
  30. sed -i '/OPTIONS=/i \SAHOME="/var/log/spamassassin/"' /etc/default/spamassassin
  31. # Set Options inc log
  32. 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
  33. # Setup sa user account
  34. groupadd spamd
  35. useradd -g spamd -s /bin/false -d /var/log/spamassassin spamd
  36. mkdir /var/log/spamassassin
  37. chown spamd:spamd /var/log/spamassassin
  38. # Edit local file
  39. sed -i '1s/^/required_hits 5.0\n/' /etc/spamassassin/local.cf
  40. sed -i '2s/^/report_safe 0\n/' /etc/spamassassin/local.cf
  41. sed -i '3s/^/required_score 5\n/' /etc/spamassassin/local.cf
  42. sed -i '4s/^/rewrite_header Subject ***SPAM***\n/' /etc/spamassassin/local.cf
  43. # Update postfix master.cf
  44. sed -i '/^smtp        inet/ s/$/ -o content_filter=spamassassin/' /etc/zpanel/configs/postfix/master.cf
  45. sed -i '/^smtp      inet/ s/$/ -o content_filter=spamassassin/' /etc/zpanel/configs/postfix/master.cf
  46. sed -i '/^smtp    inet/ s/$/ -o content_filter=spamassassin/' /etc/zpanel/configs/postfix/master.cf
  47. sed -i '/^smtp  inet/ s/$/ -o content_filter=spamassassin/' /etc/zpanel/configs/postfix/master.cf
  48. 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
  49. service postfix restart
  50. service spamassassin restart
  51. 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"
  52. echo "Your first email will take about 150 seconds to arrive"
  53. fi
Advertisement
Add Comment
Please, Sign In to add comment