aports/main/libmaxminddb/libmaxminddb.cron
TBK ab9928705f main/libmaxminddb: remove openrc subpackage, rename cron configuration
In this instance the .confd file is not related to openrc, but used by the cron script.

Lets move it out of the path of OpenRC and place it somewhere else
2021-02-28 08:38:51 +00:00

25 lines
924 B
Bash
Executable File

#!/bin/sh
. /etc/libmaxminddb.cron.conf
set -e
[ -z "$MAXMINDDB_FILES" ] && MAXMINDDB_FILES="GeoLite2-City.mmdb"
[ -z "$MAXMINDDB_URL" ] && MAXMINDDB_URL="https://download.maxmind.com/app/geoip_download"
[ -z "$MAXMINDDB_LIBDIR" ] && MAXMINDDB_LIBDIR="/var/lib/libmaxminddb"
[ -z "$MAXMINDDB_LICENSE_KEY" ] && { echo "No MaxMind license key found; exiting. Please enter your license key into /etc/libmaxminddb.cron.conf"; exit 1; }
clean_up() {
[ -n "$TMPDIR" ] && rm -rf "$TMPDIR"
}
trap clean_up EXIT TERM INT QUIT
TMPDIR="$(mktemp -d)"
for filename in $MAXMINDDB_FILES; do
EDITION_ID=$(echo "${filename}" | sed 's/\.mmdb$//')
curl --silent "${MAXMINDDB_URL}?edition_id=${EDITION_ID}&license_key=${MAXMINDDB_LICENSE_KEY}&suffix=tar.gz" -o "$TMPDIR/${filename}.tar.gz"
tar xf "$TMPDIR/${filename}.tar.gz" -C "$TMPDIR" --strip-components=1
mv "$TMPDIR/$filename" "$MAXMINDDB_LIBDIR"
done
exit 0