]> git.openstreetmap.org Git - chef.git/commitdiff
planet: remove old legacy mirror redirect updater
authorGrant Slater <github@firefishy.com>
Tue, 26 Sep 2023 00:48:00 +0000 (01:48 +0100)
committerGrant Slater <github@firefishy.com>
Tue, 26 Sep 2023 00:48:07 +0000 (01:48 +0100)
cookbooks/planet/recipes/default.rb
cookbooks/planet/recipes/dump.rb
cookbooks/planet/templates/default/planet-mirror-redirect-update.erb [deleted file]
test/integration/planet-dump/inspec/planetdump_spec.rb

index db55c246dbd4335ba52efbdbc7433655473028ce..b83d3449b88e375d4b9e3f27b4b01cfcf895a1c7 100644 (file)
@@ -24,7 +24,6 @@ include_recipe "planet::aws"
 include_recipe "munin"
 
 package %w[
-  php-cli
   python3
   python3-geoip2
 ]
index aa69f9318922fb75b57d075261bfc14e5ac5ac8d..fe56f127ebce632d72b73b2f8e44c616aa4d1584 100644 (file)
@@ -38,8 +38,6 @@ package %w[
   libprotobuf-dev
   osmpbf-bin
   pbzip2
-  php-cli
-  php-curl
   mktorrent
   xmlstarlet
   libxml2-utils
@@ -95,7 +93,7 @@ directory "/store/planetdump" do
   recursive true
 end
 
-%w[planetdump planetdump-trigger planet-mirror-redirect-update].each do |program|
+%w[planetdump planetdump-trigger].each do |program|
   template "/usr/local/bin/#{program}" do
     source "#{program}.erb"
     owner "root"
@@ -135,20 +133,13 @@ service "planetdump-trigger" do
 end
 
 systemd_service "planet-dump-mirror" do
-  description "Update planet dump mirrors"
-  exec_start "/usr/local/bin/planet-mirror-redirect-update"
-  user "planet"
-  sandbox :enable_network => true
-  memory_deny_write_execute false
-  read_write_paths "/store/planet/.htaccess"
+  action :delete
 end
 
-systemd_timer "planet-dump-mirror" do
-  description "Update planet dump mirrors"
-  on_boot_sec "10min"
-  on_unit_inactive_sec "10min"
+service "planet-dump-mirror.timer" do
+  action [:disable, :stop]
 end
 
-service "planet-dump-mirror.timer" do
-  action [:enable, :start]
+systemd_timer "planet-dump-mirror" do
+  action :delete
 end
diff --git a/cookbooks/planet/templates/default/planet-mirror-redirect-update.erb b/cookbooks/planet/templates/default/planet-mirror-redirect-update.erb
deleted file mode 100644 (file)
index 2c651ea..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-#!/usr/bin/php
-<?php
-/*
-       DO NOT EDIT - This file is being maintained by Chef
-
-       planet-mirror-redirect
-       Check if planet file exists on mirror and link if not yet linked
-       Modifies .htaccess
-*/
-$_YEAR = date('Y');
-
-$_MIRROR = 'https://ftp5.gwdg.de/pub/misc/openstreetmap/planet.openstreetmap.org/';
-
-$_FOLDERS = [
-              "planet_bz2" => [
-                          'FOLDER'     => '<%= node[:planet][:dump][:xml_directory] %>/'.$_YEAR.'/',
-                          'REGEX'      => '/^(planet|changesets|discussions)\-\d{6}(\-nolt)?\.osm\.(bz2|gz)$/',
-                          'DIR_PREFIX' => 'planet/'.$_YEAR.'/'
-                          ],
-
-              "history_bz2" => [
-                          'FOLDER' => '<%= node[:planet][:dump][:xml_history_directory] %>/'.$_YEAR.'/',
-                          'REGEX'  => '/^(history)\-\d{6}(\-nolt)?\.osm\.(bz2|gz)$/',
-                          'DIR_PREFIX' => 'planet/full-history/'.$_YEAR.'/'
-                          ],
-              "planet_pbf" => [
-                          'FOLDER'     => '<%= node[:planet][:dump][:pbf_directory] %>/',
-                          'REGEX'      => '/^(planet)\-\d{6}(\-nolt)?\.osm\.pbf$/',
-                          'DIR_PREFIX' => 'pbf/'
-                          ],
-
-              "history_pbf" => [
-                          'FOLDER' => '<%= node[:planet][:dump][:pbf_history_directory] %>/',
-                          'REGEX'  => '/^(history)\-\d{6}(\-nolt)?\.osm\.pbf$/',
-                          'DIR_PREFIX' => 'pbf/full-history/'
-                          ]
-            ];
-
-$_PLANET_HTACCESS = realpath('<%= node[:planet][:dump][:xml_directory] %>/..').'/.htaccess';
-
-function _MIRROR_FILE_SIZE($url) {
-       $ch = @curl_init();
-       curl_setopt($ch, CURLOPT_URL, $url);
-       curl_setopt($ch, CURLOPT_NOBODY, TRUE);
-       curl_setopt($ch, CURLOPT_VERBOSE, FALSE);
-       $curl_response = @curl_exec($ch);
-       $curl_result = curl_getinfo($ch);
-       if ($curl_result['http_code']!='200') return FALSE;
-       return ($curl_result['download_content_length']);
-}
-
-if (!is_writable($_PLANET_HTACCESS)) die('File '.$_PLANET_HTACCESS.' is not writable by current user.'."\n");
-
-$htaccess_contents = file_get_contents($_PLANET_HTACCESS);
-$htaccess_handle = fopen($_PLANET_HTACCESS, 'a');
-
-foreach ($_FOLDERS as $FOLDER) {
-
-  $_PLANET_FOLDER = $FOLDER["FOLDER"];
-  $_PLANET_REGEX  = $FOLDER["REGEX"];
-
-  if (!(is_dir($_PLANET_FOLDER))) {
-    continue;
-  }
-
-  if ($dh = opendir($_PLANET_FOLDER)) {
-    while (($file = readdir($dh)) !== false ) {
-      if (preg_match($_PLANET_REGEX, $file)) {
-        $file_slashed = str_replace(array('.','-'), array('\.','\-'), $FOLDER['DIR_PREFIX'].$file);
-        if (strpos($htaccess_contents, $file_slashed) === false) {
-          $file_size = filesize($_PLANET_FOLDER.$file);
-          sleep(rand(2,5));
-          $file_mirror_size = _MIRROR_FILE_SIZE($_MIRROR.$FOLDER['DIR_PREFIX'].$file);
-          if ($file_size==$file_mirror_size) {
-            echo 'Adding: '.$file."\n";
-            fwrite($htaccess_handle, 'RewriteRule'."\t". '^('.$file_slashed.')$'."\t".$_MIRROR.'$1'."\t".'[R,L]'."\n");
-          }
-        }
-      }
-    }
-    closedir($dh);
-  }
-}
-
-fclose($htaccess_handle);
-
index b66ee8313b89ab2ad0c38c2618daeacd3fe789e7..71891e30273de099fb9187da38cbb1a6f24f4f46 100644 (file)
@@ -7,13 +7,3 @@ describe file("/usr/local/bin/planetdump") do
   it { should be_file }
   it { should be_executable }
 end
-
-describe file("/usr/local/bin/planet-mirror-redirect-update") do
-  it { should be_file }
-  it { should be_executable }
-end
-
-describe service("planet-dump-mirror.timer") do
-  it { should be_enabled }
-  it { should be_running }
-end