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
Script for operations on Black and White list tables
- shawniverson
- Posts: 3650
- Joined: 13 Jan 2014 23:30
- Location: Indianapolis, Indiana USA
- Contact:
Re: Script for operations on Black and White list tables
Indeed a good start! I my case I only have to modify the blacklist automated. Thanks!
# 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
# 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