Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6595 kshitij.so 1
#!/bin/bash
2
rm -f Deniedlist
3
rm -f GeoIPCountry*
4
rm -f ARGlist
5
rm -f temp
6
 
7
if [ -z "$1" ]; then
8
 
9
echo "Usage: GetDeniedIpRange.sh Country1,Country2,.....,CountryN"
10
 
11
exit 1
12
 
13
fi
14
 
15
echo $1 | sed 's/,/\n/g' >ARGlist
16
 
17
/usr/bin/mysql -h 192.168.190.114 -u root -pshop2020 -Bse "use transaction;delete from blockediprange"
18
 
19
wget http://geolite.maxmind.com/download/geoip/database/GeoIPCountryCSV.zip
20
 
21
unzip GeoIPCountryCSV.zip
22
 
23
while read arglist
24
 
25
do
26
 
27
PARAM=$arglist
28
 
29
grep -i "$PARAM" GeoIPCountryWhois.csv | awk -F ',' '{print $3" "$4}' | sed 's/"//g' > Deniedlist
30
 
31
while read line
32
 
33
do
34
 
35
echo $line > temp
36
 
37
START=`awk -F ' ' '{print $1}' temp`
38
 
39
END=`awk -F ' ' '{print $2}' temp`
40
 
41
/usr/bin/mysql -h 192.168.190.114 -u root -pshop2020 -Bse "use transaction;insert into blockediprange (start, end) values ('$START','$END')"
42
 
43
done < Deniedlist
44
 
45
done < ARGlist