This repository has been archived by the owner on Jul 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgeoip.rb
53 lines (45 loc) · 1.56 KB
/
geoip.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
dep "geoip.bin" do
installs do
via :apt, "geoip-bin", "libgeoip-dev"
otherwise "geoip"
end
provides "geoiplookup", "geoiplookup6"
end
dep "geoip database", :source, :app_root do
# we download a cached copy of this database from our cloud files account to
# avoid hitting usage limits on the upstream server. Don't forget to occasionally
# update the cached version with a fresh file from http://dev.maxmind.com/geoip/legacy/geolite/
source.default!("http://c10736763.r63.cf2.rackcdn.com/GeoLiteCity.dat.gz")
app_root.default("~/current")
def local_path
app_root / "db" / File.basename(source.to_s.chomp(".gz"))
end
met? do
local_path.p.exists?
end
meet do
Babushka::Resource.get source do |download_path|
shell "mkdir -p #{local_path.parent}"
shell "gzip -dc #{download_path} > #{local_path}"
end
end
end
dep "as database", :source, :app_root do
# we download a cached copy of this database from our cloud files account to
# avoid hitting usage limits on the upstream server. Don't forget to occasionally
# update the cached version with a fresh file from http://dev.maxmind.com/geoip/legacy/geolite/
source.default!("http://c10736763.r63.cf2.rackcdn.com/GeoIPASNum.dat.gz")
app_root.default("~/current")
def local_path
app_root / "db" / File.basename(source.to_s.chomp(".gz"))
end
met? do
local_path.p.exists?
end
meet do
Babushka::Resource.get source do |download_path|
shell "mkdir -p #{local_path.parent}"
shell "gzip -dc #{download_path} > #{local_path}"
end
end
end