feat(updater): use nobackup option instead of backup
Some checks are pending
/ test (push) Waiting to run

This commit is contained in:
Florian Schmitt 2025-03-27 13:17:06 +03:00
parent 107bd64253
commit a5c6a74f2b
2 changed files with 9 additions and 9 deletions

View file

@ -317,7 +317,7 @@ function saveSql($wikiDir, $backupDir)
return '==== Mysql database saved in '.$backupDir.'/database.sql ==========='. "\n"; return '==== Mysql database saved in '.$backupDir.'/database.sql ==========='. "\n";
} }
function upgradeWiki($srcDir, $destDir, $backup) function upgradeWiki($srcDir, $destDir, $nobackup = false)
{ {
$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')); $defaultExtensions = array_map('basename', array_filter(glob($srcDir.'/tools/*'), 'is_dir'));
@ -329,7 +329,7 @@ function upgradeWiki($srcDir, $destDir, $backup)
$sudo = 'sudo -u ' . $user . ' '; $sudo = 'sudo -u ' . $user . ' ';
$wakkaConfig = []; $wakkaConfig = [];
require $destDir.'/wakka.config.php'; require $destDir.'/wakka.config.php';
if ($backup === true) { if (!$nobackup) {
$tmpbackupDir = '/root/yeswiki_backups/'.str_replace(['https://', 'http://', '/?', '/'], ['','','','-'], $wakkaConfig['base_url']); $tmpbackupDir = '/root/yeswiki_backups/'.str_replace(['https://', 'http://', '/?', '/'], ['','','','-'], $wakkaConfig['base_url']);
if (is_dir($tmpbackupDir)) { if (is_dir($tmpbackupDir)) {
$output .= 'ERROR: found existing backup in "' . $tmpbackupDir . '" aborting' . "\n"; $output .= 'ERROR: found existing backup in "' . $tmpbackupDir . '" aborting' . "\n";

View file

@ -39,11 +39,11 @@ if ($isRoot) {
'description' => 'Update to latest version of stable yeswiki', 'description' => 'Update to latest version of stable yeswiki',
'noValue' => true 'noValue' => true
], ],
'backup' => [ 'nobackup' => [
'prefix' => 'b', 'prefix' => 'nobackup',
'longPrefix' => 'backup', 'longPrefix' => 'nobackup',
'description' => 'Save a backup in /root/yeswiki_backups folder before upgrading the yeswiki', 'description' => 'Do not save a backup in /root/yeswiki_backups folder before upgrading the yeswiki',
'defaultValue' => true 'noValue' => true
], ],
'depth' => [ 'depth' => [
'prefix' => 'd', 'prefix' => 'd',
@ -66,7 +66,7 @@ if ($isRoot) {
try { try {
$update = $climate->arguments->get('update'); $update = $climate->arguments->get('update');
$output = $climate->arguments->get('output'); $output = $climate->arguments->get('output');
$backup = $climate->arguments->get('backup'); $nobackup = $climate->arguments->get('nobackup');
$depth = $climate->arguments->get('depth'); $depth = $climate->arguments->get('depth');
$matches = searchWikis($path, 'wakka.config.php', $depth); $matches = searchWikis($path, 'wakka.config.php', $depth);
if (count($matches) == 0) { if (count($matches) == 0) {
@ -94,7 +94,7 @@ if ($isRoot) {
} elseif ($wiki['RELEASE'] == $version) { } elseif ($wiki['RELEASE'] == $version) {
$climate->info('Skipping up-to-date wiki '.$wiki['URL']); $climate->info('Skipping up-to-date wiki '.$wiki['URL']);
} else { } else {
$climate->info(upgradeWiki($destDir, $wiki['PATH'], $backup)); $climate->info(upgradeWiki($destDir, $wiki['PATH'], $nobackup));
} }
} }
} else { // show yeswiki list info } else { // show yeswiki list info