Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: modules/statsmaster/files/cron_geoipdb_update.py

Issue 5316783485485056: Issue 670 - Use GeoIP City database for AWStats (Closed)
Patch Set: Created June 17, 2014, 3:06 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | modules/statsmaster/manifests/init.pp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/sh 1 #!/usr/bin/env python
2 2
3 # 3 import urllib
4 # paranoia settings 4 import zlib
5 # 5 from StringIO import StringIO
Wladimir Palant 2014/06/17 15:16:21 I already removed that import locally, it's a left
6 umask 022
7 6
8 PATH=/sbin:/bin:/usr/sbin:/usr/bin 7 downloads = {
9 export PATH 8 '/usr/share/GeoIP/GeoIP.dat': 'http://geolite.maxmind.com/download/geoip/datab ase/GeoLiteCountry/GeoIP.dat.gz',
9 '/usr/share/GeoIP/GeoIPv6.dat': 'http://geolite.maxmind.com/download/geoip/dat abase/GeoIPv6.dat.gz',
10 10
11 wget -q http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP. dat.gz -O /tmp/GeoIP.dat.gz 11 '/usr/share/GeoIP/GeoIPCity.dat': 'http://geolite.maxmind.com/download/geoip/d atabase/GeoLiteCity.dat.gz',
12 test -e /tmp/GeoIP.dat.gz && gzip -fd /tmp/GeoIP.dat.gz 12 '/usr/share/GeoIP/GeoIPCityv6.dat': 'http://geolite.maxmind.com/download/geoip /database/GeoLiteCityv6-beta/GeoLiteCityv6.dat.gz',
13 test -e /tmp/GeoIP.dat && mv -f /tmp/GeoIP.dat /usr/share/GeoIP/GeoIP.dat 13 }
14 14
15 wget -q http://geolite.maxmind.com/download/geoip/database/GeoIPv6.dat.gz -O /tm p/GeoIPv6.dat.gz 15 for dest, source in downloads.iteritems():
16 test -e /tmp/GeoIPv6.dat.gz && gzip -fd /tmp/GeoIPv6.dat.gz 16 data = urllib.urlopen(source).read()
17 test -e /tmp/GeoIPv6.dat && mv -f /tmp/GeoIPv6.dat /usr/share/GeoIP/GeoIPv6.dat 17 with open(dest, "wb") as f:
18 # wbit parameter value isn't properly documented, see https://stackoverflow. com/a/22310760/785541
19 f.write(zlib.decompress(data, zlib.MAX_WBITS | 16))
OLDNEW
« no previous file with comments | « no previous file | modules/statsmaster/manifests/init.pp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld