Skip to content

Instantly share code, notes, and snippets.

@jonathanroze
Last active December 6, 2021 23:17
Show Gist options
  • Save jonathanroze/0dc2e7fc7aebda24a8aa169266a6b0e2 to your computer and use it in GitHub Desktop.
Save jonathanroze/0dc2e7fc7aebda24a8aa169266a6b0e2 to your computer and use it in GitHub Desktop.
Script to install and update MaxMind geoipupdate in AWS ElasticBeanStalk (EBS)
// FILENAME: 01-update-maxmind-database.config
// LOCATION: <project>/.ebextensions/
// Script to setup geoipupdate (Maxmind) package on AWS ElasticBeanStalk (EBS)
// Don't forget to replace tar url by a version of your current architecture (and indeed, folder name)
// Replace <ACCOUNT_ID_TO_REPLACE> by your account Id
// Replace <LICENSE_KEY_TO_REPLACE> by your key
container_commands:
geoip:
command: |
#!/usr/bin/env bash
if [ ! -f "/usr/local/bin/geoipupdate" ]
then
system_arch=$(uname -m)
arch_target='arm64'
if [ $system_arch = 'x86_64']
then
arch_target='amd64'
fi
wget https://github.com/maxmind/geoipupdate/releases/download/v4.8.0/geoipupdate_4.8.0_linux_$arch_target.tar.gz
tar -xf geoipupdate_4.8.0_linux_$arch_target.tar.gz
cd geoipupdate_4.8.0_linux_$arch_target
sudo cp ./GeoIP.conf /usr/local/etc/GeoIP.conf
sudo sed -i 's/YOUR_ACCOUNT_ID_HERE/<ACCOUNT_ID_TO_REPLACE>/' /usr/local/etc/GeoIP.conf
sudo sed -i 's/YOUR_LICENSE_KEY_HERE/<LICENSE_KEY_TO_REPLACE>/' /usr/local/etc/GeoIP.conf
sudo mkdir /usr/local/share/GeoIP
sudo cp ./geoipupdate /usr/bin/geoipupdate
sudo geoipupdate
fi
// FILENAME: 02-cron-linux.config
// LOCATION: <project>/.ebextensions/
// IF YOU WANT TO SETUP A CRON
files:
"/etc/cron.d/update_geoip":
mode: "000644"
owner: root
group: root
content: |
MAILTO="[email protected]"
0 * * * * root sudo geoipupdate
commands:
remove_old_cron:
command: "rm -f /etc/cron.d/update_geoip.bak"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment