Skip to content

Instantly share code, notes, and snippets.

@rushipkar90
Created September 25, 2015 16:43
Show Gist options
  • Save rushipkar90/44db0eb8b785451f8bde to your computer and use it in GitHub Desktop.
Save rushipkar90/44db0eb8b785451f8bde to your computer and use it in GitHub Desktop.
spam_sender_block.sh
#!/bin/bash
#
# Bronco May 2014
#
CONF=/etc/exim.conf.local
CHANGE=0
main() {
if [ -n "$(diff $CONF /tmp/exim.conf.local)" ] && [ -f "/tmp/exim.conf.local" ]; then
echo "Replacing the config..."
mv $CONF /home/bronco/exim.conf.local.$(date +%s)
mv /tmp/exim.conf.local $CONF
for F in /etc/deny_senders; do
touch $F;chown root:mail $F;chmod 640 $F
done
/scripts/buildeximconf && /etc/init.d/exim restart && echo "DONE"
else
echo "Latest file used"
fi
for U in $(cat /etc/deny_senders); do exiqgrep -r | grep "<"$U">" | awk '{print $3}' | sed '/^$/d' | xargs exim -Mf; exiqgrep -z -i | xargs exim -Mrm; done
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment