mirror of
https://github.com/yann64/haikuports.git
synced 2026-04-23 04:00:05 +02:00
geoip: Add usage and trap for geoipupdate.sh.
This commit is contained in:
@@ -10,7 +10,7 @@ download GeoLite Legacy, GeoLite2 and GeoIP2 databases from MaxMind."
|
||||
HOMEPAGE="https://dev.maxmind.com/geoip/legacy/"
|
||||
COPYRIGHT="2002-2016 MaxMind, Inc."
|
||||
LICENSE="GNU LGPL v2.1"
|
||||
REVISION="1"
|
||||
REVISION="2"
|
||||
SOURCE_URI="https://github.com/maxmind/geoip-api-c/archive/v$portVersion.tar.gz"
|
||||
CHECKSUM_SHA256="05468adbb6bdbddc588ee6f0df990f47b1b24d278519c35d59f7a8058a2a9825"
|
||||
SOURCE_FILENAME="geoip-api-c-$portVersion.tar.gz"
|
||||
|
||||
@@ -1,20 +1,41 @@
|
||||
From f50fd9c259aee1fa429076ddafe0cfbbac43850f Mon Sep 17 00:00:00 2001
|
||||
From: fbrosson <fbrosson@localhost>
|
||||
Date: Fri, 25 Mar 2016 10:03:51 +0000
|
||||
Subject: Use timestamps to find out if a file is up-to-date.
|
||||
Subject: Use time stamps, add usage and use trap.
|
||||
|
||||
|
||||
diff --git a/geoipupdate-r5.sh b/geoipupdate-r5.sh
|
||||
index 484ff7e..da72a2d 100644
|
||||
--- a/geoipupdate-r5.sh
|
||||
+++ b/geoipupdate-r5.sh
|
||||
@@ -13,10 +13,20 @@ DATABASES="
|
||||
@@ -13,33 +13,94 @@ DATABASES="
|
||||
asnum/GeoIPASNumv6
|
||||
"
|
||||
|
||||
+# This script, when called without any option, will download all files you already have, if they are outdated.
|
||||
+# Use "-a" to force download all files unless they are up-to-date.
|
||||
+# Use "-f" to download all files, even if they are already up-to-to-date.
|
||||
+usage ()
|
||||
+{
|
||||
+ echo "Usage: $0 [OPTION]"
|
||||
+ echo "Update GeoIP/GeoLite files from the GeoIP mirror, MaxMind.com, if they already exist locally but are outdated."
|
||||
+ echo
|
||||
+ echo "Options:"
|
||||
+ echo " -a, --all Update existing files (if their time stamps are older than those on the mirror) and download all other files thay may be downloaded from the mirror with this script. If a file exists but is empty then the file is downloaded regardless of its time stamp."
|
||||
+ echo " -f, --force Download all files even if they are already up-to-date."
|
||||
+ echo " -h, --help Print this message and exit."
|
||||
+ echo
|
||||
+ echo "Files that this script can update or download:"
|
||||
+ echo " GeoIP.dat [similar to GeoLiteCountry.dat (1)]"
|
||||
+ echo " GeoIPv6.dat (2)"
|
||||
+ echo " GeoIPASNum.dat [similar to GeoLiteASNum.dat (1)]"
|
||||
+ echo " GeoIPASNumv6.dat"
|
||||
+ echo " GeoLiteCity.dat (2)"
|
||||
+ echo " GeoLiteCityv6.dat (2)"
|
||||
+ echo "(1) File which can only be updated with the geoipupdate utility."
|
||||
+ echo "(2) File which can also be updated with the geoipupdate utility."
|
||||
+ echo "Notes:"
|
||||
+ echo " Unlike geoipupdate, which sets the time stamps to the current time, this script sets the time stamps to those of the files on the GeoIP mirror."
|
||||
+ echo " Updates on the GeoIP mirror of the files this script downloads occur generally once per month, whereas updates of the files that geoipupdate downloads seem to occur more often."
|
||||
+ exit 1
|
||||
+}
|
||||
+
|
||||
if [ "${1}" = -f ] || [ "${1}" = --force ]; then
|
||||
force=true
|
||||
@@ -24,12 +45,19 @@ index 484ff7e..da72a2d 100644
|
||||
+ all=true
|
||||
+fi
|
||||
+
|
||||
+if [ "${1}" = -h ] || [ "${1}" = --help ]; then
|
||||
+ usage
|
||||
+fi
|
||||
+
|
||||
+[ "${force}" -o "${all}" ] && [ ! -d "${GEOIPDIR}" ] && mkdir -p "${GEOIPDIR}"
|
||||
+
|
||||
if [ -d "${GEOIPDIR}" ]; then
|
||||
cd $GEOIPDIR
|
||||
if [ -n "${DATABASES}" ]; then
|
||||
@@ -26,20 +36,44 @@ if [ -d "${GEOIPDIR}" ]; then
|
||||
TMPDIR=$(mktemp -d geoipupdate.XXXXXXXXXX)
|
||||
+ trap "rm -rf $GEOIPDIR/$TMPDIR" EXIT
|
||||
|
||||
echo "Updating GeoIP databases..."
|
||||
|
||||
for db in $DATABASES; do
|
||||
fname=$(basename $db)
|
||||
@@ -41,6 +69,7 @@ index 484ff7e..da72a2d 100644
|
||||
+ fi
|
||||
+ else
|
||||
+ if [ ! "${force}" -a ! "${all}" ]; then
|
||||
+ echo " skipped."
|
||||
+ continue
|
||||
+ fi
|
||||
+ fi
|
||||
|
||||
Reference in New Issue
Block a user