Skip to content

Commit

Permalink
net/ntopng: Fix GeoIP data download script
Browse files Browse the repository at this point in the history
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:	#182
  • Loading branch information
madpilot78 committed Jul 28, 2023
1 parent 959ab8d commit f785779
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion net/ntopng/Makefile
@@ -1,5 +1,6 @@
PORTNAME= ntopng
PORTVERSION= 5.6.d20230531
PORTREVISION= 1
PORTEPOCH= 1
CATEGORIES= net

Expand Down Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions net/ntopng/files/ntopng-geoip2update.sh.in
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion net/ntopng/pkg-message → net/ntopng/files/pkg-message.in
Expand Up @@ -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:
Expand Down

0 comments on commit f785779

Please sign in to comment.