#!/bin/sh
set -e

CONFIG_PATH=/data/options.json

GEOIPUPDATE_DB_DIR=$(jq --raw-output '.GEOIPUPDATE_DB_DIR // empty' $CONFIG_PATH)
echo "GEOIPUPDATE_DB_DIR: ${GEOIPUPDATE_DB_DIR}"
export GEOIPUPDATE_DB_DIR="${GEOIPUPDATE_DB_DIR}"

GEOIPUPDATE_ACCOUNT_ID=$(jq --raw-output '.GEOIPUPDATE_ACCOUNT_ID // empty' $CONFIG_PATH)
echo "GEOIPUPDATE_ACCOUNT_ID: ${GEOIPUPDATE_ACCOUNT_ID}"
export GEOIPUPDATE_ACCOUNT_ID="${GEOIPUPDATE_ACCOUNT_ID}"

GEOIPUPDATE_LICENSE_KEY=$(jq --raw-output '.GEOIPUPDATE_LICENSE_KEY // empty' $CONFIG_PATH)
echo "GEOIPUPDATE_LICENSE_KEY: ${GEOIPUPDATE_LICENSE_KEY}"
export GEOIPUPDATE_LICENSE_KEY="${GEOIPUPDATE_LICENSE_KEY}"

GEOIPUPDATE_EDITION_IDS=$(jq --raw-output '.GEOIPUPDATE_EDITION_IDS // empty' $CONFIG_PATH)
echo "GEOIPUPDATE_EDITION_IDS: ${GEOIPUPDATE_EDITION_IDS}"
export GEOIPUPDATE_EDITION_IDS="${GEOIPUPDATE_EDITION_IDS}"

GEOIPUPDATE_FREQUENCY=$(jq --raw-output '.GEOIPUPDATE_FREQUENCY // empty' $CONFIG_PATH)
echo "GEOIPUPDATE_FREQUENCY: ${GEOIPUPDATE_FREQUENCY}"
export GEOIPUPDATE_FREQUENCY="${GEOIPUPDATE_FREQUENCY}"

/usr/bin/entry.sh
