Adding base script parsing database and constructing continent lists
This commit is contained in:
parent
20db3b099f
commit
8e0ea9bd21
31
haproxy-geoip-generate.sh
Executable file
31
haproxy-geoip-generate.sh
Executable 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
|
||||
Loading…
x
Reference in New Issue
Block a user