X-Git-Url: https://git.openstreetmap.org/chef.git/blobdiff_plain/979e98164cc9a6d7216197f01febc918c9a152b9..ca0e23852a9523282075fe78076b2deeca69ee53:/cookbooks/planet/templates/default/planet-mirror-redirect-update.erb diff --git a/cookbooks/planet/templates/default/planet-mirror-redirect-update.erb b/cookbooks/planet/templates/default/planet-mirror-redirect-update.erb index c673998e6..81c9f2ae3 100644 --- a/cookbooks/planet/templates/default/planet-mirror-redirect-update.erb +++ b/cookbooks/planet/templates/default/planet-mirror-redirect-update.erb @@ -10,8 +10,8 @@ $_YEAR = date('Y'); $_PLANET_FOLDER = '<%= node[:planet][:dump][:xml_directory] %>/'.$_YEAR.'/'; $_PLANET_REGEX = "/^(planet|changesets)\-\d{6}(\-nolt)?\.osm\.(bz2|gz)$/"; -$_MIRROR = 'http://ftp.heanet.ie/mirrors/openstreetmap.org/planet/'.$_YEAR.'/'; -$_PLANET_HTACCESS = realpath($_PLANET_FOLDER.'../..').'/.htaccess'; +$_MIRROR = 'https://ftp5.gwdg.de/pub/misc/openstreetmap/planet.openstreetmap.org/planet/'.$_YEAR.'/'; +$_PLANET_HTACCESS = realpath('<%= node[:planet][:dump][:xml_directory] %>/..').'/.htaccess'; function _MIRROR_FILE_SIZE($url) { $ch = @curl_init(); @@ -22,7 +22,7 @@ function _MIRROR_FILE_SIZE($url) { $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"); @@ -34,16 +34,14 @@ if (is_dir($_PLANET_FOLDER)) { if (preg_match($_PLANET_REGEX,$file)) { $file_slashed = 'planet/'.$_YEAR.'/'.str_replace(array('.','-'), array('\.','\-'), $file); if (strpos($htaccess_contents,$file_slashed) === false) { - //PHP IS BRAINDEAD filesize borked >4GB - //$file_size = $file_stats['size']; - $file_size = trim(`stat -c%s $_PLANET_FOLDER$file`); + $file_size = filesize($_PLANET_FOLDER.$file); sleep(rand(2,5)); $file_mirror_size = _MIRROR_FILE_SIZE($_MIRROR.$file); if ($file_size==$file_mirror_size) { echo 'Adding: '.$file."\n"; fwrite($htaccess_handle, 'RewriteRule'."\t". '^('.$file_slashed.')$'."\t". - 'http://ftp.heanet.ie/mirrors/openstreetmap.org/$1'."\t". + 'https://ftp5.gwdg.de/pub/misc/openstreetmap/planet.openstreetmap.org/$1'."\t". '[R,L]'."\n"); } }