#!/usr/bin/env bash
#
# fail2db ver 1.0
#
# Skrypt zapisuje do bazy danych adresy IP zablokowane przez fail2ban
#
#
# by Krzysztof 'zmijka' Zmijewski
# zmijka at szoszo dot eu
#
##############################################################################


DATA=`date "+%Y-%m-%d %H:%M:%S"`
CCODE=`/usr/bin/geoiplookup $2 | awk '{ print $4 }' | cut -d , -f 1`
CNAME=`/usr/bin/geoiplookup $2 | cut -d , -f 2 | sed 's/^[[:space:]]//g'`


/usr/bin/mysql -ufail2ban -p'password' -D fail2ban -e "INSERT INTO baned (ban_date, ban_name, ban_ip, country_code, country_name) VALUES (\"$DATA\", \"$1\", \"$2\", \"$CCODE \", \"$CNAME\");"





syntax highlighted by Code2HTML, v. 0.9.1