aboutsummaryrefslogtreecommitdiffstats
path: root/main/libmaxminddb/libmaxminddb.cron
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2013-11-14 15:33:16 +0200
committerTimo Teräs <timo.teras@iki.fi>2013-11-14 15:33:16 +0200
commit6fd658a9994c9d1d1aa3447bddc8c1a15744e766 (patch)
tree150cfd517c52015f1081c23f2fb2092cbd4dbc4c /main/libmaxminddb/libmaxminddb.cron
parent3df7efd33ac16ad57c9d2c2e8cb7b29576edd6fa (diff)
downloadaports-6fd658a9994c9d1d1aa3447bddc8c1a15744e766.tar.gz
aports-6fd658a9994c9d1d1aa3447bddc8c1a15744e766.tar.bz2
aports-6fd658a9994c9d1d1aa3447bddc8c1a15744e766.tar.xz
main/libmaxminddb: new aport
Maxmind GeoIP2 database library https://github.com/maxmind/$pkgname
Diffstat (limited to 'main/libmaxminddb/libmaxminddb.cron')
-rwxr-xr-xmain/libmaxminddb/libmaxminddb.cron22
1 files changed, 22 insertions, 0 deletions
diff --git a/main/libmaxminddb/libmaxminddb.cron b/main/libmaxminddb/libmaxminddb.cron
new file mode 100755
index 0000000000..9b6e5fab8e
--- /dev/null
+++ b/main/libmaxminddb/libmaxminddb.cron
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+. /etc/conf.d/libmaxminddb
+
+set -e
+
+[ -z "$MAXMINDDB_FILES" ] && MAXMINDDB_FILES="GeoLite2-City.mmdb"
+[ -z "$MAXMINDDB_URL" ] && MAXMINDDB_URL="http://geolite.maxmind.com/download/geoip/database"
+[ -z "$MAXMINDDB_LIBDIR" ] && MAXMINDDB_LIBDIR="/var/lib/libmaxminddb"
+
+clean_up() {
+ [ -n "$TMPDIR" ] && rm -rf "$TMPDIR"
+}
+trap clean_up EXIT SIGTERM SIGINT SIGQUIT
+
+TMPDIR="$(mktemp -d)"
+for filename in $MAXMINDDB_FILES; do
+ curl --silent "$MAXMINDDB_URL/$filename.gz" -o "$TMPDIR/$filename.gz"
+ gunzip "$TMPDIR/$filename.gz"
+ mv "$TMPDIR/$filename" "$MAXMINDDB_LIBDIR"
+done
+exit 0