flowtop: make function nested
[netsniff-ng.git] / scripts / geoip-database-update
blob1a19c7c618bbf16fa679518c9c74cecd5b7fe9c0
1 #!/bin/sh
2 # (C) Ludovico Cavedon <cavedon@debian.org>
4 GEOIP_URL="http://geolite.maxmind.com/download/geoip/database/"
6 GEOLITE_COUNTRY_PATH="GeoLiteCountry/"
7 GEOLITE_COUNTRY_FILE="GeoIP.dat.gz"
9 GEOLITE_COUNTRY_IPV6_PATH=""
10 GEOLITE_COUNTRY_IPV6_FILE="GeoIPv6.dat.gz"
12 GEOLITE_CITY_PATH=""
13 GEOLITE_CITY_FILE="GeoLiteCity.dat.gz"
15 GEOLITE_CITY_IPV6_PATH="GeoLiteCityv6-beta/"
16 GEOLITE_CITY_IPV6_FILE="GeoLiteCityv6.dat.gz"
18 GEOLITE_ASNUM_PATH="asnum/"
19 GEOLITE_ASNUM_FILE="GeoIPASNum.dat.gz"
21 FAILED=0
23 for url in \
24 "$GEOIP_URL$GEOLITE_COUNTRY_PATH$GEOLITE_COUNTRY_FILE" \
25 "$GEOIP_URL$GEOLITE_COUNTRY_IPV6_PATH$GEOLITE_COUNTRY_IPV6_FILE" \
26 "$GEOIP_URL$GEOLITE_CITY_PATH$GEOLITE_CITY_FILE" \
27 "$GEOIP_URL$GEOLITE_CITY_IPV6_PATH$GEOLITE_CITY_IPV6_FILE" \
28 "$GEOIP_URL$GEOLITE_ASNUM_PATH$GEOLITE_ASNUM_FILE"
30 echo "Downloading $url"
32 FILE=$(basename $url)
34 rm -f /usr/share/GeoIP/$FILE
35 /usr/bin/wget -t3 -T15 -P /usr/share/GeoIP/ "$url" && \
36 /bin/gunzip -f /usr/share/GeoIP/$FILE
37 if [ "$?" != "0" ]
38 then
39 FAILED=1
40 echo "Failed to download and decompress $FILE"
42 done
44 ln -s /usr/share/GeoIP/GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat
45 ln -s /usr/share/GeoIP/GeoLiteCityv6.dat /usr/share/GeoIP/GeoIPCityv6.dat
46 ln -s /usr/share/GeoIP/ /usr/local/share/
48 exit $FAILED