Skip to content

Commit

Permalink
geoip: update GeoIP.conf with AccountID for geoipupdate (#580)
Browse files Browse the repository at this point in the history
  • Loading branch information
msimerson committed Sep 9, 2024
1 parent 0a801f5 commit 25fcb5c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions provision/geoip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 25fcb5c

Please sign in to comment.