fix(updater): load config file
Some checks are pending
/ test (push) Waiting to run

This commit is contained in:
Florian Schmitt 2025-03-25 20:41:36 +03:00
parent ff56e0fb09
commit 73f6cc0e62

View file

@ -314,7 +314,7 @@ function saveSql($wikiDir, $backuptDir)
$wakkaConfig = []; $wakkaConfig = [];
include_once($wikiDir.'/wakka.config.php'); include_once($wikiDir.'/wakka.config.php');
exec($sudo . 'mysqldump -u'.$wakkaConfig['mysql_user'].' -p'.$wakkaConfig['mysql_password'].' '.$wakkaConfig['mysql_database'].' '.$wakkaConfig['table_prefix'].'acls, '.$wakkaConfig['table_prefix'].'links '.$wakkaConfig['table_prefix'].'nature '.$wakkaConfig['table_prefix'].'pages '.$wakkaConfig['table_prefix'].'referrers '.$wakkaConfig['table_prefix'].'triples '.$wakkaConfig['table_prefix'].'usersname > ' . $backupDir.'/database.sql'); exec($sudo . 'mysqldump -u'.$wakkaConfig['mysql_user'].' -p'.$wakkaConfig['mysql_password'].' '.$wakkaConfig['mysql_database'].' '.$wakkaConfig['table_prefix'].'acls, '.$wakkaConfig['table_prefix'].'links '.$wakkaConfig['table_prefix'].'nature '.$wakkaConfig['table_prefix'].'pages '.$wakkaConfig['table_prefix'].'referrers '.$wakkaConfig['table_prefix'].'triples '.$wakkaConfig['table_prefix'].'usersname > ' . $backupDir.'/database.sql');
return '== Mysql database saved in '.$backupDir.'/database.sql ==========='. "\n"; return '==== Mysql database saved in '.$backupDir.'/database.sql ==========='. "\n";
} }
function upgradeWiki($srcDir, $destDir) function upgradeWiki($srcDir, $destDir)
@ -326,7 +326,7 @@ function upgradeWiki($srcDir, $destDir)
$user = posix_getpwuid(fileowner($destDir . '/wakka.config.php'))['name']; $user = posix_getpwuid(fileowner($destDir . '/wakka.config.php'))['name'];
$sudo = 'sudo -u ' . $user . ' '; $sudo = 'sudo -u ' . $user . ' ';
$wakkaConfig = []; $wakkaConfig = [];
include_once($destDir.'/wakka.config.php'); require $destDir.'/wakka.config.php';
$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";
@ -350,7 +350,6 @@ function upgradeWiki($srcDir, $destDir)
$output .= 'File not found "' . $f . '"' . "\n"; $output .= 'File not found "' . $f . '"' . "\n";
} }
} }
$output .= '==== End Move files to temporary backup dir ' . $tmpbackupDir . ' ' . $bars;
$output .= saveSql($destDir, $tmpbackupDir); $output .= saveSql($destDir, $tmpbackupDir);
$output .= '==== Update to latest sources ' . $bars; $output .= '==== Update to latest sources ' . $bars;
foreach ($filesToMove as $f) { foreach ($filesToMove as $f) {
@ -361,7 +360,6 @@ function upgradeWiki($srcDir, $destDir)
} }
} }
runUpgrades($sudo, $destDir); runUpgrades($sudo, $destDir);
$output .= '==== End Update to latest sources ' . $bars;
$output .= '== End update wiki in path: ' . $destDir . ' ' . $bars; $output .= '== End update wiki in path: ' . $destDir . ' ' . $bars;
return $output; return $output;
} }