Script for operations on Black and White list tables

Request and discuss new features you would like to have.
Post Reply
SupportOU
Posts: 47
Joined: 12 Sep 2016 18:47

Script for operations on Black and White list tables

Post by SupportOU » 03 Nov 2017 19:51

Hola,

I have automated a lot of stuff for allowing new users and departments on my platform. Is there a piece of script with which I can add or delete black and white list entries? Or should I create something myself with the mySQL credentials in the conf files? And are the tables straight forward?

And is there a bulk export script or should I create one myself as well?

Grtz,
Ronald

User avatar
shawniverson
Posts: 2785
Joined: 13 Jan 2014 23:30
Location: Rushville, Indiana, USA
Contact:

Re: Script for operations on Black and White list tables

Post by shawniverson » 12 Nov 2017 11:20

Version eFa 4.0.0 RC3 now available in testing repo. Come join us in advancing eFa!

SupportOU
Posts: 47
Joined: 12 Sep 2016 18:47

Re: Script for operations on Black and White list tables

Post by SupportOU » 16 Nov 2017 14:47

Indeed a good start! I my case I only have to modify the blacklist automated. Thanks! :clap: :clap:

# adding domain to mysql db mailscanner table blacklist
MAILWATCHSQLPWD=`grep MAILWATCHSQLPWD /etc/EFA-Config | sed 's/.*://'`
if [[ -z $MAILWATCHSQLPWD ]]; then
echo "Unable to access SQL password from /etc/EFA-Config, exiting."
exit
fi

# check if there already
echo 'checking mailwatch'
A=`mysql -u mailwatch --password=$MAILWATCHSQLPWD mailscanner -e "SELECT COUNT(*) from blacklist WHERE from_address='$1';" | awk '!/COUNT/{print $1}'`
if [ -z "$A" ]; then
echo "something went wrong quering mailwatch, exit"
fi

if [ "$A" == "0" ]; then
echo "adding $1 to blacklist in mailwatch"
mysql -u mailwatch --password=$MAILWATCHSQLPWD mailscanner -e "INSERT INTO blacklist (to_address, to_domain, from_address) VALUES ('default','','$1')"
else
echo "$1 already in mailwatch black list"
fi

Post Reply