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)
|
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'];
|
$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'];
|
$filesToCopy = ['files', 'custom', 'wakka.config.php'];
|
||||||
$bars = '============' . "\n";
|
$bars = '============' . "\n";
|
||||||
$output = '== Update wiki in path: ' . $destDir . ' ' . $bars;
|
$output = '== Update wiki in path: ' . $destDir . ' ' . $bars;
|
||||||
|
@ -359,24 +361,45 @@ function upgradeWiki($srcDir, $destDir)
|
||||||
$output .= 'File not found "' . $f . '"' . "\n";
|
$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;
|
$output .= '== End update wiki in path: ' . $destDir . ' ' . $bars;
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
function cli($cmd)
|
function cli($cmd)
|
||||||
{
|
{
|
||||||
|
$output = '';
|
||||||
|
ob_start();
|
||||||
system($cmd, $return_value);
|
system($cmd, $return_value);
|
||||||
($return_value == 0) or die('ERROR : '.$cmd."\n");
|
($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();
|
$startDir = getcwd();
|
||||||
chdir($destDir);
|
$output .= runMigrations($sudo, $destDir);
|
||||||
cli($sudo.' ./yeswicli upgrade');
|
foreach ($extensions as $ext) {
|
||||||
cli($sudo.' ./yeswicli migrate');
|
$output .= '==== Install latest version of extension ' . $ext."\n";
|
||||||
chdir($startDir);
|
//$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)
|
function copyYesWikiFiles($domain, $user, $dbUser, $herseUser = null, $hersePass = null, $nossl = null)
|
||||||
|
|
|
@ -67,7 +67,7 @@ if ($isRoot) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
if (count($matches) > 0 && $update) { // update yeswiki list
|
if (count($matches) > 0 && $update) { // update yeswiki list
|
||||||
$climate->info('Update yeswiki');
|
$climate->info('Update all listed yeswikis');
|
||||||
$tmpFile = '/tmp/yeswiki.zip';
|
$tmpFile = '/tmp/yeswiki.zip';
|
||||||
$destDir = '/tmp/yeswiki_for_update';
|
$destDir = '/tmp/yeswiki_for_update';
|
||||||
exec('rm -rf ' . $destDir . ' && mkdir -p ' . $destDir, $output);
|
exec('rm -rf ' . $destDir . ' && mkdir -p ' . $destDir, $output);
|
||||||
|
@ -79,8 +79,16 @@ if ($isRoot) {
|
||||||
exec('mv ' . $destDir . '/doryphore/* ' . $destDir . '/');
|
exec('mv ' . $destDir . '/doryphore/* ' . $destDir . '/');
|
||||||
exec('rm -rf ' . $destDir . '/doryphore');
|
exec('rm -rf ' . $destDir . '/doryphore');
|
||||||
unlink($tmpFile);
|
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) {
|
foreach ($matches as $k => $wiki) {
|
||||||
$climate->info(upgradeWiki($destDir, $wiki['PATH']));
|
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
|
} else { // show yeswiki list info
|
||||||
$climate->info(count($matches) . ' yeswikis found on ' . $path);
|
$climate->info(count($matches) . ' yeswikis found on ' . $path);
|
||||||
|
@ -103,6 +111,7 @@ if ($isRoot) {
|
||||||
$climate->info($fileName . ' was created.');
|
$climate->info($fileName . ' was created.');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
$climate->info(count($matches) . ' yeswikis found on ' . $path);
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$climate->error('ERROR : ' . $e->getMessage());
|
$climate->error('ERROR : ' . $e->getMessage());
|
||||||
|
|
Loading…
Add table
Reference in a new issue