Adding base script parsing database and constructing continent lists

This commit is contained in:
Sebastien Laithier 2019-08-09 10:53:22 +02:00
parent 20db3b099f
commit 8e0ea9bd21
2 changed files with 331728 additions and 0 deletions

31
haproxy-geoip-generate.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/bash
FILE_RANGE="./temp.txt"
FILE_COUNTRY_CODE="./GeoLite2-Country-CSV_20190806/GeoLite2-Country-Locations-fr.csv"
CODE=0
while read p; do
CODE=$(awk -F ',' '{print $2}' <<< $p)
RANGE=$(awk -F ',' '{print $1}' <<< $p)
CONTINENT=$(awk -v country_code="$CODE" -F ',' '$0 ~ country_code {print $3}' $FILE_COUNTRY_CODE)
case "$CONTINENT" in
AS)
printf "%s %s\n" "$RANGE" "$CONTINENT" >> AS.txt
;;
OC)
printf "%s %s\n" "$RANGE" "$CONTINENT" >> OC.txt
;;
EU)
printf "%s %s\n" "$RANGE" "$CONTINENT" >> EU.txt
;;
AF)
printf "%s %s\n" "$RANGE" "$CONTINENT" >> AF.txt
;;
SA)
printf "%s %s\n" "$RANGE" "$CONTINENT" >> SA.txt
;;
NA)
printf "%s %s\n" "$RANGE" "$CONTINENT" >> NA.txt
;;
esac
done < temp.txt

331697
temp.txt Normal file

File diff suppressed because it is too large Load Diff