Files
T
2023-05-18 15:07:07 -04:00

32 lines
1.3 KiB
Plaintext
Executable File

#!/usr/bin/with-contenv bash
echo "Applying the maxmind mod..."
# create GeoIP2 folder symlink
mkdir -p \
/config/geoip2db
if [[ -d /var/lib/libmaxminddb ]] && [[ ! -L /var/lib/libmaxminddb ]]; then
rm -rf /var/lib/libmaxminddb
fi
if [[ ! -d /var/lib/libmaxminddb ]]; then
ln -s /config/geoip2db /var/lib/libmaxminddb
fi
# check GeoIP2 database
if [[ -n "$MAXMINDDB_LICENSE_KEY" ]]; then
sed -i "s|.*MAXMINDDB_LICENSE_KEY.*|MAXMINDDB_LICENSE_KEY=\"${MAXMINDDB_LICENSE_KEY}\"|g" /etc/libmaxminddb.cron.conf
if [[ ! -f /var/lib/libmaxminddb/GeoLite2-City.mmdb ]]; then
echo "Downloading GeoIP2 City database."
/etc/periodic/weekly/libmaxminddb
fi
elif [[ -f /var/lib/libmaxminddb/GeoLite2-City.mmdb ]]; then
echo -e "Currently using the user provided GeoLite2-City.mmdb.\nIf you want to enable weekly auto-updates of the database, retrieve a free license key from MaxMind,\nand add a new env variable \"MAXMINDDB_LICENSE_KEY\", set to your license key."
else
echo -e "Starting 2019/12/30, GeoIP2 databases require personal license key to download. Please retrieve a free license key from MaxMind,\nand add a new env variable \"MAXMINDDB_LICENSE_KEY\", set to your license key."
fi
if [[ ! -f /config/nginx/maxmind.conf ]]; then
cp /defaults/maxmind.conf /config/nginx/maxmind.conf
fi
echo "Applied the maxmind mod"