Make the installation more robust on errors.
This commit is contained in:
@@ -201,27 +201,32 @@ else if($action==="install")
|
|||||||
*5.2 Install plugins
|
*5.2 Install plugins
|
||||||
* */
|
* */
|
||||||
|
|
||||||
|
|
||||||
|
$report = NULL;
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
require_once 'Log.php';
|
require_once 'Log.php';
|
||||||
|
|
||||||
$sp = "/";
|
$sp = "/";
|
||||||
$dir_data = $dataClient->path_data;
|
$dir_data = $dataClient->path_data;
|
||||||
//$dir_compiled = $dataClient->path_compiled;
|
|
||||||
|
|
||||||
$dir_data = (substr($dir_data,-1)==$sp)?$dir_data:$dir_data."/";
|
$dir_data = (substr($dir_data,-1)==$sp)?$dir_data:$dir_data."/";
|
||||||
$dir_compiled = $dir_data . "compiled/"; //(substr($dir_compiled,-1)==$sp)?$dir_compiled:$dir_compiled."/";
|
$dir_compiled = $dir_data . "compiled/";
|
||||||
|
$dir_log = "{$dir_data}logs/";
|
||||||
global $isWindows;
|
global $isWindows;
|
||||||
|
|
||||||
@mkdir($dir_data."sites",0777,true);
|
@mkdir($dir_data."sites",0777,true);
|
||||||
@mkdir($dir_compiled,0777,true);
|
@mkdir($dir_compiled,0777,true);
|
||||||
|
@mkdir($dir_log, 0777, true);
|
||||||
|
|
||||||
$logFile = "{$dir_data}install.log";
|
$logFilename = "{$dir_log}install.log";
|
||||||
$display = Log::singleton('display', '', 'INSTALLER', array('lineFormat' => "%{message}"));
|
$displayLog = Log::singleton('display', '', 'INSTALLER', array('lineFormat' => "%{message}"));
|
||||||
$file = Log::singleton('file', $logFile, 'INSTALLER');
|
$fileLog = Log::singleton('file', $logFilename, 'INSTALLER');
|
||||||
|
|
||||||
global $logger;
|
global $logger;
|
||||||
$logger = Log::singleton('composite');
|
$logger = Log::singleton('composite');
|
||||||
$logger->addChild($display);
|
$logger->addChild($displayLog);
|
||||||
$logger->addChild($file);
|
|
||||||
|
|
||||||
$create_db ="create-db.sql";
|
$create_db ="create-db.sql";
|
||||||
$schema ="schema.sql";
|
$schema ="schema.sql";
|
||||||
@@ -234,7 +239,6 @@ else if($action==="install")
|
|||||||
$p1 = (isset($dataClient->ao_admin_pass1))?$dataClient->ao_admin_pass1:'admin';
|
$p1 = (isset($dataClient->ao_admin_pass1))?$dataClient->ao_admin_pass1:'admin';
|
||||||
$p2 = (isset($dataClient->ao_admin_pass2))?$dataClient->ao_admin_pass2:'admin';
|
$p2 = (isset($dataClient->ao_admin_pass2))?$dataClient->ao_admin_pass2:'admin';
|
||||||
|
|
||||||
try {
|
|
||||||
$s = $inst->create_site(Array(
|
$s = $inst->create_site(Array(
|
||||||
'name' =>'workflow',
|
'name' =>'workflow',
|
||||||
'path_data'=>$dataClient->path_data,
|
'path_data'=>$dataClient->path_data,
|
||||||
@@ -253,6 +257,14 @@ else if($action==="install")
|
|||||||
'password'=>$dataClient->mysqlP
|
'password'=>$dataClient->mysqlP
|
||||||
)
|
)
|
||||||
),true);
|
),true);
|
||||||
|
if ($s['created'])
|
||||||
|
$report = $inst->report;
|
||||||
|
else
|
||||||
|
/* On a failed install, $inst->report is blank because the
|
||||||
|
* installation didnt occured at all. So we use the test report
|
||||||
|
* instead.
|
||||||
|
*/
|
||||||
|
$report = $s['result'];
|
||||||
$installError = (!$s['created']);
|
$installError = (!$s['created']);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$installError = ($e->getMessage() ? $e->getMessage() : true);
|
$installError = ($e->getMessage() ? $e->getMessage() : true);
|
||||||
@@ -264,8 +276,20 @@ else if($action==="install")
|
|||||||
/* Status is used in the Windows installer, do not change this */
|
/* Status is used in the Windows installer, do not change this */
|
||||||
print_r("Status: ".(($installError) ? 'FAILED':'SUCCESS')."\n\n");
|
print_r("Status: ".(($installError) ? 'FAILED':'SUCCESS')."\n\n");
|
||||||
|
|
||||||
$file->log("Status: ".(($installError) ? 'FAILED':'SUCCESS'));
|
/* Try to open the file log, if it fails, set it to NULL, so we don't try to
|
||||||
$display->log("This log is also avaliable in $logFile");
|
* write to it again afterwards. If it succeeds, add to the logger.
|
||||||
|
* Only open the log after writing status, otherwise a warning can be issued
|
||||||
|
* which will affect the Windows installer.
|
||||||
|
*/
|
||||||
|
if (!$fileLog->open()) {
|
||||||
|
$fileLog = NULL;
|
||||||
|
$displayLog->log("Failed to create file log in $logFilename");
|
||||||
|
} else {
|
||||||
|
$logger->addChild($fileLog);
|
||||||
|
$fileLog->log(" ** Starting installation ** ");
|
||||||
|
$fileLog->log("Status: ".(($installError) ? 'FAILED':'SUCCESS'));
|
||||||
|
$displayLog->log("This log is also avaliable in $logFilename");
|
||||||
|
}
|
||||||
|
|
||||||
$installArgs = (array)$dataClient;
|
$installArgs = (array)$dataClient;
|
||||||
$hiddenFields = array('mysqlP', 'ao_admin_pass1', 'ao_admin_pass2');
|
$hiddenFields = array('mysqlP', 'ao_admin_pass1', 'ao_admin_pass2');
|
||||||
@@ -275,20 +299,16 @@ else if($action==="install")
|
|||||||
|
|
||||||
$logger->log("Installation arguments\n" . neat_r(array($installArgs)));
|
$logger->log("Installation arguments\n" . neat_r(array($installArgs)));
|
||||||
|
|
||||||
if ($installError !== false && isset($s) && !$s['created']) {
|
if (isset($report))
|
||||||
/* On a failed install, $inst->report is blank because the
|
$logger->log("Installation report\n" . neat_r(array($report)));
|
||||||
* installation didnt occured at all. So we use the test report
|
else
|
||||||
* instead.
|
$logger->log("** No installation report **");
|
||||||
*/
|
|
||||||
$logger->log("Installation report\n" . neat_r(array($s['result'])));
|
if ($installError) {
|
||||||
|
$logger->log("Installation ending with errors");
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
$logger->log("Installation report\n" . neat_r(array($inst->report)));
|
|
||||||
|
|
||||||
if ($installError)
|
|
||||||
die();
|
|
||||||
|
|
||||||
$sh=md5(filemtime(PATH_GULLIVER."/class.g.php"));
|
$sh=md5(filemtime(PATH_GULLIVER."/class.g.php"));
|
||||||
$h=G::encrypt($dataClient->mysqlH.$sh.$dataClient->mysqlU.$sh.$dataClient->mysqlP.$sh.$inst->cc_status,$sh);
|
$h=G::encrypt($dataClient->mysqlH.$sh.$dataClient->mysqlU.$sh.$dataClient->mysqlP.$sh.$inst->cc_status,$sh);
|
||||||
$db_text = "<?php\n" .
|
$db_text = "<?php\n" .
|
||||||
@@ -321,6 +341,8 @@ else if($action==="install")
|
|||||||
if (trim(str_replace("<br>","",$update)) == "")
|
if (trim(str_replace("<br>","",$update)) == "")
|
||||||
$update = "Nothing to do.";
|
$update = "Nothing to do.";
|
||||||
$logger->log("Plugin AutoInstall => ".str_replace("<br>","\n",$update));
|
$logger->log("Plugin AutoInstall => ".str_replace("<br>","\n",$update));
|
||||||
|
|
||||||
|
$logger->log("Installation finished successfuly");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user