android_mt6572_jiabo/lineage/ansible/roles/mirrorbits/files/geoip-lite-update
2025-09-05 16:56:03 +08:00

68 lines
1.9 KiB
Bash

#!/bin/bash
# geoip-lite-update -- update geoip lite database(s).
# (c) 2008,2009,2010,2011,2012,2013,2014 poeml@cmdline.net
# Distribute under GPLv2 if it proves worthy.
# With added support for:
# - GeoLiteCityv6
# - GeoIPASNum
# - GeoIPASNumv6
# by Ludovic Fauvet <etix@videolan.org>
for i in curl wget ftp; do
if which $i &>/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
cd /data/mirrorbits/geoip
rm -f 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
rm -f 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
rm -f GeoLiteCityv6.dat.gz
$prg http://geolite.maxmind.com/download/geoip/database/GeoLiteCityv6-beta/GeoLiteCityv6.dat.gz
gunzip -c GeoLiteCityv6.dat.gz > GeoLiteCityv6.dat.updated.new
mv GeoLiteCityv6.dat.updated.new GeoLiteCityv6.dat.updated
rm -f GeoIPv6.dat.gz
$prg http://geolite.maxmind.com/download/geoip/database/GeoIPv6.dat.gz
gunzip -c GeoIPv6.dat.gz > GeoIPv6.dat.updated.new
mv GeoIPv6.dat.updated.new GeoIPv6.dat.updated
rm -f GeoIPASNum.dat.gz
$prg http://download.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz
gunzip -c GeoIPASNum.dat.gz > GeoIPASNum.dat.updated.new
mv GeoIPASNum.dat.updated.new GeoIPASNum.dat.updated
rm -f GeoIPASNumv6.dat.gz
$prg http://download.maxmind.com/download/geoip/database/asnum/GeoIPASNumv6.dat.gz
gunzip -c GeoIPASNumv6.dat.gz > GeoIPASNumv6.dat.updated.new
mv GeoIPASNumv6.dat.updated.new GeoIPASNumv6.dat.updated