Skip to content

Instantly share code, notes, and snippets.

@michal-m
Created March 15, 2012 11:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michal-m/2043707 to your computer and use it in GitHub Desktop.
Save michal-m/2043707 to your computer and use it in GitHub Desktop.
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