From 03f6bff777021f410e7cba5501b14893e336ee80 Mon Sep 17 00:00:00 2001
From: Adam Weinberger <adamw@FreeBSD.org>
Date: Fri, 8 May 2015 17:19:04 +0000
Subject: Support fetching the GeoLite City and GeoLite ASN databases.

Requested by:	Scott Loga
---
 net/GeoIP/Makefile                |  2 +-
 net/GeoIP/files/geoipupdate.sh.in | 22 +++++++++++++++++++---
 2 files changed, 20 insertions(+), 4 deletions(-)

(limited to 'net')

diff --git a/net/GeoIP/Makefile b/net/GeoIP/Makefile
index 88d0249ffa01..b1060b681874 100644
--- a/net/GeoIP/Makefile
+++ b/net/GeoIP/Makefile
@@ -4,7 +4,7 @@
 PORTNAME=	GeoIP
 PORTVERSION=	1.6.5
 DISTVERSIONPREFIX=	v
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	net geography
 
 MAINTAINER=	adamw@FreeBSD.org
diff --git a/net/GeoIP/files/geoipupdate.sh.in b/net/GeoIP/files/geoipupdate.sh.in
index 7fb8a43d4f86..1099a56c9d8f 100644
--- a/net/GeoIP/files/geoipupdate.sh.in
+++ b/net/GeoIP/files/geoipupdate.sh.in
@@ -1,5 +1,15 @@
 #!/bin/sh
 
+# You can set the following environment variables:
+#
+# GEOIP_DB_SERVER: The default download server is geolite.maxmind.com
+# GEOIP_FETCH_CITY: If set (to anything), download the GeoLite City DB
+# GEOIP_FETCH_ASN: If sset, download the GeoIP ASN DB
+
+GEOIP_DB_SERVER=${GEOIP_DB_SERVER:=geolite.maxmind.com}
+GEOIP_FETCH_CITY=${GEOIP_FETCH_CITY:=}
+GEOIP_FETCH_ASN=${GEOIP_FETCH_ASN:=}
+
 set -eu
 echo Fetching GeoIP.dat and GeoIPv6.dat...
 
@@ -27,8 +37,14 @@ _fetch() {
     return 0
 }
 
-GEOIP_DB_SERVER=${GEOIP_DB_SERVER:=geolite.maxmind.com}
-
 _fetch "http://${GEOIP_DB_SERVER}/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz" GeoIP.dat
-
 _fetch "http://${GEOIP_DB_SERVER}/download/geoip/database/GeoIPv6.dat.gz" GeoIPv6.dat
+
+if [ -n "$GEOIP_FETCH_CITY" ]; then
+	_fetch "http://${GEOIP_DB_SERVER}/download/geoip/database/GeoLiteCity.dat.gz" GeoLiteCity.dat
+	_fetch "http://${GEOIP_DB_SERVER}/download/geoip/database/GeoLiteCityv6-beta/GeoLiteCityv6.dat.gz" GeoLiteCityv6.dat
+fi
+if [ -n "$GEOIP_FETCH_ASN" ]; then
+	_fetch "http://${GEOIP_DB_SERVER}/download/geoip/database/asnum/GeoIPASNum.dat.gz" GeoIPASNum.dat
+	_fetch "http://${GEOIP_DB_SERVER}/download/geoip/database/asnum/GeoIPASNumv6.dat.gz" GeoIPASNumv6.dat
+fi
-- 
cgit debian/1.2.3+git2.25.1-1-2-gaceb0