From cf05cee924589cf6112c116ff4a91f46e0acbcdb Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Wed, 20 Nov 2013 23:25:30 +0200 Subject: [PATCH] fwd_only update trigger --- upd/add_fwd_only.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 upd/add_fwd_only.sh diff --git a/upd/add_fwd_only.sh b/upd/add_fwd_only.sh new file mode 100755 index 000000000..a5af47912 --- /dev/null +++ b/upd/add_fwd_only.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Define exim config +if [ -e "/etc/exim/exim.conf" ]; then + # RHEL or CentOS + conf="/etc/exim/exim.conf" +else + # Debian or Ubuntu + conf="/etc/exim4/exim4.conf.template" +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 + +exit