added cronjob-auto-update-feature (beware and READ), fixes #1342; remove old backup-ftp-users on update, fixes #1381

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2014-02-25 07:48:46 +01:00
parent e650be3814
commit d00cdec296
10 changed files with 103 additions and 21 deletions

View File

@@ -29,6 +29,14 @@ return array(
'default' => '/etc/cron.d/froxlor',
'save_method' => 'storeSettingField',
),
'system_croncmdline' => array(
'label' => $lng['serversettings']['system_croncmdline'],
'settinggroup' => 'system',
'varname' => 'croncmdline',
'type' => 'string',
'default' => '/usr/bin/nice -n 5 /usr/bin/php5 -q',
'save_method' => 'storeSettingField',
),
'system_crondreload' => array(
'label' => $lng['serversettings']['system_crondreload'],
'settinggroup' => 'system',
@@ -36,7 +44,15 @@ return array(
'type' => 'string',
'default' => '/etc/init.d/cron reload',
'save_method' => 'storeSettingField',
),
),
'system_cron_allowautoupdate' => array(
'label' => $lng['serversettings']['system_cron_allowautoupdate'],
'settinggroup' => 'system',
'varname' => 'cron_allowautoupdate',
'type' => 'bool',
'default' => false,
'save_method' => 'storeSettingField',
),
'system_debug_cron' => array(
'label' => $lng['serversettings']['cron']['debug'],
'settinggroup' => 'system',

View File

@@ -501,6 +501,8 @@ INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES
('system', 'mailtraffic_enabled', '1'),
('system', 'cronconfig', '/etc/cron.d/froxlor'),
('system', 'crondreload', '/etc/init.d/cron reload'),
('system', 'croncmdline', '/usr/bin/nice -n 5 /usr/bin/php5 -q'),
('system', 'cron_allowautoupdate', '0'),
('panel', 'decimal_places', '4'),
('panel', 'adminmail', 'admin@SERVERNAME'),
('panel', 'phpmyadmin_url', ''),
@@ -528,7 +530,7 @@ INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES
('panel', 'phpconfigs_hidestdsubdomain', '0'),
('panel', 'allow_theme_change_admin', '1'),
('panel', 'allow_theme_change_customer', '1'),
('panel', 'version', '0.9.32-rc1');
('panel', 'version', '0.9.32-rc2');
DROP TABLE IF EXISTS `panel_tasks`;

View File

@@ -275,7 +275,7 @@ class FroxlorInstall {
$navigation = '';
$msgcolor = 'red';
$message = $this->_lng['install']['testing_mysql_fail'];
$link = 'install.php';
$link = 'install.php?check=1';
$linktext = $this->_lng['click_here_to_goback'];
} else {
// all good

View File

@@ -2727,3 +2727,29 @@ if (isFroxlorVersion('0.9.32-dev6')) {
updateToVersion('0.9.32-rc1');
}
if (isFroxlorVersion('0.9.32-rc1')) {
showUpdateStep("Updating from 0.9.32-rc1 to 0.9.32-rc2", false);
showUpdateStep("Removing autoresponder-cronjob (deprecated)");
Database::query("DELETE FROM `".TABLE_PANEL_CRONRUNS."` WHERE `module` = 'froxlor/autoresponder';");
lastStepStatus(0);
showUpdateStep("Adding new settings for cron");
// get user-chosen value
$croncmdline = isset($_POST['croncmdline']) ? $_POST['croncmdline'] : "/usr/bin/nice -n 5 /usr/bin/php5 -q";
Settings::AddNew("system.croncmdline", $croncmdline);
// add task to generate cron.d-file
inserttask('99');
// silenty add the auto-update setting - we do not want everybody to know and use this
// as it is a very dangerous setting
Settings::AddNew("system.cron_allowautoupdate", 0);
lastStepStatus(0);
showUpdateStep("Removing backup-module ftp-users (deprecated)");
Database::query("DELETE FROM `".TABLE_FTP_USERS."` WHERE `username` LIKE '%_backup';");
lastStepStatus(0);
updateToVersion('0.9.32-rc2');
}

View File

@@ -650,4 +650,12 @@ function parseAndOutputPreconfig(&$has_preconfig, &$return, $current_version) {
eval("\$return.=\"" . getTemplate("update/preconfigitem") . "\";");
}
if (versionInUpdate($current_version, '0.9.32-rc2')) {
$has_preconfig = true;
$description = 'To customize the command which executes the cronjob (php - basically) change the path below according to your system.<br /><br />';
$question = '<strong>Please specify the command to execute cronscripts</strong> (default: "/usr/bin/nice -n 5 /usr/bin/php5 -q")<br />';
$question.= '<input type="text" class="text" name="croncmdline" value="/usr/bin/nice -n 5 /usr/bin/php5 -q" /><br />';
eval("\$return.=\"" . getTemplate("update/preconfigitem") . "\";");
}
}

View File

@@ -64,7 +64,7 @@ $lockDirHandle = opendir($lockdir);
while ($fName = readdir($lockDirHandle)) {
if ($lockFilename == substr($fName, 0, strlen($lockFilename))
&& $lockfName != $fName
&& $lockfName != $fName
) {
// Check if last run jailed out with an exception
$croncontent = file($lockdir . $fName);
@@ -169,19 +169,44 @@ if (((int)Settings::Get('system.mod_fcgid') == 1 && (int)Settings::Get('system.m
// be sure HTMLPurifier's cache folder is writable
safe_exec('chmod -R 0755 '.escapeshellarg(dirname(__FILE__).'/classes/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer'));
// Initialize logging
$cronlog = FroxlorLogger::getInstanceOf(array('loginname' => 'cronjob'));
fwrite($debugHandler, 'Logger has been included' . "\n");
if (Settings::Get('panel.version') == null
|| Settings::Get('panel.version') != $version
|| Settings::Get('panel.version') != $version
) {
/**
* Do not proceed further if the Database version is not the same as the script version
*/
fclose($debugHandler);
unlink($lockfile);
$errormessage = "Version of file doesnt match version of database. Exiting...\n\n";
$errormessage.= "Possible reason: Froxlor update\n";
$errormessage.= "Information: Current version in database: ".Settings::Get('panel.version')." - version of Froxlor files: ".$version."\n";
$errormessage.= "Solution: Please visit your Foxlor admin interface for further information.\n";
die($errormessage);
if (Settings::Get('system.cron_allowautoupdate') == null
|| Settings::Get('system.cron_allowautoupdate') == 0
) {
/**
* Do not proceed further if the Database version is not the same as the script version
*/
fclose($debugHandler);
unlink($lockfile);
$errormessage = "Version of file doesnt match version of database. Exiting...\n\n";
$errormessage.= "Possible reason: Froxlor update\n";
$errormessage.= "Information: Current version in database: ".Settings::Get('panel.version')." - version of Froxlor files: ".$version."\n";
$errormessage.= "Solution: Please visit your Foxlor admin interface for further information.\n";
die($errormessage);
}
if (Settings::Get('system.cron_allowautoupdate') == 1) {
/**
* let's walk the walk - do the dangerous shit
*/
$cronlog->logAction(CRON_ACTION, LOG_WARNING, 'Automatic update is activated and we are going to proceed without any notices');
$cronlog->logAction(CRON_ACTION, LOG_WARNING, 'all new settings etc. will be stored with the default value, that might not always be right for your system!');
$cronlog->logAction(CRON_ACTION, LOG_WARNING, 'If you dont want this to happen in the future consider removing the --allow-autoupdate flag from the cronjob');
fwrite($debugHandler, '*** WARNING *** - Automatic update is activated and we are going to proceed without any notices' . "\n");
fwrite($debugHandler, '*** WARNING *** - all new settings etc. will be stored with the default value, that might not always be right for your system!' . "\n");
fwrite($debugHandler, '*** WARNING *** - If you dont want this to happen in the future consider removing the --allow-autoupdate flag from the cronjob' . "\n");
// including update procedures
include_once FROXLOR_INSTALL_DIR.'/install/updatesql.php';
// pew - everything went better than expected
$cronlog->logAction(CRON_ACTION, LOG_WARNING, 'Automatic update done - you should check your settings to be sure everything is fine');
fwrite($debugHandler, '*** WARNING *** - Automatic update done - you should check your settings to be sure everything is fine' . "\n");
}
}
fwrite($debugHandler, 'Froxlor version and database version are correct' . "\n");
@@ -191,9 +216,5 @@ $cronscriptDebug = (Settings::Get('system.debug_cron') == '1') ? true : false;
// Create a new idna converter
$idna_convert = new idna_convert_wrapper();
// Initialize logging
$cronlog = FroxlorLogger::getInstanceOf(array('loginname' => 'cronjob'));
fwrite($debugHandler, 'Logger has been included' . "\n");
// check for cron.d-generation task and create it if necessary
checkCrondConfigurationFile();

View File

@@ -80,7 +80,12 @@ function checkCrondConfigurationFile() {
}
// create entry-line
$binpath = "/usr/bin/nice -n 5 /usr/bin/php5 -q";
$binpath = Settings::Get("system.croncmdline");
// fallback as it is important
if ($binpath === null) {
$binpath = "/usr/bin/nice -n 5 /usr/bin/php5 -q";
}
$cronfile .= "root " . $binpath." " . FROXLOR_INSTALL_DIR . "/scripts/froxlor_master_cronjob.php --" . $row_cronentry['cronfile'] . " 1> /dev/null\n";
}
}

View File

@@ -51,6 +51,6 @@ define('TABLE_PANEL_DOMAIN_SSL_SETTINGS', 'domain_ssl_settings');
define('TABLE_DOMAINTOIP', 'panel_domaintoip');
// VERSION INFO
$version = '0.9.32-rc1';
$version = '0.9.32-rc2';
$dbversion = '2';
$branding = '';

View File

@@ -1815,3 +1815,5 @@ $lng['serversettings']['system_croncmdline']['title'] = 'Cron execution command
$lng['serversettings']['system_croncmdline']['description'] = 'Command to execute our cronjobs. Change this only if you know what you are doing (default: "/usr/bin/nice -n 5 /usr/bin/php5 -q")!';
$lng['error']['cannotdeletehostnamephpconfig'] = 'This PHP-configuration is used by the Froxlor-vhost and cannot be deleted.';
$lng['error']['cannotdeletedefaultphpconfig'] = 'This PHP-configuration is set as default and cannot be deleted.';
$lng['serversettings']['system_cron_allowautoupdate']['title'] = 'Allow automatic database updates';
$lng['serversettings']['system_cron_allowautoupdate']['description'] = '<div style="color:red"><b>ATTENTION:</b></div> This settings allows the cronjob to bypass the version-check of froxlors files and database and runs the database-updates in case a version-mismatch occurs.<br><br><div style="color:red">Auto-update will always set default values for new settings or changes. This might not always suite your system. Please think twice before activating this option</div>';

View File

@@ -1540,3 +1540,5 @@ $lng['serversettings']['system_croncmdline']['title'] = 'Cron Startbefehl (php P
$lng['serversettings']['system_croncmdline']['description'] = 'Befehl zum Ausführen des Cronjobs. Ändern dieser Einstellung nur wenn nötig (Standard: "/usr/bin/nice -n 5 /usr/bin/php5 -q")!';
$lng['error']['cannotdeletehostnamephpconfig'] = 'Diese PHP-Konfiguration ist dem Froxlor-Vhost zugewiesen und kann daher nicht gelöscht werden.';
$lng['error']['cannotdeletedefaultphpconfig'] = 'Diese PHP-Konfiguration ist als Standard hinterlegt und kann daher nicht gelöscht werden.';
$lng['serversettings']['system_cron_allowautoupdate']['title'] = 'Erlaube automatische Datenbank-Aktualisierungen';
$lng['serversettings']['system_cron_allowautoupdate']['description'] = '<div style="color:red"><b>WARNUNG:</b></div> Diese Einstellung erlaubt es dem Cronjob die Prüfung der Dateien- und Datenbank-Version zu umgehen und bei einem Versions-Unterschied die Datenbank-Aktualisierungen automatisiert auszuführen.<br><br><div style="color:red">Das automatische Update setzt für neue Einstellungen und Änderungen immer die default-Werte. Diese müssen nicht zwingend zu dem genutzten System passen. Bitte zwei mal nachdenken, bevor diese Option aktiviert wird.</div>';