feat(updater): change version and upgrade extension, all clear for prod
Some checks are pending
/ test (push) Waiting to run
Some checks are pending
/ test (push) Waiting to run
This commit is contained in:
parent
f4c48be28b
commit
abd61a963c
2 changed files with 40 additions and 8 deletions
|
@ -320,6 +320,8 @@ function saveSql($wikiDir, $backupDir)
|
|||
function upgradeWiki($srcDir, $destDir)
|
||||
{
|
||||
$filesToMove = ['actions', 'cache', 'docker', 'docs', 'formatters', 'handlers', 'includes', 'javascripts', 'lang', 'private', 'setup', 'styles', 'templates', 'tests', 'themes', 'tools', 'vendor', 'composer.json', 'composer.lock', 'index.php', 'INSTALL.md', 'interwiki.conf', 'LICENSE', 'Makefile', 'package.json', 'README.md', 'SECURITY.md', 'wakka.basic.css', 'wakka.css', 'wakka.php', 'yarn.lock', 'yeswicli'];
|
||||
$defaultExtensions = array_map('basename', array_filter(glob($srcDir.'/tools/*'), 'is_dir'));
|
||||
$installedExtensions = array_map('basename', array_filter(glob($destDir.'/tools/*'), 'is_dir'));
|
||||
$filesToCopy = ['files', 'custom', 'wakka.config.php'];
|
||||
$bars = '============' . "\n";
|
||||
$output = '== Update wiki in path: ' . $destDir . ' ' . $bars;
|
||||
|
@ -359,24 +361,45 @@ function upgradeWiki($srcDir, $destDir)
|
|||
$output .= 'File not found "' . $f . '"' . "\n";
|
||||
}
|
||||
}
|
||||
runUpgrades($sudo, $destDir);
|
||||
$output .= runUpgrades($sudo, $destDir, array_diff($installedExtensions, $defaultExtensions));
|
||||
$version = trim(cli("cat $destDir/includes/constants.php | grep YESWIKI_RELEASE | sed -r -e \"s/.*([0-9]+\\.[0-9]+\\.[0-9]+).*/\\1/\""));
|
||||
$output .= '==== Change YesWiki version to '.$version.' '. $bars;
|
||||
$output .= cli("sed -r -i -e \"s/(['\\\"]yeswiki_release['\\\"].*)[0-9]+\\.[0-9]+\\.[0-9]+/\\1$version/\" $destDir/wakka.config.php");
|
||||
$output .= '== End update wiki in path: ' . $destDir . ' ' . $bars;
|
||||
return $output;
|
||||
}
|
||||
|
||||
function cli($cmd)
|
||||
{
|
||||
$output = '';
|
||||
ob_start();
|
||||
system($cmd, $return_value);
|
||||
($return_value == 0) or die('ERROR : '.$cmd."\n");
|
||||
$output .= ob_get_contents();
|
||||
ob_end_clean();
|
||||
return $output;
|
||||
}
|
||||
|
||||
function runUpgrades($sudo, $destDir)
|
||||
function runUpgrades($sudo, $destDir, $extensions = [])
|
||||
{
|
||||
$output = '';
|
||||
$startDir = getcwd();
|
||||
chdir($destDir);
|
||||
cli($sudo.' ./yeswicli upgrade');
|
||||
cli($sudo.' ./yeswicli migrate');
|
||||
chdir($startDir);
|
||||
$output .= runMigrations($sudo, $destDir);
|
||||
foreach ($extensions as $ext) {
|
||||
$output .= '==== Install latest version of extension ' . $ext."\n";
|
||||
//$output .= cli('cd '.$destDir.' && '.$sudo.' ./yeswicli upgrade '.$ext);
|
||||
}
|
||||
$output .= cli('cd '.$startDir);
|
||||
return $output;
|
||||
}
|
||||
|
||||
function runMigrations($sudo, $destDir)
|
||||
{
|
||||
$output = '==== Run migrations on core'."\n";
|
||||
$startDir = getcwd();
|
||||
//$output .= cli('cd '.$destDir.' && '.$sudo.' ./yeswicli migrate');
|
||||
//$output .= cli('cd '.$startDir);
|
||||
return $output;
|
||||
}
|
||||
|
||||
function copyYesWikiFiles($domain, $user, $dbUser, $herseUser = null, $hersePass = null, $nossl = null)
|
||||
|
|
|
@ -67,7 +67,7 @@ if ($isRoot) {
|
|||
exit;
|
||||
}
|
||||
if (count($matches) > 0 && $update) { // update yeswiki list
|
||||
$climate->info('Update yeswiki');
|
||||
$climate->info('Update all listed yeswikis');
|
||||
$tmpFile = '/tmp/yeswiki.zip';
|
||||
$destDir = '/tmp/yeswiki_for_update';
|
||||
exec('rm -rf ' . $destDir . ' && mkdir -p ' . $destDir, $output);
|
||||
|
@ -79,9 +79,17 @@ if ($isRoot) {
|
|||
exec('mv ' . $destDir . '/doryphore/* ' . $destDir . '/');
|
||||
exec('rm -rf ' . $destDir . '/doryphore');
|
||||
unlink($tmpFile);
|
||||
// get latest yeswiki version
|
||||
$version = trim(cli("cat $destDir/includes/constants.php | grep YESWIKI_RELEASE | sed -r -e \"s/.*([0-9]+\\.[0-9]+\\.[0-9]+).*/\\1/\""));
|
||||
foreach ($matches as $k => $wiki) {
|
||||
if ($wiki['VERSION'] != 'doryphore') {
|
||||
$climate->red('Skipping non doryphore version wiki '.$wiki['URL']);
|
||||
} elseif ($wiki['RELEASE'] == $version) {
|
||||
$climate->info('Skipping up-to-date wiki '.$wiki['URL']);
|
||||
} else {
|
||||
$climate->info(upgradeWiki($destDir, $wiki['PATH']));
|
||||
}
|
||||
}
|
||||
} else { // show yeswiki list info
|
||||
$climate->info(count($matches) . ' yeswikis found on ' . $path);
|
||||
switch ($output) {
|
||||
|
@ -103,6 +111,7 @@ if ($isRoot) {
|
|||
$climate->info($fileName . ' was created.');
|
||||
break;
|
||||
}
|
||||
$climate->info(count($matches) . ' yeswikis found on ' . $path);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$climate->error('ERROR : ' . $e->getMessage());
|
||||
|
|
Loading…
Add table
Reference in a new issue