]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - src/scripts/xt_geoip_update
Merge branch 'next'
[people/pmueller/ipfire-2.x.git] / src / scripts / xt_geoip_update
index 93884dcf5b67de12467c467b67a4af0f0cca32dd..9ea66e00678a3bb89a3d92c376ca67c6ea511099 100644 (file)
@@ -25,6 +25,7 @@ TMP_FILE=$(mktemp -p $TMP_PATH)
 SCRIPT_PATH=/usr/local/bin
 DEST_PATH=/usr/share/xt_geoip
 DB_PATH=/var/lib/GeoIP
+DB1_PATH=/usr/share/GeoIP
 
 DL_URL=https://geolite.maxmind.com/download/geoip/database
 DL_FILE=GeoLite2-Country-CSV.zip
@@ -82,6 +83,22 @@ function install() {
        return 0
 }
 
+function build_legacy() {
+       # Create temporary directory.
+       mkdir -pv $TMP_PATH
+       
+       echo "Convert database to legacy GeoIP.dat ..."
+       cat $DB_PATH/GeoLite2-Country-Blocks-IPv4.csv | \
+           $DB1_PATH/bin/geolite2-to-legacy-csv.sh $DB1_PATH/bin/countryInfo.txt > \
+           $TMP_FILE
+       $DB1_PATH/bin/geoip-generator -v -4 --info="$(date -u +'GEO-106FREE %Y%m%d Build -IPFire-' \
+           -r $DB_PATH/GeoLite2-Country-Blocks-IPv4.csv) $(<$DB_PATH/COPYRIGHT.txt)" -o \
+           $DB1_PATH/GeoIP.dat $TMP_FILE
+
+       return 0
+}
+
+
 function build() {
        echo "Convert database..."
 
@@ -121,7 +138,12 @@ function main() {
        # Convert the ruleset.
        build || exit $?
 
+       # Convert GeoIP2 to lagacy.
+       build_legacy || exit $?
        return 0
+
+       # Remove temporary files.
+       cleanup || exit $?
 }
 
 # Run the main function.