mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-11 04:52:14 +09:00
Add script to update all modules from the CLI
This commit is contained in:
parent
3cec3baf33
commit
f27ea1b666
1 changed files with 61 additions and 0 deletions
61
common/scripts/update_all_modules.php
Normal file
61
common/scripts/update_all_modules.php
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This script updates all modules.
|
||||||
|
*
|
||||||
|
* Running this script on the CLI is better than clicking 'update' in the
|
||||||
|
* admin dashboard because some module updates may take a long time.
|
||||||
|
*/
|
||||||
|
require_once __DIR__ . '/common.php';
|
||||||
|
|
||||||
|
Context::init();
|
||||||
|
$oModuleModel = getModel('module');
|
||||||
|
|
||||||
|
// Get the list of modules that need to be updated.
|
||||||
|
$module_list = $oModuleModel->getModuleList();
|
||||||
|
$need_install = array();
|
||||||
|
$need_update = array();
|
||||||
|
foreach($module_list as $key => $value)
|
||||||
|
{
|
||||||
|
if($value->need_install)
|
||||||
|
{
|
||||||
|
$need_install[] = $value->module;
|
||||||
|
}
|
||||||
|
if($value->need_update)
|
||||||
|
{
|
||||||
|
$need_update[] = $value->module;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Install all modules.
|
||||||
|
$oInstallController = getController('install');
|
||||||
|
foreach ($need_install as $module)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
echo 'Installing ' . $module . '...' . PHP_EOL;
|
||||||
|
$oInstallController->installModule($module, './modules/' . $module);
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
// pass
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update all modules.
|
||||||
|
$oInstallAdminController = getAdminController('install');
|
||||||
|
foreach ($need_update as $module)
|
||||||
|
{
|
||||||
|
echo 'Updating ' . $module . '...' . PHP_EOL;
|
||||||
|
$oModule = getModule($module, 'class');
|
||||||
|
if ($oModule)
|
||||||
|
{
|
||||||
|
$oModule->moduleUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the exit status if there were any errors.
|
||||||
|
if ($exit_status != 0)
|
||||||
|
{
|
||||||
|
exit($exit_status);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue