backward compatibility for updaters to update cron.d configuration file after update

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2022-12-06 16:47:16 +01:00
parent d7a2ec35cc
commit 6135ba8468
4 changed files with 26 additions and 2 deletions

View File

@@ -742,7 +742,7 @@ opcache.validate_timestamps'),
('panel', 'logo_overridecustom', '0'),
('panel', 'settings_mode', '0'),
('panel', 'version', '2.0.0-beta1'),
('panel', 'db_version', '202211030');
('panel', 'db_version', '202212060');
DROP TABLE IF EXISTS `panel_tasks`;

View File

@@ -196,3 +196,21 @@ if (Froxlor::isDatabaseVersion('202112310')) {
Froxlor::updateToDbVersion('202211030');
}
if (Froxlor::isDatabaseVersion('202211030')) {
Update::showUpdateStep("Creating backward compatibility for cronjob");
$complete_filedir = Froxlor::getInstallDir() . '/scripts';
mkdir($complete_filedir, 0750, true);
$newCronBin = Froxlor::getInstallDir().'/bin/froxlor-cli';
$compCron = <<<EOF
<?php
// re-create cron.d configuration file
exec('$newCronBin froxlor:cron -r 99');
exit;
EOF;
file_put_contents($complete_filedir.'/froxlor_master_cronjob.php', $compCron);
Update::lastStepStatus(0);
Froxlor::updateToDbVersion('202212060');
}

View File

@@ -150,6 +150,12 @@ final class MasterCron extends CliCommand
// check for cron.d-generation task and create it if necessary
CronConfig::checkCrondConfigurationFile();
// check for old/compatibility cronjob file
if (file_exists(Froxlor::getInstallDir().'/scripts/froxlor_master_cronjob.php')) {
@unlink(Froxlor::getInstallDir().'/scripts/froxlor_master_cronjob.php');
@rmdir(Froxlor::getInstallDir().'/scripts');
}
// reset cronlog-flag if set to "once"
if ((int) Settings::Get('logger.log_cron') == 1) {
FroxlorLogger::getInstanceOf()->setCronLog(0);

View File

@@ -34,7 +34,7 @@ final class Froxlor
const VERSION = '2.0.0-beta1';
// Database version (YYYYMMDDC where C is a daily counter)
const DBVERSION = '202211030';
const DBVERSION = '202212060';
// Distribution branding-tag (used for Debian etc.)
const BRANDING = '';