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 »

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: 3644
Joined: 13 Jan 2014 23:30
Location: Indianapolis, Indiana USA
Contact:

Re: Script for operations on Black and White list tables

Post by shawniverson »

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

Re: Script for operations on Black and White list tables

Post by SupportOU »

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