Subversion Repositories SmartDukaan

Rev

Rev 6595 | Blame | Compare with Previous | Last modification | View Log | RSS feed

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

CURDIR=`pwd`

if [ -z "$1" ]; then

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

exit 1

fi


if [ -z "$2" ]; then

echo "No host given using localhost"

host="localhost"

else

host=$2

fi


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

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

if [ $? -eq 0 ]; then

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

else

echo "Request Denied IP List file not downloaded....Exiting"

exit 1

fi

unzip GeoIPCountryCSV.zip

while read arglist

do

PARAM=$arglist

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

/usr/bin/mysql -h $host -u root -pshop2020 -Bse "use transaction;LOAD DATA LOCAL INFILE '$CURDIR/Deniedlist' INTO TABLE blockediprange FIELDS TERMINATED BY ' ' LINES TERMINATED BY '\n' (start,end)"

done < ARGlist