Subversion Repositories SmartDukaan

Rev

Rev 6595 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6595 Rev 6596
Line 2... Line 2...
2
rm -f Deniedlist
2
rm -f Deniedlist
3
rm -f GeoIPCountry*
3
rm -f GeoIPCountry*
4
rm -f ARGlist
4
rm -f ARGlist
5
rm -f temp
5
rm -f temp
6
 
6
 
-
 
7
CURDIR=`pwd`
-
 
8
 
7
if [ -z "$1" ]; then
9
if [ -z "$1" ]; then
8
 
10
 
9
echo "Usage: GetDeniedIpRange.sh Country1,Country2,.....,CountryN"
11
echo "Usage: GetDeniedIpRange.sh Country1,Country2,.....,CountryN DatabaseIPAddress"
10
 
12
 
11
exit 1
13
exit 1
12
 
14
 
13
fi
15
fi
14
 
16
 
15
echo $1 | sed 's/,/\n/g' >ARGlist
-
 
16
 
17
 
-
 
18
if [ -z "$2" ]; then
-
 
19
 
17
/usr/bin/mysql -h 192.168.190.114 -u root -pshop2020 -Bse "use transaction;delete from blockediprange"
20
echo "No host given using localhost"
-
 
21
 
-
 
22
host="localhost"
-
 
23
 
-
 
24
else
-
 
25
 
-
 
26
host=$2
-
 
27
 
-
 
28
fi
-
 
29
 
-
 
30
 
-
 
31
echo $1 | sed 's/,/\n/g' >ARGlist
18
 
32
 
19
wget http://geolite.maxmind.com/download/geoip/database/GeoIPCountryCSV.zip
33
wget http://geolite.maxmind.com/download/geoip/database/GeoIPCountryCSV.zip
20
 
34
 
21
unzip GeoIPCountryCSV.zip
35
if [ $? -eq 0 ]; then
22
 
36
 
23
while read arglist
37
/usr/bin/mysql -h $host -u root -pshop2020 -Bse "use transaction;delete from blockediprange"
24
 
38
 
25
do
39
else
26
 
40
 
27
PARAM=$arglist
41
echo "Request Denied IP List file not downloaded....Exiting"
28
 
42
 
29
grep -i "$PARAM" GeoIPCountryWhois.csv | awk -F ',' '{print $3" "$4}' | sed 's/"//g' > Deniedlist
-
 
-
 
43
exit 1
30
 
44
 
31
while read line
45
fi
32
 
46
 
33
do
47
unzip GeoIPCountryCSV.zip
34
 
48
 
35
echo $line > temp
49
while read arglist
36
 
50
 
37
START=`awk -F ' ' '{print $1}' temp`
-
 
-
 
51
do
38
 
52
 
39
END=`awk -F ' ' '{print $2}' temp`
53
PARAM=$arglist
40
 
54
 
41
/usr/bin/mysql -h 192.168.190.114 -u root -pshop2020 -Bse "use transaction;insert into blockediprange (start, end) values ('$START','$END')"
55
grep -i "$PARAM" GeoIPCountryWhois.csv | awk -F ',' '{print $3" "$4}' | sed 's/"//g' > Deniedlist
42
 
56
 
43
done < Deniedlist
-
 
-
 
57
/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)"
44
 
58
 
45
done < ARGlist
59
done < ARGlist