Skip to content

Commit

Permalink
geoip: update GeoIP.conf with AccountID for geoipupdate
Browse files Browse the repository at this point in the history
  • Loading branch information
msimerson committed May 15, 2024
1 parent 8460d98 commit fb55a92
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 fb55a92

Please sign in to comment.