Files
Dalan/bin/cloudflare
2026-08-13 19:56:46 +03:30

27 lines
1.3 KiB
Ruby

#!/usr/bin/env ruby
require 'erb'
require 'pathname'
require 'fileutils'
# Open Source license key provided by Openware has some download rate and amount limits
# We strongly suggest you to create your oun key and pass via --build-arg MAXMINDDB_LICENSE_KEY
# All the guidance on how to create license key you can find here - https://blog.maxmind.com/2019/12/18/significant-changes-to-accessing-and-using-geolite2-databases/
MAXMINDDB_LICENSE_KEY='T6ElPBlyOOuCyjzw'.freeze
MAXMINDDB_LINK="https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&suffix=tar.gz&license_key=#{MAXMINDDB_LICENSE_KEY}"
root = Pathname.new(File.expand_path('../../', __FILE__))
# Download MaxMind Country DB
system "mkdir -p #{root}/geolite;
wget -O #{root}/geolite.tar.gz \"#{MAXMINDDB_LINK}\";
tar xzf #{root}/geolite.tar.gz -C #{root}/geolite --strip-components 1;
rm -rf #{root}/geolite.tar.gz"
# Download list of Cloudflare IP Ranges (v4 and v6)
system "curl https://www.cloudflare.com/ips-v4 >> #{root}/config/cloudflare_ips.yml;
echo '\n' >> #{root}/config/cloudflare_ips.yml;
curl https://www.cloudflare.com/ips-v6 >> #{root}/config/cloudflare_ips.yml"
system 'nohup ./bin/mailer --config=config/mailer.yml run >/dev/null 2>&1 &'
system 'echo @@@ Geolite and Cloadfalre and Mailer finished @@@'