Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Sblam Updater
#!/usr/bin/env bash
# Autoupdater for SBLAM! blacklist and converter to nginx deny format
# Based on sblam_nginx.sh by Marcin M. (exine):
# https://bitbucket.org/exine/scriptlets/src/tip/sblam/sblam_nginx.sh
BLACKLIST="http://sblam.com/blacklisthtaccess.txt" # Adress of the source blacklist
HTACCESS="/usr/local/www/apache22/data/.htaccess" # Under this path blacklist will be saved. Do NOT set this to any file that needs to contain something else than blacklist, it is cleared every time this script runs
DATE=`date` # Do not change unless you know what you're doing
TMP_BLACKLIST="/tmp/spammer_blacklist.txt"
touch ${TMP_BLACKLIST}
chmod 0600 ${TMP_BLACKLIST} # /tmp race prevention
/usr/local/bin/wget -O- ${BLACKLIST} > ${TMP_BLACKLIST}
echo "# This file is updated periodically, do not edit" > ${HTACCESS}
echo "# Last update: ${DATE}" >> ${HTACCESS}
cat ${TMP_BLACKLIST} >> ${HTACCESS}
rm ${TMP_BLACKLIST}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment