-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathda_enable_spamassassin.sh
More file actions
36 lines (34 loc) · 1.33 KB
/
da_enable_spamassassin.sh
File metadata and controls
36 lines (34 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
# A shell script to enable SpamAssassin with Low Threshold (5.0) when a new user is created in DirectAdmin
# Place this code in /usr/local/directadmin/scripts/custom/user_create_post.sh
# Written by: TimVNL
if [ "$spam" = "ON" ]; then
echo "Enabling SpamAssassin with Low Threshold (5.0)"
DIR=/home/$username/.spamassassin
mkdir -p $DIR
USERPREFS=$DIR/user_prefs
if [ ! -s ${USERPREFS} ]; then
echo 'required_score 5.0' > ${USERPREFS}
echo 'rewrite_header subject *****SPAM*****' >> ${USERPREFS}
echo 'report_safe 1' >> ${USERPREFS}
chown $username:$username ${USERPREFS}
chmod 644 ${USERPREFS}
fi
chown ${username}:mail $DIR
chmod 771 $DIR
if grep -m1 -q '^spamd=rspamd$' /usr/local/directadmin/custombuild/options.conf; then
echo "action=rewrite&value=rspamd&user=${username}" >> /usr/local/directadmin/data/task.queue
fi
if [ "${domain}" != "" ]; then
FILTERCONF=/etc/virtual/${domain}/filter.conf
if [ ! -s ${FILTERCONF} ]; then
echo 'adult=ON' > ${FILTERCONF}
echo 'high_score=15' > ${FILTERCONF}
echo 'high_score_block=no' >> ${FILTERCONF}
echo 'where=userspamfolder' >> ${FILTERCONF}
chown mail:mail ${FILTERCONF}
echo "action=rewrite&value=filter&user=$username" >> /usr/local/directadmin/data/task.queue
fi
fi
fi
exit 0;