Skip to content
Snippets Groups Projects
Commit dfa90b8a authored by Jared Hancock's avatar Jared Hancock
Browse files

Installer uses the streams config

Allow the installation to use the same streams config and schema signatures
as the migrater

Allow the install to install mulitple database streams
parent df5d2cbb
Branches
Tags
No related merge requests found
...@@ -81,10 +81,13 @@ class DatabaseMigrater { ...@@ -81,10 +81,13 @@ class DatabaseMigrater {
* update is triggered and the patches in the stream folder are used to * update is triggered and the patches in the stream folder are used to
* upgrade the database. * upgrade the database.
*/ */
/* static */ function getUpgradeStreams($basedir) { /* static */
function getUpgradeStreams($basedir) {
static $streams = array(); static $streams = array();
if ($streams) return $streams; if ($streams) return $streams;
// TODO: Make the hash algo configurable in the streams
// configuration ( core : md5 )
$config = @file_get_contents($basedir.'/streams.cfg'); $config = @file_get_contents($basedir.'/streams.cfg');
if (!$config) $config = 'core'; if (!$config) $config = 'core';
foreach (explode("\n", $config) as $line) { foreach (explode("\n", $config) as $line) {
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
vim: expandtab sw=4 ts=4 sts=4: vim: expandtab sw=4 ts=4 sts=4:
**********************************************************************/ **********************************************************************/
require_once INCLUDE_DIR.'class.migrater.php';
require_once INCLUDE_DIR.'class.setup.php'; require_once INCLUDE_DIR.'class.setup.php';
class Installer extends SetupWizard { class Installer extends SetupWizard {
...@@ -109,24 +110,34 @@ class Installer extends SetupWizard { ...@@ -109,24 +110,34 @@ class Installer extends SetupWizard {
define('ADMIN_EMAIL',$vars['admin_email']); //Needed to report SQL errors during install. define('ADMIN_EMAIL',$vars['admin_email']); //Needed to report SQL errors during install.
define('PREFIX',$vars['prefix']); //Table prefix define('PREFIX',$vars['prefix']); //Table prefix
$schemaFile =INC_DIR.'sql/osTicket-mysql.sql'; //DB dump. $debug = true; // Change it to false to squelch SQL errors.
$debug = true; //XXX:Change it to true to show SQL errors.
//Last minute checks. //Last minute checks.
if(!file_exists($schemaFile) || !($fp = fopen($schemaFile, 'rb'))) if(!file_exists($this->getConfigFile()) || !($configFile=file_get_contents($this->getConfigFile())))
$this->errors['err']='Internal Error - please make sure your download is the latest (#1)';
elseif(
!($signature=trim(file_get_contents("$schemaFile.sig")))
|| !($hash=md5(fread($fp, filesize($schemaFile))))
|| strcasecmp($signature, $hash))
$this->errors['err']='Unknown or invalid schema signature ('
.$signature.' .. '.$hash.')';
elseif(!file_exists($this->getConfigFile()) || !($configFile=file_get_contents($this->getConfigFile())))
$this->errors['err']='Unable to read config file. Permission denied! (#2)'; $this->errors['err']='Unable to read config file. Permission denied! (#2)';
elseif(!($fp = @fopen($this->getConfigFile(),'r+'))) elseif(!($fp = @fopen($this->getConfigFile(),'r+')))
$this->errors['err']='Unable to open config file for writing. Permission denied! (#3)'; $this->errors['err']='Unable to open config file for writing. Permission denied! (#3)';
elseif(!$this->load_sql_file($schemaFile,$vars['prefix'], true, $debug))
$this->errors['err']='Error parsing SQL schema! Get help from developers (#4)'; else {
foreach (DatabaseMigrater::getUpgradeStreams(INCLUDE_DIR.'upgrader/streams/')
as $stream=>$signature) {
$schemaFile = INC_DIR."streams/$stream/install-mysql.sql";
if (!file_exists($schemaFile) || !($fp2 = fopen($schemaFile, 'rb')))
$this->errors['err'] = $stream
. ': Internal Error - please make sure your download is the latest (#1)';
elseif (
// TODO: Make the hash algo configurable in the streams
// configuration ( core : md5 )
!($hash = md5(fread($fp2, filesize($schemaFile))))
|| strcasecmp($signature, $hash))
$this->errors['err'] = $stream
.': Unknown or invalid schema signature ('
.$signature.' .. '.$hash.')';
elseif (!$this->load_sql_file($schemaFile, $vars['prefix'], true, $debug))
$this->errors['err'] = $stream
.': Error parsing SQL schema! Get help from developers (#4)';
}
}
$sql='SELECT `id` FROM '.PREFIX.'sla ORDER BY `id` LIMIT 1'; $sql='SELECT `id` FROM '.PREFIX.'sla ORDER BY `id` LIMIT 1';
$sla_id_1 = db_result(db_query($sql, false), 0); $sla_id_1 = db_result(db_query($sql, false), 0);
...@@ -173,6 +184,7 @@ class Installer extends SetupWizard { ...@@ -173,6 +184,7 @@ class Installer extends SetupWizard {
//Create config settings---default settings! //Create config settings---default settings!
//XXX: rename ostversion helpdesk_* ?? //XXX: rename ostversion helpdesk_* ??
// XXX: Some of this can go to the core install file
$defaults = array('isonline'=>'0', 'default_email_id'=>$support_email_id, $defaults = array('isonline'=>'0', 'default_email_id'=>$support_email_id,
'alert_email_id'=>$alert_email_id, 'default_dept_id'=>$dept_id_1, 'default_sla_id'=>$sla_id_1, 'alert_email_id'=>$alert_email_id, 'default_dept_id'=>$dept_id_1, 'default_sla_id'=>$sla_id_1,
'default_timezone_id'=>$eastern_timezone, 'default_template_id'=>$template_id_1, 'default_timezone_id'=>$eastern_timezone, 'default_template_id'=>$template_id_1,
......
740428f9986da6ad85f88ec841b57bfe
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment