Rev 6595 | Blame | Compare with Previous | Last modification | View Log | RSS feed
#!/bin/bashrm -f Deniedlistrm -f GeoIPCountry*rm -f ARGlistrm -f tempCURDIR=`pwd`if [ -z "$1" ]; thenecho "Usage: GetDeniedIpRange.sh Country1,Country2,.....,CountryN DatabaseIPAddress"exit 1fiif [ -z "$2" ]; thenecho "No host given using localhost"host="localhost"elsehost=$2fiecho $1 | sed 's/,/\n/g' >ARGlistwget http://geolite.maxmind.com/download/geoip/database/GeoIPCountryCSV.zipif [ $? -eq 0 ]; then/usr/bin/mysql -h $host -u root -pshop2020 -Bse "use transaction;delete from blockediprange"elseecho "Request Denied IP List file not downloaded....Exiting"exit 1fiunzip GeoIPCountryCSV.zipwhile read arglistdoPARAM=$arglistgrep -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