[mirrorbrain-commits] r8170 - /trunk/tools/geoip-lite-update

From: <poeml_at_mirrorbrain.org>
Date: Sun, 26 Sep 2010 12:23:24 -0000
Author: poeml
Date: Sun Sep 26 14:23:23 2010
New Revision: 8170

URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain?rev=8170&view=rev
Log:
tools/geoip-lite-update:
- make it work on Ubuntu by not using the "ftp" command, which is not capable
  of doing HTTP, preferring curl or wget if available.

Modified:
    trunk/tools/geoip-lite-update

Modified: trunk/tools/geoip-lite-update
URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain/trunk/tools/geoip-lite-update?rev=8170&r1=8169&r2=8170&view=diff
==============================================================================
--- trunk/tools/geoip-lite-update (original)
+++ trunk/tools/geoip-lite-update Sun Sep 26 14:23:23 2010
_at_@ -3,6 +3,27 @@
 # geoip-lite-update -- update geoip lite database(s).
 # (c) 2008,2009,2010 poeml_at_cmdline.net
 # Distribute under GPLv2 if it proves worthy.
+
+for i in curl wget ftp; do
+	if which $i 2>/dev/null; then 
+		prg=$i
+		break
+	fi
+done
+
+if [ -z "$prg" ]; then
+	echo cannot find a tool to download, like curl or wget >&2
+	exit 1
+fi
+
+case $prg in 
+curl)
+	prg="curl -s -O"
+	;;
+wget)
+	prg="wget --quiet"
+	;;
+esac
 
 
 set -e
_at_@ -12,12 +33,12 @@
 # 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
+$prg 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
+$prg 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
+/etc/init.d/apache2 reload




_______________________________________________
mirrorbrain-commits mailing list
Archive: http://mirrorbrain.org/archive/mirrorbrain-commits/

Note: To remove yourself from this list, send a mail with the content
 	unsubscribe
to the address mirrorbrain-commits-request_at_mirrorbrain.org
Received on Sun Sep 26 2010 - 12:23:27 GMT

This archive was generated by hypermail 2.3.0 : Mon Feb 20 2012 - 23:47:04 GMT