Move all CLI scripts except common.cron to the "scripts" directory under the corresponding module

This commit is contained in:
Kijin Sung 2025-05-21 18:07:04 +09:00
parent 792ea89e64
commit 9ca2f79dce
14 changed files with 490 additions and 394 deletions

View file

@ -0,0 +1,84 @@
<?php
/**
* This script deletes old logs from the database.
*
* Rhymix produces various logs that can increase the size of the database
* unnecessarily if not cleaned. This script removes old logs.
*/
if (!defined('RX_VERSION'))
{
exit;
}
// Initialize the exit status.
$exit_status = 0;
// Delete logs older than this number of days.
$days = intval($args[0] ?? 0) ?: 30;
// Delete advanced mailer email logs.
$output = executeQuery('advanced_mailer.deleteMailLogs', [
'regdate' => date('YmdHis', time() - ($days * 86400)),
]);
if ($output->toBool())
{
echo "Successfully deleted all email logs older than $days days.\n";
}
else
{
echo "Error while deleting email logs older than $days days.\n";
echo $output->getMessage() . "\n";
$exit_status = 11;
}
// Delete advanced mailer SMS logs.
$output = executeQuery('advanced_mailer.deleteSMSLogs', [
'regdate' => date('YmdHis', time() - ($days * 86400)),
]);
if ($output->toBool())
{
echo "Successfully deleted all SMS logs older than $days days.\n";
}
else
{
echo "Error while deleting SMS logs older than $days days.\n";
echo $output->getMessage() . "\n";
$exit_status = 12;
}
// Delete advanced mailer Push logs.
$output = executeQuery('advanced_mailer.deletePushLogs', [
'regdate' => date('YmdHis', time() - ($days * 86400)),
]);
if ($output->toBool())
{
echo "Successfully deleted all Push logs older than $days days.\n";
}
else
{
echo "Error while deleting Push logs older than $days days.\n";
echo $output->getMessage() . "\n";
$exit_status = 13;
}
// Delete spamfilter logs.
$output = executeQuery('spamfilter.deleteLog', [
'regdate' => date('YmdHis', time() - ($days * 86400)),
]);
if ($output->toBool())
{
echo "Successfully deleted all spamfilter logs older than $days days.\n";
}
else
{
echo "Error while deleting spamfilter logs older than $days days.\n";
echo $output->getMessage() . "\n";
$exit_status = 21;
}
// Set the exit status if there were any errors.
if ($exit_status != 0)
{
exit($exit_status);
}

View file

@ -0,0 +1,67 @@
<?php
/**
* This script updates all modules.
*
* When upgrading from a very old version, it is safer to run this script
* on the CLI than clicking 'update' in the admin dashboard.
* This is because some module updates may take a long time.
*
* Note that if you use APC cache, you may need to reset the cache
* in the admin dashboard after running this script.
*/
if (!defined('RX_VERSION'))
{
exit;
}
// Get the list of modules that need to be updated.
$module_list = ModuleModel::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 = InstallController::getInstance();
foreach ($need_install as $module)
{
try
{
echo 'Installing ' . $module . '...' . PHP_EOL;
$oInstallController->installModule($module, './modules/' . $module);
}
catch (\Exception $e)
{
echo 'Error: ' . $e->getMessage() . PHP_EOL;
}
}
// Update all modules.
foreach ($need_update as $module)
{
try
{
echo 'Updating ' . $module . '...' . PHP_EOL;
$oInstallController->updateModule($module);
}
catch (\Exception $e)
{
echo 'Error: ' . $e->getMessage() . PHP_EOL;
}
}
// Set the exit status if there were any errors.
if ($exit_status != 0)
{
exit($exit_status);
}