diff options
Diffstat (limited to 'check.php')
| -rwxr-xr-x | check.php | 156 | 
1 files changed, 116 insertions, 40 deletions
| @@ -35,17 +35,18 @@ if ($cli) {  <?php  }  $repos = [ +	'enterprise/10'	=> 'Enterprise Linux 10', +	'enterprise/9'	=> 'Enterprise Linux 9',  	'enterprise/8'	=> 'Enterprise Linux 8', -	'enterprise/7'	=> 'Enterprise Linux 7', -	'enterprise/6'	=> 'Enterprise Linux 6', -	'fedora/31'		=> 'Fedora 31', -	'fedora/30' 	=> 'Fedora 30', -	'fedora/29' 	=> 'Fedora 29', +	'fedora/41' 	=> 'Fedora 41', +	'fedora/40' 	=> 'Fedora 40', +	'fedora/39' 	=> 'Fedora 39',  ];  $subs = [ +	'modular',  	'remi', +	'safe',  	'test', -	'php56',  ];  $archs = [  	'i386', @@ -53,7 +54,6 @@ $archs = [  ];  $mirrors = [ -	'http://remi.conetix.com.au/',  	'http://mirrors.neterra.net/remi/',  	'http://remi.schlundtech.de/',  	'http://mirror.cedia.org.ec/remi/', @@ -63,21 +63,16 @@ $mirrors = [  	'http://mirrors.netix.net/remi/',  	'http://remi.mirrors.cu.be/',  	'http://mirror.neolabs.kz/remi/', -	'https://remi.mirror.ate.info/',  	'https://mirrors.tuna.tsinghua.edu.cn/remi/',  	'https://mirror.23m.com/remi/',  	'https://mirror.oxilion.nl/remi/', -	'https://remi.mirror.wearetriple.com/',  	'https://mirrors.uni-ruse.bg/remi/',  	'https://remi.mirror.karneval.cz/',  	'https://mirror.netsite.dk/remi/',  	'http://mirror.team-cymru.com/remi/', -	'http://mirrors.ukfast.co.uk/sites/remi/',  	'https://mirror.netweaver.uk/remi/',  	'http://ftp.riken.jp/Linux/remi/',  	'https://mir01.syntis.net/remirepo/', -	'http://mirrors.bytes.ua/remi/', -	'http://mirror.hoster.kz/remi/',  	'http://remirepo.reloumirrors.net/',  	'https://mirror.pit.teraswitch.com/remi/',  	'http://remi.mirror.liteserver.nl/', @@ -93,30 +88,36 @@ $mirrors = [  	'https://mirror.docker.ru/remi/',  	'https://repo.extreme-ix.org/remi/',  	'https://mirror.mangohost.net/remi/', -	'https://bd.mirror.vanehost.com/Remi/', -	'https://repo1.vetta.net.nz/remi/', -	'https://cdn.centos.no/remi/', -	'https://mirror.centos.no/remi/', +	'https://mirror.fjordos.com/remi/',  	'https://muug.ca/mirror/remi/',  	'https://mirror.netzwerge.de/remi/', +	'https://pit.mirror.jurassicinnovations.com/remi/', +	'http://mirror.yer.az/remi/', +	'https://mirror.raiolanetworks.com/remi/', 	// 2025-01-08 +	'https://remi.mirror.wearetriple.com/',		// 2025-01-10 +	'https://mirror.geo.yer.cloud/remi/',		// 2025-01-07 +	'http://mirrors.bytes.ua/remi/',			// 2025-01-13 +	'https://remi.mivzakim.net/',				// 2025-01-13 +	'http://repo1.ash.innoscale.net/remi/',		// 2025-01-13 +	'https://bd.mirror.vanehost.com/Remi/',		// 2025-01-17 +	'http://mirrors.ukfast.co.uk/sites/remi/',	// 2025-01-28 / 2025-01-30  ];  $testing = [ -	'https://pit1.mirror.jurassicinnovations.com/remi/', -	'https://mirror.raiolanetworks.com/remi/', -	'http://repo1.ash.innoscale.net/remi/', +	'http://remi.conetix.com.au/', 				// 2025-01-22 +	'https://mirror.usi.edu/pub/remi/',			// 2024-04-03 / 2025-01-29  ];  $disabled = [ -	'https://remi.mivzakim.net/',		// 2024-04-03 -	'https://mirror.usi.edu/pub/remi/',	// 2024-04-03 -	'http://mirror.awanti.com/remi/',	// 2024-03-20 +	'https://remi.mirror.ate.info/',			// 2025-09-23 (404) +	'http://mirror.hoster.kz/remi/', +	'https://repo1.vetta.net.nz/remi/',			// 2025-01-17 (too slow)  	'http://mirror.xeonbd.com/remi/',  	'https://mirror.telkomuniversity.ac.id/remi/',  	'http://mirror.uta.edu.ec/remi/',  	'http://repo1.dal.innoscale.net/remi/',  	'http://repo1.sea.innoscale.net/remi/', -	'http://mirror.yer.az/remi/',  ];  $deprecated = [ +	'http://mirror.awanti.com/remi/',	// 2025-01-08  	'https://remi.srv.magticom.ge/',  	'https://mirror.sjc02.svwh.net/remi/',  	'http://mirror.upb.edu.co/remi/', @@ -155,7 +156,7 @@ $deprecated = [  function getRepoTime($uri) {  	$ctx = stream_context_create([  		'http' => [ -			'timeout' => 4, +			'timeout' => 7,  		]  	]);  	$txt = @file_get_contents($uri . '/repodata/repomd.xml', false, $ctx); @@ -168,10 +169,35 @@ function getRepoTime($uri) {  	}  	return ERR_CONTENT;  } + +function delta($ref, $loc) { +	$d = ($ref > $loc ? $ref - $loc : $loc - $ref); +	if ($d >= 60) { +		$d /= 60; +		if ($d >= 60) { +			$d = (int)($d / 60); +			if ($d >= 24) { +				$d = (int)($d / 24); +				$unit = 'DAY'; +			} else { +				$unit = 'hour'; +			} +		} else { +			$unit = 'minute'; +		} +	} else { +		$unit = 'second'; +	} +	if ($d > 1) { +		$unit .= 's'; +	} +	return sprintf("%s :%3d %s", date('r', $loc), $d, $unit); +} +  if (isset($_GET['mirror']) && isset($repos[$_GET['mirror']])) {  	$path = $_GET['mirror'];  } else { -	$path = 'enterprise/8'; +	$path = 'enterprise/9';  }  if (isset($_GET['repo']) && in_array($_GET['repo'], $subs)) {  	$repo = $_GET['repo']; @@ -183,6 +209,18 @@ if (isset($_GET['arch']) && in_array($_GET['arch'], $archs)) {  } else {  	$arch = 'x86_64';  } +if (isset($_SERVER['argv'][1]) && isset($repos[$_SERVER['argv'][1]])) { +	$path = $_SERVER['argv'][1]; +	array_shift($_SERVER['argv']); +} +if (isset($_SERVER['argv'][1]) && in_array($_SERVER['argv'][1], $subs)) { +	$repo = $_SERVER['argv'][1]; +	array_shift($_SERVER['argv']); +} +if (isset($_SERVER['argv'][1]) && in_array($_SERVER['argv'][1], $archs)) { +	$arch = $_SERVER['argv'][1]; +	array_shift($_SERVER['argv']); +}  $name = $repos[$path];  $full = "$path/$repo/$arch"; @@ -199,24 +237,48 @@ if (!$cli) {  }  $pids = array();  $ref = getRepoTime($full); -$mirrors = array_merge($mirrors, $testing);  if ($ref) {  	if (!$cli) echo "<ul class='pkglist'>\n";  	if (isset($_SERVER['argv'][1])) { -		$tocheck = []; -		foreach ($mirrors as $mirror) { -			if (preg_match('|'.$_SERVER['argv'][1].'|', $mirror)) { -				$tocheck[] = $mirror; -			} +		switch ($_SERVER['argv'][1]) { +			case 'active': +				$tocheck = $mirrors; +				break; +			case 'testing': +				$tocheck = $testing; +				break; +			case 'disabled': +				$tocheck = $disabled; +				break; +			case 'deprecated': +				$tocheck = $deprecated; +				break; +			default: +				$tocheck = []; +				foreach ($mirrors as $mirror) { +					if (preg_match('|'.$_SERVER['argv'][1].'|', $mirror)) { +						$tocheck[] = $mirror; +					} +				} +				foreach ($mirrors as $testing) { +					if (preg_match('|'.$_SERVER['argv'][1].'|', $mirror)) { +						$tocheck[] = $mirror; +					} +				} +				foreach ($mirrors as $disabled) { +					if (preg_match('|'.$_SERVER['argv'][1].'|', $mirror)) { +						$tocheck[] = $mirror; +					} +				} +				if (empty($tocheck)) { +					$tocheck[] = $_SERVER['argv'][1]; +				}  		}  	} else { -		$tocheck = $mirrors; +		$tocheck = array_merge($mirrors, $testing);  	} -	printf(($cli ? "Check %d mirror(s) of %s (%s)\n" : "<h3>%s - %s</h3>\n"), count($tocheck), $name, date('r', $ref)); +	printf(($cli ? "Check %d mirror(s) of %s (%s, %s)\n" : "<h3>%s - %s</h3>\n"), count($tocheck), $name, $full, date('r', $ref));  	foreach ($tocheck as $mirror) { -		if ($_SERVER['argc']>1 && !strpos($mirror, $_SERVER['argv'][1])) { -			continue; -		}  		if ($cli) {  			$pid = pcntl_fork();  			if ($pid<0) { @@ -232,12 +294,14 @@ if ($ref) {  					printf("%50.50s : ** Corrupted **\n", $mirror);  				} else if ($ref == $loc) {  					printf("%50.50s : Ok\n", $mirror); +					exit(0);  				} else if ($loc) { -					printf("%50.50s : %s\n", $mirror, date('r', $loc)); +					printf("%50.50s : %s\n", $mirror, delta($ref, $loc)); +					exit(1);  				} else {  					printf("%50.50s : N/A\n", $mirror);  				} -				break; +				exit(2);  			}  			continue;  		} @@ -258,7 +322,8 @@ if ($ref) {  		}  	}  	if ($cli) { -		$nb=count($pids); +		$nb = count($pids); +		$ok = $lack = 0;  		while (count($pids)) {  			if (posix_isatty(STDOUT)) {  				printf("Wait %d\r", count($pids)); @@ -268,10 +333,21 @@ if ($ref) {  				die("Cound not wait\n");  				exit (1);  			} else { +				switch (pcntl_wexitstatus($status)) { +					case 0: +						$ok++; +						break; +					case 1: +						$lack++; +						break; +				}  				unset($pids[$pid]);  			}  		} -		if ($nb) printf("%d mirrors checked.\n", $nb); +		if ($nb) { +			printf("%3d mirrors checked on %s,\n%3d are OK\t(%d%%)\n%3d are late\t(%d%%)\n%3d are KO.\n", +				$nb, date("r"), $ok, $ok*100/$nb, $lack, $lack*100/$nb, $nb-$ok-$lack); +		}  	} else {  		echo "</ul>\n";  	} | 
