Adam,

My name is Scott Loga and I am currently using the Port net/GeoIP-1.6.5_1 in 
order to utilize geographic IP information with in AWStats.  Within the port 
GeoIP-1.6.5_1 there are several files, one of which is an update script, 
geoipupdate.sh.in, for updating the GeoIP.dat and GeoIPv6.dat files.  

As useful as this script is, it lacks the ability to update the GeoLiteCity.dat 
file which, like the GeoIP.dat and GeoIPv6.dat files, are part of MaxMind.com’s 
open source data.

I have included a modification to the script in the attached file and have 
tested it.  

If it is suitable for inclusion to the geoipupdate.sh.in script, I would 
appreciate it if you would kindly commit the change.

Regards,

Scott Loga

#!/bin/sh

set -eu
echo Fetching GeoIP.dat, GeoIPv6.dat, and GeoLiteCity.dat…

# arguments:
# $1 URL
# $2 output file name
_fetch() {
    url="$1"
    out="$2"
    TEMPDIR="$(mktemp -d '%%DATADIR%%/GeoIPupdate.XXXXXX')"
    trap 'rc=$? ; set +e ; rm -rf "'"$TEMPDIR"'" ; exit $rc' 0
    if fetch -o "$TEMPDIR/$out.gz" "$url"; then
        gunzip "$TEMPDIR/$out.gz"
        chmod 444 "$TEMPDIR/$out"
        if ! mv -f "$TEMPDIR/$out" "%%DATADIR%%"/"$2"; then
            echo "Unable to replace %%DATADIR%%/$2"
            return 2
        fi
    else
        echo "$2 download failed"
        return 1
    fi
    rmdir "$TEMPDIR"
    trap - 0
    return 0
}

GEOIP_DB_SERVER=${GEOIP_DB_SERVER:=geolite.maxmind.com}

_fetch 
"http://${GEOIP_DB_SERVER}/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz"; 
GeoIP.dat

_fetch "http://${GEOIP_DB_SERVER}/download/geoip/database/GeoIPv6.dat.gz"; 
GeoIPv6.dat

_fetch "http://${GEOIP_DB_SERVER}/download/geoip/database/GeoLiteCity.dat.gz"; 
GeoLiteCity.dat
_______________________________________________
freebsd-ports@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "freebsd-ports-unsubscr...@freebsd.org"

Reply via email to