no dump , logic for update

This commit is contained in:
Florian Schmitt 2024-01-23 22:21:26 +03:00
parent b439265c25
commit 1e3942f609
2 changed files with 8 additions and 3 deletions

View file

@ -366,7 +366,9 @@ function searchWikis($path, $pattern)
$responses = Future\awaitAll(array_map(function ($l) use ($httpClient) { $responses = Future\awaitAll(array_map(function ($l) use ($httpClient) {
return Amp\async(fn () => $httpClient->request(new Request($l['URL'], 'HEAD'))); return Amp\async(fn () => $httpClient->request(new Request($l['URL'], 'HEAD')));
}, $list)); }, $list));
var_dump($responses[0]); foreach ($responses[0] as $key => $response) {
$list[$key]['STATUS'] = 'ERROR';
}
foreach ($responses[1] as $key => $response) { foreach ($responses[1] as $key => $response) {
$list[$key]['STATUS'] = $response->getStatus() . ' ' . $response->getReason(); $list[$key]['STATUS'] = $response->getStatus() . ' ' . $response->getReason();
} }

View file

@ -1,4 +1,4 @@
#!/usr/bin/php #!php
<?php <?php
require_once('vendor/autoload.php'); require_once('vendor/autoload.php');
require_once('utils.inc.php'); require_once('utils.inc.php');
@ -34,7 +34,7 @@ if (0 == posix_getuid()) {
'prefix' => 'u', 'prefix' => 'u',
'longPrefix' => 'update', 'longPrefix' => 'update',
'description' => 'Update to latest version of stable yeswiki', 'description' => 'Update to latest version of stable yeswiki',
'defaultValue' => '0' 'noValue' => true
], ],
]); ]);
try { try {
@ -52,6 +52,9 @@ if (0 == posix_getuid()) {
$update = $climate->arguments->get('update'); $update = $climate->arguments->get('update');
$output = $climate->arguments->get('output'); $output = $climate->arguments->get('output');
$matches = searchWikis($path, 'wakka.config.php'); $matches = searchWikis($path, 'wakka.config.php');
if (count($matches) > 0 && $update) {
$climate->info('update');
}
$climate->info(count($matches) . ' yeswikis found on ' . $path); $climate->info(count($matches) . ' yeswikis found on ' . $path);
switch ($output) { switch ($output) {