#!/bin/bash

# geoip-lite-update -- update geoip lite database(s).
# (c) 2008,2009,2010 poeml@cmdline.net
# Distribute under GPLv2 if it proves worthy.


set -e

# GeoIP data used to be in /usr/share/GeoIP in the openSUSE package, and was moved later.
# try the old location first - if it's present, it means that the user had his own
# updated database there
cd /usr/share/GeoIP/ 2>/dev/null || cd /var/lib/GeoIP

ftp http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
gunzip -c GeoIP.dat.gz > GeoIP.dat.updated.new
mv GeoIP.dat.updated.new GeoIP.dat.updated

ftp http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gunzip -c GeoLiteCity.dat.gz > GeoLiteCity.dat.updated.new
mv GeoLiteCity.dat.updated.new GeoLiteCity.dat.updated

rcapache2 reload
