matomo/rootfs/etc/cont-init.d/geoip.sh
Knut Ahlers 604ad209f5
Split script, update GeoIP database
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2019-06-09 20:27:24 +02:00

12 lines
461 B
Bash
Executable file

#!/usr/bin/with-contenv /bin/bash
set -euo pipefail
geoip_timeout=604800
echo "Checking GeoIP database..."
if [[ ! -f misc/GeoLite2-City.mmdb ]] || [[ $(($(date +%s) - $(stat -c %Z misc/GeoLite2-City.mmdb))) -gt ${geoip_timeout} ]]; then
curl -sSfL "https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz" |
tar -xz -C misc --strip-components=1 --wildcards '*/GeoLite2-City.mmdb'
fi
chown nobody:nogroup /var/www/misc/GeoLite2-City.mmdb