ports/net/ntopng/files/ntopng-geoip2update.sh.in
Guido Falsi 9d7e78cad2 - Update ntopng to latest upstream snapshot
- Enable again IP geolocation by using the maxminddb. Rename script
  which downloads the data to reflect the change
2019-01-15 18:16:34 +00:00

44 lines
802 B
Bash

#!/bin/sh
set -eu
mkdir -p "%%DATADIR%%/httpdocs/geoip"
TEMPDIR="$(mktemp -d "%%DATADIR%%/httpdocs/geoip/MMDB-XXXXXX")"
trap 'rc=$? ; set +e ; rm -rf "'"$TEMPDIR"'" ; exit $rc' 0
cd "${TEMPDIR}"
# arguments:
# $1 URL
# $2 filename
_fetchextract() {
url="$1"
file="$(basename "${url}")"
if fetch "${url}"; then
tar xzf "${file}"
else
echo "${file} download failed"
return 1
fi
return 0
}
echo Fetching GeoLite2-City
_fetchextract 'https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz'
echo Fetching GeoLite2-ASN
_fetchextract 'https://geolite.maxmind.com/download/geoip/database/GeoLite2-ASN.tar.gz'
mv GeoLite2-*/*.mmdb %%DATADIR%%/httpdocs/geoip
cd %%DATADIR%%/httpdocs/geoip
rm -rf "${TEMPDIR}"
chown root:wheel *.mmdb
chmod 444 *.mmdb
trap - 0
return 0