default[:geoipupdate][:account] = "149244"
default[:geoipupdate][:editions] = %w[GeoLite2-ASN GeoLite2-City GeoLite2-Country]
+default[:geoipupdate][:directory] = if node[:lsb][:release].to_f < 22.04
+ "/usr/share/GeoIP"
+ else
+ "/var/lib/GeoIP"
+ end
default[:apt][:sources] |= ["maxmind"]
command "geoipupdate"
user "root"
group "root"
- not_if { kitchen? || node[:geoipupdate][:editions].all? { |edition| ::File.exist?("/usr/share/GeoIP/#{edition}.mmdb") } }
+ not_if { kitchen? || node[:geoipupdate][:editions].all? { |edition| ::File.exist?("#{node[:geoipupdate][:directory]}/#{edition}.mmdb") } }
end
systemd_service "geoipupdate" do
private_devices true
protect_system "strict"
protect_home true
- read_write_paths %w[/usr/share/GeoIP /var/lib/GeoIP]
+ read_write_paths node[:geoipupdate][:directory]
end
systemd_timer "geoipupdate" do
version = node[:piwik][:version]
+geoip_directory = node[:geoipupdate][:directory]
+
directory "/opt/piwik-#{version}" do
owner "root"
group "root"
end
link "/opt/piwik-#{version}/piwik/misc/GeoLite2-ASN.mmdb" do
- to "/usr/share/GeoIP/GeoLite2-ASN.mmdb"
+ to "#{geoip_directory}/GeoLite2-ASN.mmdb"
end
link "/opt/piwik-#{version}/piwik/misc/GeoLite2-City.mmdb" do
- to "/usr/share/GeoIP/GeoLite2-City.mmdb"
+ to "#{geoip_directory}/GeoLite2-City.mmdb"
end
link "/opt/piwik-#{version}/piwik/misc/GeoLite2-Country.mmdb" do
- to "/usr/share/GeoIP/GeoLite2-Country.mmdb"
+ to "#{geoip_directory}/GeoLite2-Country.mmdb"
end
link "/srv/piwik.openstreetmap.org" do
line.gsub!(/^( *)#geonames_username:.*$/, "\\1geonames_username: \"openstreetmap\"")
- line.gsub!(/^( *)#maxmind_database:.*$/, "\\1maxmind_database: \"/usr/share/GeoIP/GeoLite2-Country.mmdb\"")
+ line.gsub!(/^( *)#maxmind_database:.*$/, "\\1maxmind_database: \"#{node[:geoipupdate][:directory]}/GeoLite2-Country.mmdb\"")
if new_resource.gpx_dir
line.gsub!(/^( *)gpx_trace_dir:.*$/, "\\1gpx_trace_dir: \"#{new_resource.gpx_dir}/traces\"")