From 23a0762219290c38c63ef2885b05f46a0f27ac48 Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Fri, 16 May 2014 21:32:14 +0300 Subject: [PATCH] update triggers --- upd/add_fwd_only.sh | 61 ++++++++++++++++++++++--------------- upd/fix_exim_permissions.sh | 12 ++++++++ 2 files changed, 48 insertions(+), 25 deletions(-) create mode 100755 upd/fix_exim_permissions.sh diff --git a/upd/add_fwd_only.sh b/upd/add_fwd_only.sh index a5af4791..ab2948ad 100755 --- a/upd/add_fwd_only.sh +++ b/upd/add_fwd_only.sh @@ -1,34 +1,45 @@ #!/bin/bash -# Define exim config +# RHEL or CentOS if [ -e "/etc/exim/exim.conf" ]; then - # RHEL or CentOS - conf="/etc/exim/exim.conf" -else - # Debian or Ubuntu + conf='/etc/exim/exim.conf' + + # Check if fwd_only flag + check_flag=$(grep localuser_fwd_only $conf) + if [ ! -z "$check_flag" ]; then + exit + fi + + # Define new router + fwd1='localuser_fwd_only:\n driver = accept\n transport = devnull\n' + fwd2=' condition = \${if exists{/etc/exim/domains/\$domain/fwd_only}' + fwd3='{\${lookup{\$local_part}lsearch{/etc/exim/domains/\$domain/fwd_only}' + fwd4='{true}{false}}}}\n\n' + + # Insert router + sed -i "s%localuser_spam:%$fwd1$fwd2$fwd3${fwd4}localuser_spam:%" $conf +fi + +# Debian or Ubuntu +if [ -e "/etc/exim4/exim4.conf.template" ]; then conf="/etc/exim4/exim4.conf.template" + + # Check if fwd_only flag + check_flag=$(grep localuser_fwd_only $conf) + if [ ! -z "$check_flag" ]; then + sed -i "s%/exim/domains/%/exim4/domains/i%" $conf + else + # Define new router + fwd1='localuser_fwd_only:\n driver = accept\n transport = devnull\n' + fwd2=' condition = \${if exists{/etc/exim4/domains/\$domain/fwd_only}' + fwd3='{\${lookup{\$local_part}lsearch' + fwd4='{/etc/exim4/domains/\$domain/fwd_only}{true}{false}}}}\n\n' + + # Insert router + sed -i "s%localuser_spam:%$fwd1$fwd2$fwd3${fwd4}localuser_spam:%" $conf + fi fi -# Check existance -if [ ! -e "$conf" ]; then - exit -fi - -# Check if fwd_only flag -check_flag=$(grep localuser_fwd_only $conf) -if [ ! -z "$check_flag" ]; then - exit -fi - -# Define new router -fwd1='localuser_fwd_only:\n driver = accept\n transport = devnull\n' -fwd2=' condition = \${if exists{/etc/exim/domains/\$domain/fwd_only}' -fwd3='{\${lookup{\$local_part}lsearch{/etc/exim/domains/\$domain/fwd_only}' -fwd4='{true}{false}}}}\n\n' - -# Insert router -sed -i "s%localuser_spam:%$fwd1$fwd2$fwd3${fwd4}localuser_spam:%" $conf - # Restart mail server /usr/local/vesta/bin/v-restart-mail diff --git a/upd/fix_exim_permissions.sh b/upd/fix_exim_permissions.sh new file mode 100755 index 00000000..7eaefb0c --- /dev/null +++ b/upd/fix_exim_permissions.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +if [ -e "/etc/exim4/domains/" ]; then + for domain in $(ls /etc/exim4/domains/); do + domain_link=$(readlink /etc/exim4/domains/$domain) + chown Debian-exim:mail $domain_link + chown Debian-exim:mail /etc/exim4/domains/$domain/* + chown dovecot:mail /etc/exim4/domains/$domain/passwd + done +fi + +exit