This repository has been archived on 2025-03-03. You can view files and clone it, but cannot push or open issues or pull requests.
q2a-antispam/q2a_usercheck.sh
2021-12-27 15:27:52 -08:00

22 lines
481 B
Bash
Executable File

#!/bin/sh
logf='/var/log/nginx/access.log'
cache='/tmp/forumspam_cache'
case `uname` in
(*"BSD"*) tail_opts='-f';;
(*) tail_opts='-F';;
esac
test -f $cache || install -m 600 /dev/null $cache
tail $tail_opts $logf | while read line ; do
case $line in (*"POST"*)
ip=`echo $line | awk '{print $1}'`
ip_regex=`echo $ip | sed 's/\./\\./g; s/^/^/; s/$/$/'`
if ! grep -q $ip_regex $cache; then
/usr/local/bin/forumspam.sh "$ip" && echo $ip >> $cache
fi
esac
done