Skip to content

Instantly share code, notes, and snippets.

@laurynas
Created November 4, 2010 12:15
Show Gist options
  • Save laurynas/662373 to your computer and use it in GitHub Desktop.
Save laurynas/662373 to your computer and use it in GitHub Desktop.
Fetch GeoLite Cities database from MaxMind
#!/bin/sh
#
# Update GeoLite Cities database from MaxMind
# (C) 2010 Laurynas Butkus laurynas.butkus at gmail.com
#
TMP=/tmp
TARGET_DIR=/usr/local/share/GeoIP
cd $TMP
# download database
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
if [ ! -f GeoLiteCity.dat.gz ]; then
echo "$TMP/GeoLiteCity.dat.gz not found"
exit 1
fi
gzip -d GeoLiteCity.dat.gz
if [ ! -f GeoLiteCity.dat ]; then
echo "$TMP/GeoLiteCity.dat not found"
exit 1
fi
mv GeoLiteCity.dat $TARGET_DIR/GeoLiteCity.dat.new
rm $TARGET_DIR/GeoLiteCity.dat
mv $TARGET_DIR/GeoLiteCity.dat.new $TARGET_DIR/GeoLiteCity.dat
echo "GeoLite cities database updated."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment