From 71e2f37b3d86898868d804d8ca67269cebada4eb Mon Sep 17 00:00:00 2001 From: Jarrett Jordaan Date: Mon, 9 Nov 2009 15:07:16 +0200 Subject: [PATCH] Updated source only install 'Configuration Step'. Removed redundant 'Install Type Step'. Updated ini class. Updated utilities class. Updated Open Office Service install --- dmsctl.sh | 2 +- setup/wizard/config/config.xml | 2 +- setup/wizard/iniUtilities.php | 30 +++++++++++------------------- setup/wizard/installUtil.php | 73 ++++++++++++++++++++++++++++++++++++------------------------------------- setup/wizard/lib/services/unixScheduler.php | 6 +++--- setup/wizard/steps/complete.php | 3 --- setup/wizard/steps/configuration.php | 56 ++++++++++++++++++++++++++++++++++---------------------- setup/wizard/steps/database.php | 4 ++-- setup/wizard/steps/registration.php | 4 ++-- setup/wizard/templates/complete.tpl | 10 +--------- 10 files changed, 91 insertions(+), 99 deletions(-) diff --git a/dmsctl.sh b/dmsctl.sh index 026ea5c..80b00ea 100755 --- a/dmsctl.sh +++ b/dmsctl.sh @@ -32,7 +32,7 @@ SOFFICE_PIDFILE=$INSTALL_PATH/var/log/soffice.bin.pid SOFFICE_PID="" SOFFICE_PORT="8100" SOFFICEBIN=/usr/bin/soffice -SOFFICE="$SOFFICEBIN -nofirststartwizard -nologo -headless -accept=socket,host=127.0.0.1,port=$SOFFICE_PORT;urp;StarOffice.ServiceManager" +SOFFICE="$SOFFICEBIN -nofirststartwizard -nologo -headless -\"accept=socket,host=127.0.0.1,port=$SOFFICE_PORT;urp;StarOffice.ServiceManager\"" SOFFICE_STATUS="" # Lucene diff --git a/setup/wizard/config/config.xml b/setup/wizard/config/config.xml index 8a2ac31..8aa533b 100644 --- a/setup/wizard/config/config.xml +++ b/setup/wizard/config/config.xml @@ -11,7 +11,7 @@ welcome license - installtype + dependencies configuration services diff --git a/setup/wizard/iniUtilities.php b/setup/wizard/iniUtilities.php index 9a963d5..b7e336e 100644 --- a/setup/wizard/iniUtilities.php +++ b/setup/wizard/iniUtilities.php @@ -43,21 +43,15 @@ class iniUtilities { private $lineNum = 0; private $exists = ''; - function load($iniFile) { -// if($this->iniFile != $iniFile) { - $this->cleanArray = array(); - $this->lineNum = 0; - $this->exists = ''; -// } + $this->cleanArray = array(); $this->iniFile = $iniFile; + $this->lineNum = 0; + $this->exists = ''; $this->backupIni($iniFile); $this->read($iniFile); } -// function __construct() { -// } - /** * Create a backup with the date as an extension in the same location as the original config.ini * @@ -125,25 +119,23 @@ class iniUtilities { } function write($iniFile = "") { - if(empty($iniFile)) { $iniFile = $this->iniFile; } if (!is_writeable($iniFile)) { return; } - $fileHandle = fopen($iniFile, 'wb'); foreach ($this->cleanArray as $section => $items) { if (substr($section, 0, strlen('_blankline_')) === '_blankline_' ) { - @fwrite ($fileHandle, "\r\n"); + fwrite ($fileHandle, "\r\n"); continue; } if (substr($section, 0, strlen('_comment_')) === '_comment_' ) { - @fwrite ($fileHandle, "$items\r\n"); + fwrite ($fileHandle, "$items\r\n"); continue; } - @fwrite ($fileHandle, "[".$section."]\r\n"); + fwrite ($fileHandle, "[".$section."]\r\n"); foreach ($items as $key => $value) { if (substr($key, 0, strlen('_blankline_')) === '_blankline_' ) { fwrite ($fileHandle, "\r\n"); @@ -155,11 +147,10 @@ class iniUtilities { } $value = addcslashes($value,''); - //fwrite ($fileHandle, $key.' = "'.$value."\"\r\n"); - @fwrite ($fileHandle, $key.' = '.$value."\r\n"); + fwrite ($fileHandle, $key.' = '.$value."\r\n"); } } - @fclose($fileHandle); + fclose($fileHandle); } function itemExists($checkSection, $checkItem) { @@ -195,10 +186,11 @@ class iniUtilities { } function updateItem($addSection, $addItem, $value) { - if(WINDOWS_OS) + if(WINDOWS_OS) { $this->cleanArray[$addSection][$addItem] = $value; - else + } else { $this->cleanArray[$addSection][$addItem] = stripcslashes($value); + } return true; } diff --git a/setup/wizard/installUtil.php b/setup/wizard/installUtil.php index d3102fd..99fb4ca 100644 --- a/setup/wizard/installUtil.php +++ b/setup/wizard/installUtil.php @@ -264,11 +264,13 @@ class InstallUtil { */ public function checkPermission($dir, $create=false, $file = false) { - if(!$file) + if(!$file) { $exist = 'Directory doesn\'t exist'; - else + } else { $exist = 'File doesn\'t exist'; + } $write = 'Directory not writable'; + $fwrite = 'File not writable'; $ret = array('class' => 'cross'); if(!file_exists($dir)){ @@ -298,7 +300,11 @@ class InstallUtil { } $this->done = false; - $ret['msg'] = $write; + if(!$file) { + $ret['msg'] = $write; + } else { + $ret['msg'] = $fwrite; + } return $ret; } @@ -364,13 +370,13 @@ class InstallUtil { * @return boolean */ public function canWriteFile($filename) { - $fh = @fopen($filename, "w+"); - $fr = @fwrite($fh, 'test'); + $fh = fopen($filename, "w+"); + $fr = fwrite($fh, 'test'); if($fr === false) { return false; } - @fclose($fh); + fclose($fh); return true; } @@ -518,23 +524,23 @@ class InstallUtil { } /** - * Check if system needs to be migrated + * Check if system needs to be accessed * * @author KnowledgeTree Team * @access public * @param none * @return boolean */ - public function migrationSpecified() { - if(isset($_POST['installtype'])) { - if($_POST['installtype'] == "Upgrade Installation") { + public function finishSpecified() { + if(isset($_GET['Finish'])) { + if($_GET['Finish'] == "Finish") { return true; } } return false; - } - + } + /** * Check if system needs to be migrated * @@ -543,27 +549,9 @@ class InstallUtil { * @param none * @return boolean */ - public function upgradeSpecified() { + public function migrationSpecified() { if(isset($_POST['installtype'])) { - if($_POST['installtype'] == "Upgrade Only") { - return true; - } - } - - return false; - } - - /** - * Check if system needs to be migrated - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return boolean - */ - public function loginSpecified() { - if(isset($_GET['completeType'])) { - if($_GET['completeType'] == "Login") { + if($_POST['installtype'] == "Upgrade Installation") { return true; } } @@ -579,9 +567,9 @@ class InstallUtil { * @param none * @return boolean */ - public function zendSpecified() { - if(isset($_GET['completeType'])) { - if($_GET['completeType'] == "Zend Server Configuration") { + public function upgradeSpecified() { + if(isset($_POST['installtype'])) { + if($_POST['installtype'] == "Upgrade Only") { return true; } } @@ -607,8 +595,6 @@ class InstallUtil { return false; } - - /** * Get session data from package * @@ -808,6 +794,19 @@ class InstallUtil { public function sqlInstallDir() { return SYSTEM_DIR."sql".DS."mysql".DS."install".DS; } + + public function getFileByLine($file) { + $fileLines = array(); + $file_handle = fopen($file, "rb"); + while (!feof($file_handle) ) { + $line_of_text = fgets($file_handle); + $parts = explode('=', $line_of_text); + $fileLines[] = $line_of_text; + } + fclose($file_handle); + return $fileLines; + } + /** * Portably execute a command on any of the supported platforms. * diff --git a/setup/wizard/lib/services/unixScheduler.php b/setup/wizard/lib/services/unixScheduler.php index eeb10be..5f393ae 100644 --- a/setup/wizard/lib/services/unixScheduler.php +++ b/setup/wizard/lib/services/unixScheduler.php @@ -108,7 +108,7 @@ class unixScheduler extends unixService { function writeSchedulerTask() { $fLoc = $this->getSchedulerDir().$this->getSchedulerSource(); - $fp = @fopen($fLoc, "w+"); + $fp = fopen($fLoc, "w+"); $content = "#!/bin/sh\n"; $content .= "cd ".SYS_BIN_DIR."\n"; $content .= "while true; do\n"; @@ -116,8 +116,8 @@ class unixScheduler extends unixService { $content .= "{$this->phpCli} -Cq scheduler.php\n"; $content .= "sleep 30\n"; $content .= "done"; - @fwrite($fp, $content); - @fclose($fp); + fwrite($fp, $content); + fclose($fp); } function install() { diff --git a/setup/wizard/steps/complete.php b/setup/wizard/steps/complete.php index 014b71d..a8a233d 100644 --- a/setup/wizard/steps/complete.php +++ b/setup/wizard/steps/complete.php @@ -54,7 +54,6 @@ class complete extends Step { private $database_check = 'tick'; private $migrate_check = false; public $silent = true; - private $install_environment = 'Zend'; private $servicesValidation = false; function doStep() { @@ -68,7 +67,6 @@ class complete extends Step { $this->checkDb(); // check database $this->checkServices(); // check services $this->checkInstallType();// Set silent mode variables - $this->install_environment = $this->util->installEnvironment(); // Determine installation environment $this->storeSilent();// Set silent mode variables } @@ -239,7 +237,6 @@ class complete extends Step { $this->temp_variables['privileges_check'] = $this->privileges_check; $this->temp_variables['database_check'] = $this->database_check; $this->temp_variables['migrate_check'] = $this->migrate_check; - $this->temp_variables['install_environment'] = $this->install_environment; $this->temp_variables['servicesValidation'] = $this->servicesValidation; } } diff --git a/setup/wizard/steps/configuration.php b/setup/wizard/steps/configuration.php index d7c22be..6aaa841 100644 --- a/setup/wizard/steps/configuration.php +++ b/setup/wizard/steps/configuration.php @@ -252,6 +252,12 @@ class configuration extends Step $paths = $this->getPathInfo($server['file_system_root']['value']); if(!$edit) $this->temp_variables['paths'] = $paths; + // Rewrite file system root + if(!$this->fpath) { + $froot = $this->temp_variables['server']['file_system_root']['value']; + $this->temp_variables['server']['file_system_root']['value'] = 'default'; + } + return $this->done; } @@ -295,6 +301,7 @@ class configuration extends Step */ public function installStep() { + $this->file_system_root = realpath(SYSTEM_DIR); $conf = $this->getDataFromSession("configuration"); // get data from the server $dbconf = $this->getDataFromSession("database"); $this->util->dbUtilities->load($dbconf['dhost'], $dbconf['dport'], $dbconf['dmsname'], $dbconf['dmspassword'], $dbconf['dname']); @@ -382,6 +389,7 @@ class configuration extends Step { $script = $_SERVER['SCRIPT_NAME']; $file_system_root = realpath(SYSTEM_DIR); + $this->file_system_root = $file_system_root; $host = $_SERVER['SERVER_NAME']; $port = $_SERVER['SERVER_PORT']; $ssl_enabled = isset($_SERVER['HTTPS']) ? (strtolower($_SERVER['HTTPS']) === 'on' ? 'yes' : 'no') : 'no'; @@ -394,12 +402,7 @@ class configuration extends Step $ssl_enabled = (isset($_POST['ssl_enabled'])) ? $_POST['ssl_enabled'] : $ssl_enabled; $server = array(); $server['root_url'] = array('name' => 'Root Url', 'setting' => 'rootUrl', 'where' => 'db', 'value' => $root_url); - if(!$this->fpath) { - $system_root = 'default'; - } else { - $system_root = $file_system_root; - } - $server['file_system_root'] = array('name' => 'File System Root', 'section' => 'KnowledgeTree', 'setting' => 'fileSystemRoot', 'where' => 'file', 'value' => $system_root); + $server['file_system_root'] = array('name' => 'File System Root', 'section' => 'KnowledgeTree', 'setting' => 'fileSystemRoot', 'where' => 'file', 'value' => $file_system_root); $server['host'] = array('name' => 'Host', 'setting' => 'server_name', 'where' => 'db', 'value' => $host); $server['port'] = array('name' => 'Port', 'setting' => 'server_port', 'where' => 'db', 'value' => $port); $server['ssl_enabled'] = array('name' => 'SSL Enabled', 'section' => 'KnowledgeTree', 'setting' => 'sslEnabled', 'where' => 'file', 'value' => $ssl_enabled); @@ -573,10 +576,9 @@ class configuration extends Step if(!$configPath) { return false; } - $this->util->iniUtilities->load($configPath); - $data = $this->util->iniUtilities->getFileByLine(); + $data = $this->util->getFileByLine($configPath); $firstline = true; - foreach ($data as $k=>$v) { + foreach ($data as $k) { if(preg_match('/config.ini/', $k)) { // Find config.ini if($k == "config/config.ini") { // Source install and source upgrades $configIniPath = realpath(SYSTEM_DIR.$k); @@ -595,10 +597,9 @@ class configuration extends Step if(!$cachePath) { return false; } - $this->util->iniUtilities->load($cachePath); - $data = $this->util->iniUtilities->getFileByLine(); + $data = $this->util->getFileByLine($cachePath); $firstline = true; - foreach ($data as $k=>$v) { + foreach ($data as $k) { if(preg_match('/cache/', $k)) { // Find config.ini if($k == "var/cache") { // Source install and source upgrades $configIniPath = realpath(SYSTEM_DIR.$k); @@ -623,10 +624,9 @@ class configuration extends Step private function readConfigPath() { $configPath = $this->getContentPath(); if(!$configPath) return false; - $this->util->iniUtilities->load($configPath); - $data = $this->util->iniUtilities->getFileByLine(); + $data = $this->util->getFileByLine($configPath); $firstline = true; - foreach ($data as $k=>$v) { + foreach ($data as $k) { if($firstline) { // First line holds the var directory $firstline = false; if(!preg_match('/config.ini/', $k)) { // Make sure it is not the old config.ini @@ -651,7 +651,11 @@ class configuration extends Step $this->confpaths['tmp'] = $k; } } - + // Source Installs + if($this->confpaths['configIni'] == 'config/config.ini') { + $this->confpaths['configIni'] = $this->file_system_root .DS. $this->confpaths['configIni']; + } + return true; } @@ -664,16 +668,24 @@ class configuration extends Step * @return boolean */ private function writeConfigPath($configPath, $configContent) { - $fp = @fopen($configPath, 'w+'); - if(@fwrite($fp, $configContent)) - return true; + if($configContent == 'config/config.ini') { + $configContent = $this->file_system_root . DS . 'config/config.ini'; + } + $fp = fopen($configPath, 'w+'); + if($configContent != '' && $fp) { + if(fwrite($fp, $configContent)) + return true; + } return false; } private function writeCachePath($cachePath, $cacheContent) { - $fp = @fopen($cachePath, 'w+'); - if($cacheContent != '') { - if(@fwrite($fp, $cacheContent)) + if($cacheContent == 'var/cache') { + $cacheContent = $this->file_system_root . DS . 'var/cache'; + } + $fp = fopen($cachePath, 'w+'); + if($cacheContent != '' && $fp) { + if(fwrite($fp, $cacheContent)) return true; } return false; diff --git a/setup/wizard/steps/database.php b/setup/wizard/steps/database.php index 87b54be..b00ca73 100644 --- a/setup/wizard/steps/database.php +++ b/setup/wizard/steps/database.php @@ -734,7 +734,7 @@ class database extends Step } private function parse_mysql_dump($url) { - $handle = @fopen($url, "r"); + $handle = fopen($url, "r"); $query = ""; if ($handle) { while (!feof($handle)) { @@ -744,7 +744,7 @@ class database extends Step $query = ''; } } - @fclose($handle); + fclose($handle); } return true; diff --git a/setup/wizard/steps/registration.php b/setup/wizard/steps/registration.php index 751c0ba..dd883e9 100644 --- a/setup/wizard/steps/registration.php +++ b/setup/wizard/steps/registration.php @@ -183,7 +183,7 @@ class registration extends Step $params['http']['header'] = $optional_headers; } $ctx = stream_context_create($params); - $fp = @fopen($url, 'r', false, $ctx); + $fp = fopen($url, 'r', false, $ctx); if (!$fp) { throw new Exception("Problem with $url, $php_errormsg"); } @@ -192,7 +192,7 @@ class registration extends Step fclose($fp); throw new Exception("Problem reading data from $url, $php_errormsg"); } - @fclose($fp); + fclose($fp); return $response; } diff --git a/setup/wizard/templates/complete.tpl b/setup/wizard/templates/complete.tpl index c90db95..1b59b8f 100644 --- a/setup/wizard/templates/complete.tpl +++ b/setup/wizard/templates/complete.tpl @@ -25,7 +25,7 @@

cd KnowledgeTree_Installation_Folder
- dmsctl.bat install + dmsctl.bat install
dmsctl.bat start cd /usr/share/knowledgetree-ce
@@ -162,13 +162,5 @@ Finish - - - - js('form.js'); } ?> \ No newline at end of file -- libgit2 0.21.4