]> git.openstreetmap.org Git - chef.git/commitdiff
Make the GeoIP database directory vary with the OS version
authorTom Hughes <tom@compton.nu>
Tue, 28 Jun 2022 07:19:52 +0000 (08:19 +0100)
committerTom Hughes <tom@compton.nu>
Tue, 28 Jun 2022 07:19:52 +0000 (08:19 +0100)
cookbooks/geoipupdate/attributes/default.rb
cookbooks/geoipupdate/recipes/default.rb
cookbooks/piwik/recipes/default.rb
cookbooks/web/resources/rails_port.rb

index 3165aa1153feb31f32a821ca74d81f17bd27e317..315dfe1463f207195966e4a3156f5bf1e856296c 100644 (file)
@@ -1,4 +1,9 @@
 default[:geoipupdate][:account] = "149244"
 default[:geoipupdate][:editions] = %w[GeoLite2-ASN GeoLite2-City GeoLite2-Country]
 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"]
 
 default[:apt][:sources] |= ["maxmind"]
index 2b2c23632c1bc97ce1ed2e10766f20b089374556..036c27881c06262bbfd00589a284dada2b992bdc 100644 (file)
@@ -35,7 +35,7 @@ execute "geoipupdate" do
   command "geoipupdate"
   user "root"
   group "root"
   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
 end
 
 systemd_service "geoipupdate" do
@@ -46,7 +46,7 @@ systemd_service "geoipupdate" do
   private_devices true
   protect_system "strict"
   protect_home true
   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
 end
 
 systemd_timer "geoipupdate" do
index b2a27737ad4872a2f6a35db11d2415d1b0109e0d..0a32dda4e6a7fac1ef293ef6c0d3458a55432def 100644 (file)
@@ -39,6 +39,8 @@ apache_module "rewrite"
 
 version = node[:piwik][:version]
 
 
 version = node[:piwik][:version]
 
+geoip_directory = node[:geoipupdate][:directory]
+
 directory "/opt/piwik-#{version}" do
   owner "root"
   group "root"
 directory "/opt/piwik-#{version}" do
   owner "root"
   group "root"
@@ -95,15 +97,15 @@ directory "/opt/piwik-#{version}/piwik/tmp/assets" do
 end
 
 link "/opt/piwik-#{version}/piwik/misc/GeoLite2-ASN.mmdb" do
 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
 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
 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
 end
 
 link "/srv/piwik.openstreetmap.org" do
index e4e206ae534a455027cd34f7937fca6faa7495ac..565a21efe5803a0ace1a9348bd84bbca8497e878 100644 (file)
@@ -191,7 +191,7 @@ action :create do
 
     line.gsub!(/^( *)#geonames_username:.*$/, "\\1geonames_username: \"openstreetmap\"")
 
 
     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\"")
 
     if new_resource.gpx_dir
       line.gsub!(/^( *)gpx_trace_dir:.*$/, "\\1gpx_trace_dir: \"#{new_resource.gpx_dir}/traces\"")