From 1835842d236a44378012ae26c5d00ad4c9b2c904 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 26 Dec 2014 15:54:13 +0530 Subject: [PATCH] Added Mailscanner --- ee/cli/plugins/stack.py | 38 +++++++++++++++++++ .../templates/15-content_filter_mode.mustache | 27 +++++++++++++ ee/cli/templates/50-user.mustache | 17 +++++++++ ee/core/variables.py | 5 +++ setup.py | 1 + 5 files changed, 88 insertions(+) create mode 100644 ee/cli/templates/15-content_filter_mode.mustache create mode 100644 ee/cli/templates/50-user.mustache diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 61322e83..f04d89b4 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -280,8 +280,35 @@ class EEStackController(CementBaseController): EEShellExec.cmd_exec("sievec /var/lib/dovecot/sieve/" "default.sieve") + if set(EEVariables.ee_mailscanner).issubset(set(apt_packages)): + # Set up Custom amavis configuration + data = dict() + ee_amavis = open('/etc/amavis/conf.d/15-content_filter_mode', + 'w') + self.app.render((data), '15-content_filter_mode.mustache', + out=ee_amavis) + ee_amavis.close() + + # Amavis postfix configuration + EEShellExec.cmd_exec("postconf -e \"content_filter = " + "smtp-amavis:[127.0.0.1]:10024\"") + EEShellExec.cmd_exec("sed -i \"s/1 pickup/1 pickup" + "\n -o content_filter=\n -o" + " receive_override_options=no_header_body" + "_checks/\" /etc/postfix/master.cf") + + # Amavis ClamAV configuration + EEShellExec.cmd_exec("adduser clamav amavis") + EEShellExec.cmd_exec("adduser amavis clamav") + EEShellExec.cmd_exec("chmod -R 775 /var/lib/amavis/tmp") + + # Update ClamAV database + EEShellExec.cmd_exec("freshclam") + EEShellExec.cmd_exec("service clamav-daemon restart") + if len(packages): if any('/usr/bin/wp' == x[1] for x in packages): + EEShellExec.cmd_exec("chmod +x /usr/bin/wp") if any('/tmp/pma.tar.gz' == x[1] for x in packages): @@ -436,6 +463,15 @@ class EEStackController(CementBaseController): out=vm_config) vm_config.close() + # If Amavis is going to be installed then configure Vimabadmin + # Amvis settings + if set(EEVariables.ee_mailscanner).issubset(set(apt_packages)): + vm_config = open('/etc/amavis/conf.d/50-user', + 'w') + self.app.render((data), '50-user.mustache', + out=vm_config) + vm_config.close() + if any('/tmp/roundcube.tar.gz' == x[1] for x in packages): # Extract RoundCubemail EEExtract.extract('/tmp/roundcube.tar.gz', '/tmp/') @@ -497,6 +533,8 @@ class EEStackController(CementBaseController): "1.0.4/roundcubemail-1.0.4.tar.gz", "/tmp/roundcube.tar.gz"] ] + if EEVariables.ee_ram > 1024: + apt_packages = apt_packages + EEVariables.ee_mailscanner if self.app.pargs.nginx: apt_packages = apt_packages + EEVariables.ee_nginx diff --git a/ee/cli/templates/15-content_filter_mode.mustache b/ee/cli/templates/15-content_filter_mode.mustache new file mode 100644 index 00000000..6fd8f218 --- /dev/null +++ b/ee/cli/templates/15-content_filter_mode.mustache @@ -0,0 +1,27 @@ +use strict; + +# You can modify this file to re-enable SPAM checking through spamassassin +# and to re-enable antivirus checking. + +# +# Default antivirus checking mode +# Please note, that anti-virus checking is DISABLED by +# default. +# If You wish to enable it, please uncomment the following lines: + + +@bypass_virus_checks_maps = ( + \%bypass_virus_checks, \@bypass_virus_checks_acl, \$bypass_virus_checks_re); + + +# +# Default SPAM checking mode +# Please note, that anti-spam checking is DISABLED by +# default. +# If You wish to enable it, please uncomment the following lines: + + +@bypass_spam_checks_maps = ( + \%bypass_spam_checks, \@bypass_spam_checks_acl, \$bypass_spam_checks_re); + +1; # ensure a defined return diff --git a/ee/cli/templates/50-user.mustache b/ee/cli/templates/50-user.mustache new file mode 100644 index 00000000..e0e0c625 --- /dev/null +++ b/ee/cli/templates/50-user.mustache @@ -0,0 +1,17 @@ +use strict; +$sa_spam_subject_tag = undef; +$spam_quarantine_to = undef; +$sa_tag_level_deflt = undef; + +# Prevent spams from automatically rejected by mail-server +$final_spam_destiny = D_PASS; + +# We need to provide list of domains for which filtering need to be done +@lookup_sql_dsn = ( +['DBI:mysql:database=vimbadmin;host=127.0.0.1;port=3306', +'vimbadmin', +'{{password}}']); + +$sql_select_policy = 'SELECT domain FROM domain WHERE CONCAT("@",domain) IN (%k)'; + +1; # ensure a defined return diff --git a/ee/core/variables.py b/ee/core/variables.py index 0271c0b5..f6fe0d05 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -4,6 +4,7 @@ import socket import configparser import os import sys +import psutil class EEVariables(): @@ -27,6 +28,10 @@ class EEVariables(): print("Unable to find GIT user name and Email") sys.exit(1) + # Get System RAM and SWAP details + ee_ram = psutil.virtual_memory().total / (1024 * 1024) + ee_swap = psutil.swap_memory().total / (1024 * 1024) + # EasyEngine stack installation varibales # Nginx repo and packages if ee_platform_distro == 'Ubuntu': diff --git a/setup.py b/setup.py index fe9b3c7a..3722d0c2 100644 --- a/setup.py +++ b/setup.py @@ -33,6 +33,7 @@ setup(name='ee', 'python-apt', 'pynginxconfig', 'pymysql3', + 'psutil', ], setup_requires=[], entry_points="""