From f785779b1bb16f8315be35d36ab57d17ed8e5560 Mon Sep 17 00:00:00 2001 From: Guido Falsi Date: Fri, 28 Jul 2023 11:45:10 +0200 Subject: [PATCH] net/ntopng: Fix GeoIP data download script MaxMind now requires a free account with an API key to access its APIs to download the GeoLite2 datanases. Update scripts to adapt to new API interface and use API key provided via %%LOCALBASE%%/etc/GeoIP.conf Update pkg-message to provide this information. Reported by: thedoctorjtd <76110609+thedoctorjtd@users.noreply.github.com> Obtained from: https://github.com/freebsd/freebsd-ports/pull/182 --- net/ntopng/Makefile | 3 ++- net/ntopng/files/ntopng-geoip2update.sh.in | 7 +++++-- net/ntopng/{pkg-message => files/pkg-message.in} | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) rename net/ntopng/{pkg-message => files/pkg-message.in} (83%) diff --git a/net/ntopng/Makefile b/net/ntopng/Makefile index 64e825b299765..8d7ee91de32f6 100644 --- a/net/ntopng/Makefile +++ b/net/ntopng/Makefile @@ -1,5 +1,6 @@ PORTNAME= ntopng PORTVERSION= 5.6.d20230531 +PORTREVISION= 1 PORTEPOCH= 1 CATEGORIES= net @@ -27,7 +28,7 @@ BUILD_DEPENDS= bash:shells/bash USES= autoreconf compiler:c++11-lang cpe gmake ldap libtool localbase \ lua:54 mysql pathfix pkgconfig shebangfix sqlite ssl -SUB_FILES= ntopng-geoip2update.sh pkg-deinstall +SUB_FILES= ntopng-geoip2update.sh pkg-deinstall pkg-message SHEBANG_FILES= httpdocs/misc/ntopng-add-user.sh \ httpdocs/misc/ntopng-utils-manage-config.in GNU_CONFIGURE= yes diff --git a/net/ntopng/files/ntopng-geoip2update.sh.in b/net/ntopng/files/ntopng-geoip2update.sh.in index 1b0302d67856e..3d3404647abe9 100644 --- a/net/ntopng/files/ntopng-geoip2update.sh.in +++ b/net/ntopng/files/ntopng-geoip2update.sh.in @@ -25,11 +25,14 @@ _fetchextract() { return 0 } +# Get the license key from the GeoIP.conf file +LICENSE_KEY=$(awk -F ' ' '/^#/ {next} $1=="LicenseKey" {print $2}' %%LOCALBASE%%/etc/GeoIP.conf) + echo Fetching GeoLite2-City -_fetchextract 'https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz' +_fetchextract "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=${LICENSE_KEY}&suffix=tar.gz" echo Fetching GeoLite2-ASN -_fetchextract 'https://geolite.maxmind.com/download/geoip/database/GeoLite2-ASN.tar.gz' +_fetchextract "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-ASN&license_key=${LICENSE_KEY}&suffix=tar.gz" mv GeoLite2-*/*.mmdb %%DATADIR%%/httpdocs/geoip diff --git a/net/ntopng/pkg-message b/net/ntopng/files/pkg-message.in similarity index 83% rename from net/ntopng/pkg-message rename to net/ntopng/files/pkg-message.in index f3c46a612b400..02cc4fc9be53d 100644 --- a/net/ntopng/pkg-message +++ b/net/ntopng/files/pkg-message.in @@ -10,7 +10,8 @@ remote one. ntopng supports IP geolocation, to enable this you should use the ntopng-geoip2update.sh script to update the maxminddb geolocation -data to the latest version. +data to the latest version. This script requires a maxmind.com +account API key configured in %%LOCALBASE%%/etc/GeoIP.conf to work. To pass a configuration file to ntopng, which overrides any command line arguments, add something like the following to rc.conf: