You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/dev-libs/geoip/files/geoipupdate-r6.sh

47 lines
1.1 KiB

#!/bin/sh
GEOIP_MIRROR="https://download.maxmind.com/download/geoip/database"
GEOIPDIR=@PREFIX@/usr/share/GeoIP
TMPDIR=
DATABASES="
GeoIPv6
GeoLiteCity
GeoLiteCityv6-beta/GeoLiteCityv6
GeoLiteCountry/GeoIP
asnum/GeoIPASNum
asnum/GeoIPASNumv6
"
if [ "${1}" = -f ] || [ "${1}" = --force ]; then
force=true
fi
if [ -d "${GEOIPDIR}" ]; then
cd $GEOIPDIR
if [ -n "${DATABASES}" ]; then
TMPDIR=$(mktemp -d geoipupdate.XXXXXXXXXX)
echo "Updating GeoIP databases..."
for db in $DATABASES; do
fname=$(basename $db)
if [ -f "${GEOIPDIR}/${fname}.dat" ] || [ ${force} ]; then
wget --no-verbose -t 3 -T 60 \
"${GEOIP_MIRROR}/${db}.dat.gz" \
-O "${TMPDIR}/${fname}.dat.gz"
if [ $? -eq 0 ]; then
gunzip -fdc "${TMPDIR}/${fname}.dat.gz" > "${TMPDIR}/${fname}.dat"
mv "${TMPDIR}/${fname}.dat" "${GEOIPDIR}/${fname}.dat"
chmod 0644 "${GEOIPDIR}/${fname}.dat"
case ${fname} in
GeoLite*) ln -sf ${fname}.dat `echo ${fname} | sed 's/GeoLite/GeoIP/'`.dat ;;
esac
fi
fi
done
[ -d "${TMPDIR}" ] && rm -rf $TMPDIR
fi
fi