root/vidalia/tags/vidalia-0.0.15/pkg/build-geoip-cache.sh

Revision 1623, 1.5 kB (checked in by edmanm, 2 years ago)

r1645@adrastea: edmanm | 2007-01-29 21:15:11 -0500
Add a --notimestamp option to build a packaged geoip-cache without timestamps.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Id
Line 
1#!/bin/sh
2#
3#  $Id$
4#
5#  Vidalia is distributed under the following license:
6#
7#  Copyright (C) 2006,  Matt Edman, Justin Hipple
8#
9#  This program is free software; you can redistribute it and/or
10#  modify it under the terms of the GNU General Public License
11#  as published by the Free Software Foundation; either version 2
12#  of the License, or (at your option) any later version.
13#
14#  This program is distributed in the hope that it will be useful,
15#  but WITHOUT ANY WARRANTY; without even the implied warranty of
16#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17#  GNU General Public License for more details.
18#
19#  You should have received a copy of the GNU General Public License
20#  along with this program; if not, write to the Free Software
21#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
22#  02110-1301, USA.
23#################################################################
24
25DIRURL="http://tor.noreply.org/tor/status/all"
26GEOIPURL="http://geoip.vidalia-project.net/cgi-bin/geoip"
27CACHEFILE="geoip-cache"
28
29if [ "$1" == "-notimestamp" -o "$1" == "--notimestamp" ]; then
30  timestamp=""
31else
32  timestamp=":$(date +%s)"
33fi
34
35# Fetch a list of server IP addresses
36ipaddrs=$(wget -q -O - "$DIRURL" | awk '$1 == "r" { print $7 }' | sort | uniq | tr "\n" ",")
37
38# Get GeoIP information for each IP address
39geoips=$(wget -q -O - --post-data="ip=$ipaddrs" "$GEOIPURL")
40
41# Cache the GeoIP information with timestamps
42IFS=$'\n'
43rm -f $CACHEFILE
44for geoip in $geoips; do
45  echo "$geoip""$timestamp" >> "$CACHEFILE"
46done
Note: See TracBrowser for help on using the browser.