[fix] fuck distro using dash over bash
This commit is contained in:
parent
af5fb34c70
commit
860344923c
|
@ -4,19 +4,21 @@ action=$1
|
||||||
ip=$2
|
ip=$2
|
||||||
service=$3
|
service=$3
|
||||||
|
|
||||||
curDir="$( cd "$( dirname $0 )" && pwd)"
|
curDir=$(dirname $0)
|
||||||
|
|
||||||
source $curDir/bancount.cfg
|
cd $curDir
|
||||||
|
|
||||||
if [ -f GeopIP.dat]
|
source bancount.cfg
|
||||||
|
|
||||||
|
if [ -f "GeoIP.dat" ]
|
||||||
then
|
then
|
||||||
allInfoIp=`geoiplookup $ip`;
|
allInfoIp=`geoiplookup $ip`;
|
||||||
else
|
else
|
||||||
allInfoIp=`geoiplookup -f GeopIP.dat $ip`;
|
allInfoIp=`geoiplookup -f GeoIP.dat $ip`;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
geoip () {
|
geoip () {
|
||||||
echo $allInfoIp | awk -F, '{print $2}' | sed s/\ //
|
echo $allInfoIp | awk -F, '{print $2}' | sed s/\ //
|
||||||
}
|
}
|
||||||
|
|
||||||
countryCode () {
|
countryCode () {
|
||||||
|
@ -26,19 +28,19 @@ countryCode () {
|
||||||
case $action in
|
case $action in
|
||||||
|
|
||||||
ban)
|
ban)
|
||||||
mysql $mysqldb -u $mysqluser --password=$mysqlpw -e "INSERT INTO bans (ip, service, ban_date, ban_time, country, countryCode) VALUES ( '$ip', '$service', '`date +%F`', '`date +%T`', '`geoip`', '`countryCode`');"
|
mysql $mysqldb -u $mysqluser --password=$mysqlpw -e "INSERT INTO bans (ip, service, ban_date, ban_time, country, countryCode) VALUES ( '$ip', '$servi$
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
unban)
|
unban)
|
||||||
mysql $mysqldb -u $mysqluser --password=$mysqlpw -e "INSERT INTO unbans (ip, service, unban_date, unban_time, country, countryCode) VALUES ( '$ip', '$service', '`date +%F`', '`date +%T`', '`geoip`', '`countryCode`');"
|
mysql $mysqldb -u $mysqluser --password=$mysqlpw -e "INSERT INTO unbans (ip, service, unban_date, unban_time, country, countryCode) VALUES ( '$ip', '$
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
cat << EOF
|
cat << EOF
|
||||||
Fail2BanCount - by k6b - MySQL logger
|
Fail2BanCount - by k6b - MySQL logger
|
||||||
|
|
||||||
$(basename $0) <ban/unban> <ip>
|
$(basename $0) <ban/unban> <ip> <service>
|
||||||
|
|
||||||
Performs geoip lookup and stamps time
|
Performs geoip lookup and stamps time
|
||||||
and date into MySQL database.
|
and date into MySQL database.
|
||||||
|
@ -46,4 +48,4 @@ EOF
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
Loading…
Reference in New Issue