From fb55a9240b5678840cc613d6fb893ad75a4e66b5 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Tue, 14 May 2024 17:30:49 -0700 Subject: [PATCH] geoip: update GeoIP.conf with AccountID for geoipupdate --- provision/geoip.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/provision/geoip.sh b/provision/geoip.sh index 62cfc64a..9adea1a4 100755 --- a/provision/geoip.sh +++ b/provision/geoip.sh @@ -13,6 +13,11 @@ preflight_check() { echo "ERROR: edit mail-toaster.conf and set MAXMIND_LICENSE_KEY" exit 1 fi + + if [ "$GEOIP_UPDATER" = "geoipupdate" ] && [ -z "$MAXMIND_ACCOUNT_ID" ]; then + echo "ERROR: edit mail-toaster.conf and set MAXMIND_ACCOUNT_ID" + exit 1 + fi } install_geoip_geoipupdate() @@ -77,6 +82,14 @@ configure_geoip() if [ -f "$ZFS_DATA_MNT/geoip/GeoIP.conf" ]; then tell_status "installing GeoIP.conf" cp "$ZFS_DATA_MNT/geoip/GeoIP.conf" "$STAGE_MNT/usr/local/etc" + else + sed -i '' \ + -e "/^AccountID/ s/YOUR_ACCOUNT_ID_HERE/$MAXMIND_ACCOUNT_ID/" \ + -e "/^LicenseKey/ s/YOUR_LICENSE_KEY_HERE/$MAXMIND_LICENSE_KEY/" \ + -e '/^EditionIDs/ s/GeoLite2-City/GeoLite2-City GeoLite2-ASN/' \ + -e '/^# DatabaseDirectory/ s/^# //' \ + -e '/^DatabaseDirectory/ s|/usr/local/share/GeoIP|/data/db|' \ + "$STAGE_MNT/usr/local/etc/GeoIP.conf" fi geoip_periodic