mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
N°2249 - Supportability - Updater module (Allow to run setup in case of failure)
This commit is contained in:
@@ -35,6 +35,7 @@ Dict::Add('EN US', 'English', 'English', array(
|
||||
'iTopUpdate:UI:Back' => 'Back',
|
||||
'iTopUpdate:UI:Cancel' => 'Cancel',
|
||||
'iTopUpdate:UI:Continue' => 'Continue',
|
||||
'iTopUpdate:UI:RunSetup' => 'Run Setup',
|
||||
'iTopUpdate:UI:WithDBBackup' => 'Database backup',
|
||||
'iTopUpdate:UI:WithFilesBackup' => 'Application files backup',
|
||||
'iTopUpdate:UI:WithoutBackup' => 'No backup is planned',
|
||||
|
||||
@@ -35,7 +35,8 @@ Dict::Add('FR FR', 'French', 'Français', array(
|
||||
'iTopUpdate:UI:Back' => 'Annuler',
|
||||
'iTopUpdate:UI:Cancel' => 'Annuler',
|
||||
'iTopUpdate:UI:Continue' => 'Continuer',
|
||||
'iTopUpdate:UI:WithDBBackup' => 'Sauvegarde de la base de données',
|
||||
'iTopUpdate:UI:RunSetup' => 'Lancer le Setup',
|
||||
'iTopUpdate:UI:WithDBBackup' => 'Sauvegarde de la base de données',
|
||||
'iTopUpdate:UI:WithFilesBackup' => 'Archive des fichiers de l\'application',
|
||||
'iTopUpdate:UI:WithoutBackup' => 'Pas de sauvegarde',
|
||||
'iTopUpdate:UI:Backup' => 'Sauvegarde effectuée avant la mise à jour',
|
||||
|
||||
@@ -79,6 +79,7 @@ class AjaxController extends Controller
|
||||
$aParams = array();
|
||||
try
|
||||
{
|
||||
SetupUtils::CheckSetupToken();
|
||||
SetupUtils::EnterReadOnlyMode(MetaModel::GetConfig());
|
||||
$iResponseCode = 200;
|
||||
} catch (Exception $e)
|
||||
@@ -95,6 +96,7 @@ class AjaxController extends Controller
|
||||
$aParams = array();
|
||||
try
|
||||
{
|
||||
SetupUtils::CheckSetupToken(true);
|
||||
SetupUtils::ExitReadOnlyMode();
|
||||
$iResponseCode = 200;
|
||||
} catch (Exception $e)
|
||||
@@ -111,6 +113,7 @@ class AjaxController extends Controller
|
||||
$aParams = array();
|
||||
try
|
||||
{
|
||||
SetupUtils::CheckSetupToken();
|
||||
CoreUpdater::Backup();
|
||||
$iResponseCode = 200;
|
||||
} catch (Exception $e)
|
||||
@@ -127,6 +130,7 @@ class AjaxController extends Controller
|
||||
$aParams = array();
|
||||
try
|
||||
{
|
||||
SetupUtils::CheckSetupToken();
|
||||
CoreUpdater::CreateItopArchive();
|
||||
$iResponseCode = 200;
|
||||
} catch (Exception $e)
|
||||
@@ -143,6 +147,7 @@ class AjaxController extends Controller
|
||||
$aParams = array();
|
||||
try
|
||||
{
|
||||
SetupUtils::CheckSetupToken();
|
||||
CoreUpdater::CopyCoreFiles();
|
||||
$iResponseCode = 200;
|
||||
} catch (Exception $e)
|
||||
@@ -160,6 +165,7 @@ class AjaxController extends Controller
|
||||
$aParams = array();
|
||||
try
|
||||
{
|
||||
SetupUtils::CheckSetupToken();
|
||||
CoreUpdater::CheckCompile();
|
||||
$iResponseCode = 200;
|
||||
}
|
||||
@@ -178,6 +184,7 @@ class AjaxController extends Controller
|
||||
$aParams = array();
|
||||
try
|
||||
{
|
||||
SetupUtils::CheckSetupToken();
|
||||
CoreUpdater::Compile();
|
||||
$iResponseCode = 200;
|
||||
}
|
||||
@@ -196,6 +203,7 @@ class AjaxController extends Controller
|
||||
$aParams = array();
|
||||
try
|
||||
{
|
||||
SetupUtils::CheckSetupToken();
|
||||
CoreUpdater::UpdateDatabase();
|
||||
$iResponseCode = 200;
|
||||
}
|
||||
|
||||
@@ -140,6 +140,15 @@ class UpdateController extends Controller
|
||||
$this->DisplayPage($aParams);
|
||||
}
|
||||
|
||||
public function OperationRunSetup()
|
||||
{
|
||||
SetupUtils::CheckSetupToken(true);
|
||||
$sConfigFile = APPCONF.'production/'.ITOP_CONFIG_FILE;
|
||||
@chmod($sConfigFile, 0770);
|
||||
$sRedirectURL = utils::GetAbsoluteUrlAppRoot().'setup/index.php';
|
||||
header("Location: $sRedirectURL");
|
||||
}
|
||||
|
||||
private function GetPreviousInstallations()
|
||||
{
|
||||
return DBToolsUtils::GetPreviousInstallations();
|
||||
|
||||
@@ -78,6 +78,11 @@
|
||||
<span>{{ 'iTopUpdate:UI:RestoreBackup'|dict_format(sBackupFile) }}</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
<form enctype="multipart/form-data" method="post">
|
||||
<input type="hidden" name="operation" value="RunSetup"/>
|
||||
<input type="hidden" name="authent" value="{{ sSetupToken }}">
|
||||
<p><input id="run_setup" type="submit" value="{{ 'iTopUpdate:UI:RunSetup'|dict_s }}" disabled/></p>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<form enctype="multipart/form-data" method="post">
|
||||
|
||||
@@ -91,7 +91,6 @@ function ExecNextStep() {
|
||||
setTimeout(ExecNextStep, 500);
|
||||
})
|
||||
.fail(function ( jqXHR) {
|
||||
$("#setup_continue").removeAttr("disabled");
|
||||
if (jqXHR && jqXHR.responseJSON) {
|
||||
$("#setup_error").html({{ 'iTopUpdate:Error:UpdateFailed'|dict_s|json_encode|raw }}+" "+jqXHR.responseJSON.sError);
|
||||
}
|
||||
@@ -101,6 +100,7 @@ function ExecNextStep() {
|
||||
}
|
||||
$('.progress').css("background-image", "none").css("background-color", "#fcc");
|
||||
$("#setup_error_outer").show();
|
||||
$("#setup_continue").hide();
|
||||
})
|
||||
;
|
||||
}
|
||||
|
||||
15
index.php
15
index.php
@@ -17,9 +17,18 @@ if (file_exists(dirname(__FILE__).'/'.$sConfigFile))
|
||||
}
|
||||
else if (is_writable($sConfigFile))
|
||||
{
|
||||
echo "<p><b>Security Warning</b>: the configuration file '$sConfigFile' should be read-only.</p>";
|
||||
echo "<p>Please modify the access rights to this file.</p>";
|
||||
echo "<p>Click <a href=\"$sStartPage\">here</a> to ignore this warning and continue to run iTop.</p>";
|
||||
require_once (APPROOT.'setup/setuputils.class.inc.php');
|
||||
if (SetupUtils::IsInReadOnlyMode())
|
||||
{
|
||||
echo "<p><b>Warning</b>: the application is currently in maintenance, please wait.</p>";
|
||||
echo "<p>Click <a href=\"$sStartPage\">here</a> to ignore this warning and continue to run iTop in read-only mode.</p>";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<p><b>Security Warning</b>: the configuration file '$sConfigFile' should be read-only.</p>";
|
||||
echo "<p>Please modify the access rights to this file.</p>";
|
||||
echo "<p>Click <a href=\"$sStartPage\">here</a> to ignore this warning and continue to run iTop.</p>";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -26,8 +26,6 @@ require_once(APPROOT.'/setup/wizardcontroller.class.inc.php');
|
||||
require_once(APPROOT.'/setup/wizardsteps.class.inc.php');
|
||||
|
||||
clearstatcache(); // Make sure we know what we are doing !
|
||||
SetupUtils::ExitMaintenanceMode(false); // Reset maintenance mode in case of problem
|
||||
SetupUtils::ExitReadOnlyMode(false); // Reset readonly mode in case of problem
|
||||
// Set a long (at least 4 minutes) execution time for the setup to avoid timeouts during this phase
|
||||
ini_set('max_execution_time', max(240, ini_get('max_execution_time')));
|
||||
// While running the setup it is desirable to see any error that may happen
|
||||
|
||||
@@ -2030,15 +2030,22 @@ JS
|
||||
/**
|
||||
* Verify Setup authentication token (from the request parameter 'authent')
|
||||
*
|
||||
* @param bool $bRemoveToken
|
||||
*
|
||||
* @throws \SecurityException
|
||||
*/
|
||||
public final static function CheckSetupToken()
|
||||
public final static function CheckSetupToken($bRemoveToken = false)
|
||||
{
|
||||
$sAuthent = utils::ReadParam('authent', '', false, 'raw_data');
|
||||
if (!file_exists(APPROOT.'data/setup/authent') || $sAuthent !== file_get_contents(APPROOT.'data/setup/authent'))
|
||||
$sTokenFile = APPROOT.'data/setup/authent';
|
||||
if (!file_exists($sTokenFile) || $sAuthent !== file_get_contents($sTokenFile))
|
||||
{
|
||||
throw new SecurityException('Setup operations are not allowed outside of the setup');
|
||||
}
|
||||
if ($bRemoveToken)
|
||||
{
|
||||
@unlink($sTokenFile);
|
||||
}
|
||||
}
|
||||
|
||||
private final static function Log($sText)
|
||||
|
||||
@@ -173,6 +173,9 @@ class WizardController
|
||||
// The configuration file already exists
|
||||
if (!is_writable($sConfigFile))
|
||||
{
|
||||
SetupUtils::ExitMaintenanceMode(false); // Reset maintenance mode in case of problem
|
||||
SetupUtils::ExitReadOnlyMode(false); // Reset readonly mode in case of problem
|
||||
|
||||
$sRelativePath = utils::GetConfigFilePathRelative();
|
||||
$oP = new SetupPage('Installation Cannot Continue');
|
||||
$oP->add("<h2>Fatal error</h2>\n");
|
||||
@@ -643,4 +646,4 @@ class Step3 extends WizardStep
|
||||
}
|
||||
}
|
||||
|
||||
End of the example */
|
||||
End of the example */
|
||||
|
||||
Reference in New Issue
Block a user