Skip to content

Commit cf05cee

Browse files
committed
fwd_only update trigger
1 parent a1d0945 commit cf05cee

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

upd/add_fwd_only.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
# Define exim config
4+
if [ -e "/etc/exim/exim.conf" ]; then
5+
# RHEL or CentOS
6+
conf="/etc/exim/exim.conf"
7+
else
8+
# Debian or Ubuntu
9+
conf="/etc/exim4/exim4.conf.template"
10+
fi
11+
12+
# Check existance
13+
if [ ! -e "$conf" ]; then
14+
exit
15+
fi
16+
17+
# Check if fwd_only flag
18+
check_flag=$(grep localuser_fwd_only $conf)
19+
if [ ! -z "$check_flag" ]; then
20+
exit
21+
fi
22+
23+
# Define new router
24+
fwd1='localuser_fwd_only:\n driver = accept\n transport = devnull\n'
25+
fwd2=' condition = \${if exists{/etc/exim/domains/\$domain/fwd_only}'
26+
fwd3='{\${lookup{\$local_part}lsearch{/etc/exim/domains/\$domain/fwd_only}'
27+
fwd4='{true}{false}}}}\n\n'
28+
29+
# Insert router
30+
sed -i "s%localuser_spam:%$fwd1$fwd2$fwd3${fwd4}localuser_spam:%" $conf
31+
32+
# Restart mail server
33+
/usr/local/vesta/bin/v-restart-mail
34+
35+
exit

0 commit comments

Comments
 (0)