22 lines
481 B
Bash
Executable File
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
|