haproxy-geoip/geoip-percountry.sh
2019-08-09 14:09:17 +02:00

13 lines
437 B
Bash
Executable File

#!/bin/bash
FILE_RANGE="./source/range-country_code.txt"
FILE_COUNTRY_CODE="./source/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)
COUNTRY=$(awk -v country_code="$CODE" -F ',' '$0 ~ country_code {print $5}' $FILE_COUNTRY_CODE)
printf "%s\n" "$RANGE" >> ./country/"$COUNTRY".txt
done < $FILE_RANGE