blob: 9b6e5fab8ee94c8b9dc651eb7d1cc91479b339bc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
|