Initial ansible onboard
This commit is contained in:
+33
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
set -e -o pipefail
|
||||
|
||||
if ! command -v podman &> /dev/null
|
||||
then
|
||||
echo "'podman' could not be found! please install"
|
||||
exit
|
||||
fi
|
||||
|
||||
if ! command -v zip &> /dev/null
|
||||
then
|
||||
echo "'zip' could not be found! please install"
|
||||
exit
|
||||
fi
|
||||
|
||||
LICENSE_KEY="F2ACVoZdaomd4Rse"
|
||||
WORKFOLDER=$(mktemp -d)
|
||||
GOVERSION="golang:1.16-stretch"
|
||||
REPO="github.com/andyjack/geoip2-haproxy-ranges"
|
||||
|
||||
# get geoip2-haproxy-ranges
|
||||
git clone https://${REPO} ${WORKFOLDER}
|
||||
|
||||
# Download maxmind legacy csv and process
|
||||
wget "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&license_key=${LICENSE_KEY}&suffix=tar.gz" -O /tmp/GeoLite2-Country.tar.gz
|
||||
tar -C ${WORKFOLDER} -xvzf /tmp/GeoLite2-Country.tar.gz --strip-components=1
|
||||
rm /tmp/GeoLite2-Country.tar.gz
|
||||
|
||||
# Convert databases
|
||||
podman run -it --rm -v ${WORKFOLDER}:/usr/src/app -w /usr/src/app ${GOVERSION} /bin/bash -c "go mod init ${REPO}; go mod tidy; go run . --db GeoLite2-Country.mmdb --destDir db"
|
||||
|
||||
# Store locally
|
||||
cp ${WORKFOLDER}/db/*.txt ../files/haproxy_country_acls
|
||||
Reference in New Issue
Block a user