Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#!/bin/bash
rm -f Deniedlist
rm -f GeoIPCountry*
rm -f ARGlist
rm -f temp

if [ -z "$1" ]; then

echo "Usage: GetDeniedIpRange.sh Country1,Country2,.....,CountryN"

exit 1

fi

echo $1 | sed 's/,/\n/g' >ARGlist

/usr/bin/mysql -h 192.168.190.114 -u root -pshop2020 -Bse "use transaction;delete from blockediprange"

wget http://geolite.maxmind.com/download/geoip/database/GeoIPCountryCSV.zip

unzip GeoIPCountryCSV.zip

while read arglist

do

PARAM=$arglist

grep -i "$PARAM" GeoIPCountryWhois.csv | awk -F ',' '{print $3" "$4}' | sed 's/"//g' > Deniedlist

while read line

do

echo $line > temp

START=`awk -F ' ' '{print $1}' temp`

END=`awk -F ' ' '{print $2}' temp`

/usr/bin/mysql -h 192.168.190.114 -u root -pshop2020 -Bse "use transaction;insert into blockediprange (start, end) values ('$START','$END')"

done < Deniedlist

done < ARGlist