From 02a2b15c114a598ff7850b3d2d61df774fb99056 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 11 Aug 2014 13:15:01 +0530 Subject: [PATCH] Added Error Handling for Sieve and Amavis --- .../stack/install/mail/ee_mod_setup_amavis.sh | 14 +++++++++----- .../stack/install/mail/ee_mod_setup_sieve.sh | 14 +++++++++----- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/modules/stack/install/mail/ee_mod_setup_amavis.sh b/src/modules/stack/install/mail/ee_mod_setup_amavis.sh index fa4d4b46..84af5a92 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_amavis.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_amavis.sh @@ -3,18 +3,22 @@ function ee_mod_setup_amavis() { # Confiure Amavis - sed -i "s'#@'@'" /etc/amavis/conf.d/15-content_filter_mode - sed -i "s'# ' '" /etc/amavis/conf.d/15-content_filter_mode + sed -i "s'#@'@'" /etc/amavis/conf.d/15-content_filter_mode && \ + sed -i "s'# ' '" /etc/amavis/conf.d/15-content_filter_mode \ + || ee_lib_error "Unable to setup Amavis, exit status = " $? # Add mail filtering rules - sed -i "s/use strict;/use strict;\n\$sa_spam_subject_tag = undef;\n\$spam_quarantine_to = undef;\n\$sa_tag_level_deflt = undef;\n\n# Prevent spams from automatically rejected by mail-server\n\$final_spam_destiny = D_PASS;\n# We need to provide list of domains for which filtering need to be done\n@lookup_sql_dsn = (\n ['DBI:mysql:database=vimbadmin;host=127.0.0.1;port=3306',\n 'vimbadmin',\n 'password']);\n\n\$sql_select_policy = 'SELECT domain FROM domain WHERE CONCAT("@",domain) IN (%k)';/" /etc/amavis/conf.d/50-user + sed -i "s/use strict;/use strict;\n\$sa_spam_subject_tag = undef;\n\$spam_quarantine_to = undef;\n\$sa_tag_level_deflt = undef;\n\n# Prevent spams from automatically rejected by mail-server\n\$final_spam_destiny = D_PASS;\n# We need to provide list of domains for which filtering need to be done\n@lookup_sql_dsn = (\n ['DBI:mysql:database=vimbadmin;host=127.0.0.1;port=3306',\n 'vimbadmin',\n 'password']);\n\n\$sql_select_policy = 'SELECT domain FROM domain WHERE CONCAT("@",domain) IN (%k)';/" /etc/amavis/conf.d/50-user \ + || ee_lib_error "Unable to setup Amavis, exit status = " $? + # Configure Postfix to use Amavis # For postfix main.cf postconf -e "content_filter = smtp-amavis:[127.0.0.1]:10024" # For postfix master.cf - sed -i "s/1 pickup/1 pickup\n -o content_filter=\n -o receive_override_options=no_header_body_checks/" /etc/postfix/master.cf + sed -i "s/1 pickup/1 pickup\n -o content_filter=\n -o receive_override_options=no_header_body_checks/" /etc/postfix/master.cf \ + || ee_lib_error "Unable to setup Amavis, exit status = " $? cat /usr/share/easyengine/mail/amavis-master.cf >> /etc/postfix/master.cf - + } diff --git a/src/modules/stack/install/mail/ee_mod_setup_sieve.sh b/src/modules/stack/install/mail/ee_mod_setup_sieve.sh index 3cf0c0ed..8b80c72c 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_sieve.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_sieve.sh @@ -3,11 +3,13 @@ function ee_mod_setup_amavis() { # Enable sieve plugin support for dovecot-lmtp - sed -i "s' #mail_plugins = \$mail_plugins' postmaster_address = admin@example.com\n mns sieve'" /etc/dovecot/conf.d/20-lmtp.conf + sed -i "s' #mail_plugins = \$mail_plugins' postmaster_address = admin@example.com\n mns sieve'" /etc/dovecot/conf.d/20-lmtp.conf \ + || ee_lib_error "Unable to add sieve plugin support for dovecot-lmtp, exit status = " $? # Sieve dovecot-pluign configuration - sed -i "s'sieve = ~/.dovecot.sieve'sieve = ~/.dovecot.sieve\n sieve_global_path = /var/lib/dovecot/sieve/default.sieve'" /etc/dovecot/conf.d/90-sieve.conf - sed -i "s'#sieve_global_dir ='sieve_global_dir = /var/lib/dovecot/sieve/'" /etc/dovecot/conf.d/90-sieve.conf + sed -i "s'sieve = ~/.dovecot.sieve'sieve = ~/.dovecot.sieve\n sieve_global_path = /var/lib/dovecot/sieve/default.sieve'" /etc/dovecot/conf.d/90-sieve.conf && \ + sed -i "s'#sieve_global_dir ='sieve_global_dir = /var/lib/dovecot/sieve/'" /etc/dovecot/conf.d/90-sieve.conf \ + || ee_lib_error "Unable to setup Sieve dovecot-pluign, exit status = " $? # Create global Sieve rules file mkdir -p /var/lib/dovecot/sieve/ @@ -15,9 +17,11 @@ function ee_mod_setup_amavis() chown -R vmail:vmail /var/lib/dovecot # Compile Sieve rules - sievec /var/lib/dovecot/sieve/default.sieve + sievec /var/lib/dovecot/sieve/default.sieve \ + || ee_lib_error "Unable to compile Sieve rules, exit status = " $? # Configure Roundcube - sed -i "s:\$config\['plugins'\] = array(:\$config\['plugins'\] = array(\n 'sieverules':" /var/www/roundcubemail/htdocs/config/config.inc.php + sed -i "s:\$config\['plugins'\] = array(:\$config\['plugins'\] = array(\n 'sieverules':" /var/www/roundcubemail/htdocs/config/config.inc.php \ + || ee_lib_error "Unable to configure Sieve Roundcube plugin, exit status = " $? echo "\$config['sieverules_port'] = 4190;" >> /var/www/roundcubemail/htdocs/config/config.inc.php }