From 71ceb5dd37c1947e9194ed6cf76217cbc96efc2a Mon Sep 17 00:00:00 2001 From: Jarrett Jordaan Date: Tue, 6 Oct 2009 17:00:37 +0200 Subject: [PATCH] Story Id:1166869 Daily Commit --- setup/migrate/dbUtil.php | 261 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- setup/migrate/index.php | 1 + setup/migrate/lib/services/service.php | 64 ---------------------------------------------------------------- setup/migrate/lib/services/unixAgent.php | 51 --------------------------------------------------- setup/migrate/lib/services/unixLucene.php | 203 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- setup/migrate/lib/services/unixOpenOffice.php | 145 ------------------------------------------------------------------------------------------------------------------------------------------------- setup/migrate/lib/services/unixScheduler.php | 175 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- setup/migrate/lib/services/unixService.php | 148 ---------------------------------------------------------------------------------------------------------------------------------------------------- setup/migrate/lib/services/windowsAgent.php | 51 --------------------------------------------------- setup/migrate/lib/services/windowsLucene.php | 375 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- setup/migrate/lib/services/windowsOpenOffice.php | 162 ------------------------------------------------------------------------------------------------------------------------------------------------------------------ setup/migrate/lib/services/windowsScheduler.php | 199 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- setup/migrate/lib/services/windowsService.php | 181 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- setup/migrate/migrateUtil.php | 537 +++++++++++++++++++++++++++++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- setup/migrate/migrateWizard.php | 6 +++--- setup/migrate/migrater.php | 7 +++++++ setup/migrate/steps/migrateComplete.php | 49 ++++++++++++++++++++++++++++++++++++++++++------- setup/migrate/steps/migrateDatabase.php | 190 ++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------------------------------------------------------------------------------------------------- setup/migrate/steps/migrateServices.php | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------- setup/migrate/templates/complete.tpl | 65 +++++++++++++++++++++++++++++------------------------------------ setup/migrate/templates/database.tpl | 5 ++++- setup/migrate/templates/services.tpl | 8 +++----- setup/wizard/dbUtil.php | 3 +++ setup/wizard/index.php | 1 + setup/wizard/lib/services/unixOpenOffice.php | 41 +++++++++++++---------------------------- setup/wizard/migrate.lock | 0 setup/wizard/path.php | 15 +++++++++++++-- 27 files changed, 238 insertions(+), 2791 deletions(-) delete mode 100644 setup/migrate/dbUtil.php delete mode 100644 setup/migrate/lib/services/service.php delete mode 100644 setup/migrate/lib/services/unixAgent.php delete mode 100644 setup/migrate/lib/services/unixLucene.php delete mode 100644 setup/migrate/lib/services/unixOpenOffice.php delete mode 100644 setup/migrate/lib/services/unixScheduler.php delete mode 100644 setup/migrate/lib/services/unixService.php delete mode 100644 setup/migrate/lib/services/windowsAgent.php delete mode 100644 setup/migrate/lib/services/windowsLucene.php delete mode 100644 setup/migrate/lib/services/windowsOpenOffice.php delete mode 100644 setup/migrate/lib/services/windowsScheduler.php delete mode 100644 setup/migrate/lib/services/windowsService.php create mode 100644 setup/wizard/migrate.lock diff --git a/setup/migrate/dbUtil.php b/setup/migrate/dbUtil.php deleted file mode 100644 index d552918..0000000 --- a/setup/migrate/dbUtil.php +++ /dev/null @@ -1,261 +0,0 @@ -. -* -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, -* California 94120-7775, or email info@knowledgetree.com. -* -* The interactive user interfaces in modified source and object code versions -* of this program must display Appropriate Legal Notices, as required under -* Section 5 of the GNU General Public License version 3. -* -* In accordance with Section 7(b) of the GNU General Public License version 3, -* these Appropriate Legal Notices must retain the display of the "Powered by -* KnowledgeTree" logo and retain the original copyright notice. If the display of the -* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices -* must display the words "Powered by KnowledgeTree" and retain the original -* copyright notice. -* -* @copyright 2008-2009, KnowledgeTree Inc. -* @license GNU General Public License version 3 -* @author KnowledgeTree Team -* @package Migrater -* @version Version 0.1 -*/ -class dbUtil { - /** - * Host - * - * @author KnowledgeTree Team - * @access protected - * @var string - */ - protected $dbhost = ''; - - /** - * Host - * - * @author KnowledgeTree Team - * @access protected - * @var string - */ - protected $dbname = ''; - - /** - * Host - * - * @author KnowledgeTree Team - * @access protected - * @var string - */ - protected $dbuname = ''; - - /** - * Host - * - * @author KnowledgeTree Team - * @access protected - * @var string - */ - protected $dbpassword = ''; - - /** - * Host - * - * @author KnowledgeTree Team - * @access protected - * @var object mysql connection - */ - protected $dbconnection = ''; - - /** - * Any errors encountered - * - * @author KnowledgeTree Team - * @access protected - * @var array - */ - protected $error = array(); - - /** - * Constructs database connection object - * - * @author KnowledgeTree Team - * @access public - */ - public function __construct() { - - } - - public function load($dhost = 'localhost', $duname, $dpassword, $dbname) { - $this->dbhost = $dhost; - $this->dbuname = $duname; - $this->dbpassword = $dpassword; - $this->dbconnection = @mysql_connect($dhost, $duname, $dpassword); - if($dbname != '') { - $this->setDb($dbname); - $this->useDb($dbname); - } - if($this->dbconnection) - return $this->dbconnection; - else { - $this->error[] = @mysql_error($this->dbconnection); - return false; - } - } - - /** - * Choose a database to use - * - * @param string $dbname name of the database - * @access public - * @return boolean - */ - public function useDb($dbname = '') { - if($dbname != '') { - $this->setDb($dbname); - } - - if(@mysql_select_db($this->dbname, $this->dbconnection)) - return true; - else { - $this->error[] = @mysql_error($this->dbconnection); - return false; - } - } - - public function setDb($dbname) { - $this->dbname = $dbname; - } - - /** - * Query the database. - * - * @param $query the sql query. - * @access public - * @return object The result of the query. - */ - public function query($query) { - $result = @mysql_query($query, $this->dbconnection); - if($result) { - return $result; - } else { - $this->error[] = @mysql_error($this->dbconnection); - return false; - } - } - - /** - * Do the same as query. - * - * @param $query the sql query. - * @access public - * @return boolean - */ - public function execute($query) { - $result = @mysql_query($query, $this->dbconnection); - if($result) { - return true; - } else { - $this->error[] = @mysql_error($this->dbconnection); - return false; - } - } - - /** - * Convenience method for mysql_fetch_object(). - * - * @param $result The resource returned by query(). - * @access public - * @return object An object representing a data row. - */ - public function fetchNextObject($result = NULL) { - if ($result == NULL || @mysql_num_rows($result) < 1) - return NULL; - else - return @mysql_fetch_object($result); - } - - /** - * Convenience method for mysql_fetch_assoc(). - * - * @param $result The resource returned by query(). - * @access public - * @return array Returns an associative array of strings. - */ - public function fetchAssoc($result = NULL) { - $r = array(); - if ($result == NULL || @mysql_num_rows($result) < 1) - return NULL; - else { - $row = @mysql_fetch_assoc($result); - while ($row) { - $r[] = $row; - } - return $r; - } - } - - /** - * Close the connection with the database server. - * - * @param none. - * @access public - * @return void. - */ - public function close() { - @mysql_close($this->dbconnection); - } - - /** - * Get database errors. - * - * @param none. - * @access public - * @return array. - */ - public function getErrors() { - return $this->error; - } - - /** - * Fetches the last generated error - - * @return string - */ - function getLastError() { - return end($this->error); - } - - /** - * Start a database transaction - */ - public function startTransaction() { - $this->query("START TRANSACTION"); - } - - /** - * Roll back a database transaction - */ - public function rollback() { - $this->query("ROLLBACK"); - } -} -?> \ No newline at end of file diff --git a/setup/migrate/index.php b/setup/migrate/index.php index e95dda7..3f80899 100644 --- a/setup/migrate/index.php +++ b/setup/migrate/index.php @@ -39,5 +39,6 @@ * @package Migrater * @version Version 0.1 */ +$_GET['type'] = 'migrate'; require_once("migrateWizard.php"); ?> \ No newline at end of file diff --git a/setup/migrate/lib/services/service.php b/setup/migrate/lib/services/service.php deleted file mode 100644 index 97f897b..0000000 --- a/setup/migrate/lib/services/service.php +++ /dev/null @@ -1,64 +0,0 @@ -. -* -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, -* California 94120-7775, or email info@knowledgetree.com. -* -* The interactive user interfaces in modified source and object code versions -* of this program must display Appropriate Legal Notices, as required under -* Section 5 of the GNU General Public License version 3. -* -* In accordance with Section 7(b) of the GNU General Public License version 3, -* these Appropriate Legal Notices must retain the display of the "Powered by -* KnowledgeTree" logo and retain the original copyright notice. If the display of the -* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices -* must display the words "Powered by KnowledgeTree" and retain the original -* copyright notice. -* -* @copyright 2008-2009, KnowledgeTree Inc. -* @license GNU General Public License version 3 -* @author KnowledgeTree Team -* @package Migrater -* @version Version 0.1 -*/ - -class Service { - public function __construct() {} - - public function load() {} - - public function start() {} - - public function stop() {} - - public function migrate() {} - - public function restart() {} - - public function unmigrate() {} - - public function status() {} - - public function pause() {} - - public function cont() {} -} -?> \ No newline at end of file diff --git a/setup/migrate/lib/services/unixAgent.php b/setup/migrate/lib/services/unixAgent.php deleted file mode 100644 index 955b203..0000000 --- a/setup/migrate/lib/services/unixAgent.php +++ /dev/null @@ -1,51 +0,0 @@ -. -* -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, -* California 94120-7775, or email info@knowledgetree.com. -* -* The interactive user interfaces in modified source and object code versions -* of this program must display Appropriate Legal Notices, as required under -* Section 5 of the GNU General Public License version 3. -* -* In accordance with Section 7(b) of the GNU General Public License version 3, -* these Appropriate Legal Notices must retain the display of the "Powered by -* KnowledgeTree" logo and retain the original copyright notice. If the display of the -* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices -* must display the words "Powered by KnowledgeTree" and retain the original -* copyright notice. -* -* @copyright 2008-2009, KnowledgeTree Inc. -* @license GNU General Public License version 3 -* @author KnowledgeTree Team -* @package Migrater -* @version Version 0.1 -*/ - -class unixAgent extends unixService { - - public function __construct() { - $this->name = "KTAgentTest"; - } - - -} -?> \ No newline at end of file diff --git a/setup/migrate/lib/services/unixLucene.php b/setup/migrate/lib/services/unixLucene.php deleted file mode 100644 index 85cc296..0000000 --- a/setup/migrate/lib/services/unixLucene.php +++ /dev/null @@ -1,203 +0,0 @@ -. -* -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, -* California 94120-7775, or email info@knowledgetree.com. -* -* The interactive user interfaces in modified source and object code versions -* of this program must display Appropriate Legal Notices, as required under -* Section 5 of the GNU General Public License version 3. -* -* In accordance with Section 7(b) of the GNU General Public License version 3, -* these Appropriate Legal Notices must retain the display of the "Powered by -* KnowledgeTree" logo and retain the original copyright notice. If the display of the -* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices -* must display the words "Powered by KnowledgeTree" and retain the original -* copyright notice. -* -* @copyright 2008-2009, KnowledgeTree Inc. -* @license GNU General Public License version 3 -* @author KnowledgeTree Team -* @package Migrater -* @version Version 0.1 -*/ - -class unixLucene extends unixService { - public $util; - private $shutdownScript; - private $indexerDir; - private $lucenePidFile; - private $luceneDir; - private $luceneSource; - private $luceneSourceLoc; - private $javaXms; - private $javaXmx; - - public function __construct() { - $this->name = "KTLuceneTest"; - $this->setLuceneSource("ktlucene.jar"); - $this->util = new MigrateUtil(); - } - - public function load() { - $this->setLuceneDir(SYSTEM_DIR."bin".DS."luceneserver".DS); - $this->setIndexerDir(SYSTEM_DIR."search2".DS."indexing".DS."bin".DS); - $this->setLucenePidFile("lucene_test.pid"); - $this->setJavaXms(512); - $this->setJavaXmx(512); - $this->setLuceneSourceLoc("ktlucene.jar"); - $this->setShutdownScript("shutdown.php"); - } - - public function setIndexerDir($indexerDir) { - $this->indexerDir = $indexerDir; - } - - private function getIndexerDir() { - return $this->indexerDir; - } - - private function setShutdownScript($shutdownScript) { - $this->shutdownScript = $shutdownScript; - } - - public function getShutdownScript() { - return $this->shutdownScript; - } - - private function setLucenePidFile($lucenePidFile) { - $this->lucenePidFile = $lucenePidFile; - } - - private function getLucenePidFile() { - return $this->lucenePidFile; - } - - private function setLuceneDir($luceneDir) { - $this->luceneDir = $luceneDir; - } - - public function getLuceneDir() { - return $this->luceneDir; - } - - private function setJavaXms($javaXms) { - $this->javaXms = "-Xms$javaXms"; - } - - public function getJavaXms() { - return $this->javaXms; - } - - private function setJavaXmx($javaXmx) { - $this->javaXmx = "-Xmx$javaXmx"; - } - - public function getJavaXmx() { - return $this->javaXmx; - } - - private function setLuceneSource($luceneSource) { - $this->luceneSource = $luceneSource; - } - - public function getLuceneSource() { - return $this->luceneSource; - } - - private function setLuceneSourceLoc($luceneSourceLoc) { - $this->luceneSourceLoc = $this->getLuceneDir().$luceneSourceLoc; - } - - public function getLuceneSourceLoc() { - return $this->luceneSourceLoc; - } - - public function getJavaOptions() { - return " {$this->getJavaXmx()} {$this->getJavaXmx()} -jar "; - } - - public function stop() { - // TODO: Breaks things - $state = $this->status(); - if($state != '') { - $cmd = "pkill -f ".$this->getLuceneSource(); - $response = $this->util->pexec($cmd); - return $response; - } - - } - - public function migrate() { - $status = $this->status(); - if($status == '') { - return $this->start(); - } else { - return $status; - } - } - - public function status() { - $cmd = "ps ax | grep ".$this->getLuceneSource(); - $response = $this->util->pexec($cmd); - if(is_array($response['out'])) { - if(count($response['out']) > 1) { - foreach ($response['out'] as $r) { - preg_match('/grep/', $r, $matches); // Ignore grep - if(!$matches) { - return 'STARTED'; - } - } - } else { - return ''; - } - } - - return ''; - } - - public function unmigrate() { - $this->stop(); - } - - public function start() { - $state = $this->status(); - return ; - if($state != 'STARTED') { - $cmd = "cd ".$this->getLuceneDir()."; "; - $cmd .= "nohup java -jar ".$this->getLuceneSource()." > ".SYS_LOG_DIR."lucene.log 2>&1 & echo $!"; - $response = $this->util->pexec($cmd); - - return $response; - } elseif ($state == '') { - // Start Service - return true; - } else { - // Service Running Already - return true; - } - - return false; - } - - -} -?> \ No newline at end of file diff --git a/setup/migrate/lib/services/unixOpenOffice.php b/setup/migrate/lib/services/unixOpenOffice.php deleted file mode 100644 index e5ca691..0000000 --- a/setup/migrate/lib/services/unixOpenOffice.php +++ /dev/null @@ -1,145 +0,0 @@ -. -* -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, -* California 94120-7775, or email info@knowledgetree.com. -* -* The interactive user interfaces in modified source and object code versions -* of this program must display Appropriate Legal Notices, as required under -* Section 5 of the GNU General Public License version 3. -* -* In accordance with Section 7(b) of the GNU General Public License version 3, -* these Appropriate Legal Notices must retain the display of the "Powered by -* KnowledgeTree" logo and retain the original copyright notice. If the display of the -* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices -* must display the words "Powered by KnowledgeTree" and retain the original -* copyright notice. -* -* @copyright 2008-2009, KnowledgeTree Inc. -* @license GNU General Public License version 3 -* @author KnowledgeTree Team -* @package Migrater -* @version Version 0.1 -*/ - -class unixOpenOffice extends unixService { - - // utility - public $util; - // path to office - private $path; - // host - private $host; - // pid running - private $pidFile; - // port to bind to - private $port; - // bin folder - private $bin; - // office executable - private $soffice; - // office log file - private $log; - private $options; - - # nohup /home/jarrett/ktdms/openoffice/program/soffice.bin -nofirststartwizard -nologo -headless -accept=socket,host=127.0.0.1,port=8100;urp;StarOffice.ServiceManager &> /home/jarrett/ktdms/var/log/dmsctl.log & - public function __construct() { - $this->name = "openoffice"; - $this->util = new MigrateUtil(); - } - - public function load() { - $this->setPort("8100"); - $this->setHost("localhost"); - $this->setLog("openoffice.log"); - $this->setBin("soffice"); - $this->setOption(); - } - - private function setPort($port = "8100") { - $this->port = $port; - } - - public function getPort() { - return $this->port; - } - - private function setHost($host = "localhost") { - $this->host = $host; - } - - public function getHost() { - return $this->host; - } - - private function setLog($log = "openoffice.log") { - $this->log = $log; - } - - public function getLog() { - return $this->log; - } - - private function setBin($bin = "soffice") { - $this->bin = $bin; - } - - public function getBin() { - return $this->bin; - } - - private function setOption() { - $this->options = "-nofirststartwizard -nologo -headless -accept=\"socket,host={$this->getHost()},port={$this->getPort()};urp;StarOffice.ServiceManager\""; - } - - public function getOption() { - return $this->options; - } - - public function migrate() { - $status = $this->status(); - if($status == '') { - return $this->start(); - } else { - return $status; - } - } - - public function start() { - $state = $this->status(); - return ; - if($state != 'STARTED') { - $cmd = "nohup {$this->getBin()} ".$this->getOption()." > ".SYS_LOG_DIR."{$this->getLog()} 2>&1 & echo $!"; - $response = $this->util->pexec($cmd); - - return $response; - } elseif ($state == '') { - // Start Service - return true; - } else { - // Service Running Already - return true; - } - - return false; - } -} -?> \ No newline at end of file diff --git a/setup/migrate/lib/services/unixScheduler.php b/setup/migrate/lib/services/unixScheduler.php deleted file mode 100644 index 19e57cf..0000000 --- a/setup/migrate/lib/services/unixScheduler.php +++ /dev/null @@ -1,175 +0,0 @@ -. -* -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, -* California 94120-7775, or email info@knowledgetree.com. -* -* The interactive user interfaces in modified source and object code versions -* of this program must display Appropriate Legal Notices, as required under -* Section 5 of the GNU General Public License version 3. -* -* In accordance with Section 7(b) of the GNU General Public License version 3, -* these Appropriate Legal Notices must retain the display of the "Powered by -* KnowledgeTree" logo and retain the original copyright notice. If the display of the -* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices -* must display the words "Powered by KnowledgeTree" and retain the original -* copyright notice. -* -* @copyright 2008-2009, KnowledgeTree Inc. -* @license GNU General Public License version 3 -* @author KnowledgeTree Team -* @package Migrater -* @version Version 0.1 -*/ - -class unixScheduler extends unixService { - private $schedulerDir; - private $schedulerSource; - private $schedulerSourceLoc; - private $systemDir; - - public function __construct() { - $this->name = "KTSchedulerTest"; - $this->util = new MigrateUtil(); - } - - public function load() { - $this->setSystemDir(SYSTEM_ROOT."bin".DS); - $this->setSchedulerDir(SYSTEM_DIR."bin".DS); - $this->setSchedulerSource('schedulerTask.sh'); - $this->setSchedulerSourceLoc('schedulerTask.sh'); - } - - function setSystemDir($systemDir) { - $this->systemDir = $systemDir; - } - - function getSystemDir() { - if(file_exists($this->systemDir)) - return $this->systemDir; - return false; - } - - function setSchedulerDir($schedulerDir) { - $this->schedulerDir = $schedulerDir; - } - - function getSchedulerDir() { - return $this->schedulerDir; - } - - function setSchedulerSource($schedulerSource) { - $this->schedulerSource = $schedulerSource; - } - - function getSchedulerSource() { - return $this->schedulerSource; - } - - function setSchedulerSourceLoc($schedulerSourceLoc) { - $this->schedulerSourceLoc = $this->getSchedulerDir().$schedulerSourceLoc; - } - - function getSchedulerSourceLoc() { - if(file_exists($this->schedulerSourceLoc)) - return $this->schedulerSourceLoc; - return false; - } - - function writeSchedulerTask() { - $fLoc = $this->getSchedulerDir().$this->getSchedulerSource(); - $fp = @fopen($fLoc, "w+"); - $content = "#!/bin/sh\n"; - $content .= "cd ".$this->getSchedulerDir()."\n"; - $content .= "while true; do\n"; - // TODO : This will not work without CLI - $content .= "php -Cq scheduler.php\n"; - $content .= "sleep 30\n"; - $content .= "done"; - @fwrite($fp, $content); - @fclose($fp); - @chmod($fLoc, '0644'); - } - - function migrate() { - $status = $this->status(); - if($status == '') { - return $this->start(); - } else { - return $status; - } - } - - function unmigrate() { - $this->stop(); - } - - function stop() { - $cmd = "pkill -f ".$this->schedulerSource; - $response = $this->util->pexec($cmd); - return $response; - } - - function status() { - $cmd = "ps ax | grep ".$this->getSchedulerSource(); - $response = $this->util->pexec($cmd); - if(is_array($response['out'])) { - if(count($response['out']) > 1) { - foreach ($response['out'] as $r) { - preg_match('/grep/', $r, $matches); // Ignore grep - if(!$matches) { - return 'STARTED'; - } - } - } else { - return ''; - } - } - - return ''; - } - - function start() { - // TODO : Write sh on the fly? Not sure the reasoning here - $source = $this->getSchedulerSourceLoc(); - return ; - if($source) { // Source - $cmd = "nohup ".$source." > ".SYS_LOG_DIR."scheduler.log 2>&1 & echo $!"; - $response = $this->util->pexec($cmd); - return $response; - } else { // Could be Stack - $source = SYS_BIN_DIR.$this->schedulerSource; - if(!file_exists($source)) { - // Write it - $this->writeSchedulerTask(); - } - $cmd = "nohup ".$source." > ".SYS_LOG_DIR."scheduler.log 2>&1 & echo $!"; - $response = $this->util->pexec($cmd); - return $response; - } - - return false; - } - - - -} -?> \ No newline at end of file diff --git a/setup/migrate/lib/services/unixService.php b/setup/migrate/lib/services/unixService.php deleted file mode 100644 index ccdd912..0000000 --- a/setup/migrate/lib/services/unixService.php +++ /dev/null @@ -1,148 +0,0 @@ -. -* -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, -* California 94120-7775, or email info@knowledgetree.com. -* -* The interactive user interfaces in modified source and object code versions -* of this program must display Appropriate Legal Notices, as required under -* Section 5 of the GNU General Public License version 3. -* -* In accordance with Section 7(b) of the GNU General Public License version 3, -* these Appropriate Legal Notices must retain the display of the "Powered by -* KnowledgeTree" logo and retain the original copyright notice. If the display of the -* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices -* must display the words "Powered by KnowledgeTree" and retain the original -* copyright notice. -* -* @copyright 2008-2009, KnowledgeTree Inc. -* @license GNU General Public License version 3 -* @author KnowledgeTree Team -* @package Migrater -* @version Version 0.1 -*/ - -class unixService extends Service { - public $name; - - /** - * Retrieve Service name - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return string - */ - public function getName() { - return $this->name; - } - - public function load() {} - - /** - * Start Service - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return mixed - */ - public function start() { - - } - - /** - * Stop Service - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return mixed - */ - public function stop() { - - } - - public function migrate() {} - - /** - * Restart Service - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return mixed - */ - public function restart() { - - } - - /** - * Unmigrate Service - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return mixed - */ - public function unmigrate() { - - } - - /** - * Retrieve Status Service - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return mixed - */ - public function status() { - - } - - /** - * Pause Service - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return mixed - */ - public function pause() { - - } - - /** - * Continue Service - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return mixed - */ - public function cont() { - - } - - -} -?> \ No newline at end of file diff --git a/setup/migrate/lib/services/windowsAgent.php b/setup/migrate/lib/services/windowsAgent.php deleted file mode 100644 index b21aed4..0000000 --- a/setup/migrate/lib/services/windowsAgent.php +++ /dev/null @@ -1,51 +0,0 @@ -. -* -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, -* California 94120-7775, or email info@knowledgetree.com. -* -* The interactive user interfaces in modified source and object code versions -* of this program must display Appropriate Legal Notices, as required under -* Section 5 of the GNU General Public License version 3. -* -* In accordance with Section 7(b) of the GNU General Public License version 3, -* these Appropriate Legal Notices must retain the display of the "Powered by -* KnowledgeTree" logo and retain the original copyright notice. If the display of the -* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices -* must display the words "Powered by KnowledgeTree" and retain the original -* copyright notice. -* -* @copyright 2008-2009, KnowledgeTree Inc. -* @license GNU General Public License version 3 -* @author KnowledgeTree Team -* @package Migrater -* @version Version 0.1 -*/ - -class windowsAgent extends windowsService { - - - public function __construct() { - $this->name = "KTAgentTest"; - } - -} -?> \ No newline at end of file diff --git a/setup/migrate/lib/services/windowsLucene.php b/setup/migrate/lib/services/windowsLucene.php deleted file mode 100644 index 7ca55e1..0000000 --- a/setup/migrate/lib/services/windowsLucene.php +++ /dev/null @@ -1,375 +0,0 @@ -. -* -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, -* California 94120-7775, or email info@knowledgetree.com. -* -* The interactive user interfaces in modified source and object code versions -* of this program must display Appropriate Legal Notices, as required under -* Section 5 of the GNU General Public License version 3. -* -* In accordance with Section 7(b) of the GNU General Public License version 3, -* these Appropriate Legal Notices must retain the display of the "Powered by -* KnowledgeTree" logo and retain the original copyright notice. If the display of the -* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices -* must display the words "Powered by KnowledgeTree" and retain the original -* copyright notice. -* -* @copyright 2008-2009, KnowledgeTree Inc. -* @license GNU General Public License version 3 -* @author KnowledgeTree Team -* @package Migrater -* @version Version 0.1 -*/ -class windowsLucene extends windowsService { - /** - * Java Directory path - * - * @author KnowledgeTree Team - * @access private - * @var string - */ - private $javaBin; - - /** - * Java JVM path - * - * @author KnowledgeTree Team - * @access private - * @var string - */ - private $javaJVM; - - /** - * Java System object - * - * @author KnowledgeTree Team - * @access private - * @var object - */ - private $javaSystem; - - /** - * Lucene executable path - * - * @author KnowledgeTree Team - * @access private - * @var string - */ - private $luceneExe; - - /** - * Lucene jar path - * - * @author KnowledgeTree Team - * @access private - * @var string - */ - private $luceneSource; - - /** - * Lucene package name - * - * @author KnowledgeTree Team - * @access private - * @var string - */ - private $luceneServer; - - /** - * Lucene output log path - * - * @author KnowledgeTree Team - * @access private - * @var string - */ - private $luceneOut; - - /** - * Lucene error log path - * - * @author KnowledgeTree Team - * @access private - * @var string - */ - private $luceneError; - - /** - * Lucene directory path - * - * @author KnowledgeTree Team - * @access private - * @var string - */ - private $luceneDir; - - /** - * Load defaults needed by service - * - * @author KnowledgeTree Team - * @access public - * @param string - * @return void - */ - public function load() { - $this->name = "KTLuceneTest"; - $this->javaSystem = new Java('java.lang.System'); - $this->setJavaBin($this->javaSystem->getProperty('java.home').DS."bin"); - $this->setLuceneDIR(SYSTEM_DIR."bin".DS."luceneserver"); - $this->setLuceneExe("KTLuceneService.exe"); - $this->setJavaJVM(); - $this->setLuceneSource("ktlucene.jar"); - $this->setLuceneServer("com.knowledgetree.lucene.KTLuceneServer"); - $this->setLuceneOut("lucene-out.txt"); - $this->setLuceneError("lucene-err.txt"); - } - - /** - * Set Java Directory path - * - * @author KnowledgeTree Team - * @access private - * @param string - * @return void - */ - private function setJavaBin($javaBin) { - $this->javaBin = $javaBin; - } - - /** - * Get Java Directory path - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return string - */ - public function getJavaBin() { - return $this->javaBin; - } - - /** - * Set Lucene directory path - * - * @author KnowledgeTree Team - * @access private - * @param string - * @return void - */ - private function setLuceneDIR($luceneDir) { - $this->luceneDir = $luceneDir; - } - - /** - * Get Lucene directory path - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return string - */ - public function getluceneDir() { - if(file_exists($this->luceneDir)) - return $this->luceneDir; - return false; - } - - /** - * Set Lucene executable path - * - * @author KnowledgeTree Team - * @access private - * @param string - * @return void - */ - private function setLuceneExe($luceneExe) { - $this->luceneExe = $this->getluceneDir().DS.$luceneExe; - } - - /** - * Get Lucene executable path - * - * @author KnowledgeTree Team - * @access public - * @param string - * @return void - */ - public function getLuceneExe() { - if(file_exists($this->luceneExe)) - return $this->luceneExe; - return false; - } - - /** - * Set Lucene source path - * - * @author KnowledgeTree Team - * @access private - * @param string - * @return void - */ - private function setLuceneSource($luceneSource) { - $this->luceneSource = $this->getluceneDir().DS.$luceneSource; - } - - /** - * Get Lucene source path - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return string - */ - public function getLuceneSource() { - if(file_exists($this->luceneSource)) - return $this->luceneSource; - return false; - } - - /** - * Set Lucene package name - * - * @author KnowledgeTree Team - * @access private - * @param string - * @return void - */ - private function setLuceneServer($luceneServer) { - $this->luceneServer = $luceneServer; - } - - /** - * Get Lucene package name - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return string - */ - public function getLuceneServer() { - return $this->luceneServer; - } - - /** - * Set Lucene output file path - * - * @author KnowledgeTree Team - * @access private - * @param string - * @return void - */ - private function setLuceneOut($luceneOut) { - $this->luceneOut = SYS_LOG_DIR.$luceneOut; - } - - /** - * Get Lucene output file path - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return string - */ - public function getLuceneOut() { - return $this->luceneOut; - } - - /** - * Set Lucene error file path - * - * @author KnowledgeTree Team - * @access private - * @param string - * @return void - */ - private function setLuceneError($luceneError) { - $this->luceneError = SYS_LOG_DIR.$luceneError; - } - - /** - * Get Lucene error file path - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return string - */ - public function getLuceneError() { - return $this->luceneError; - } - - /** - * Set Java JVM path - * - * @author KnowledgeTree Team - * @access private - * @param string - * @return void - */ - private function setJavaJVM() { - if(file_exists($this->getJavaBin().DS."client".DS."jvm.dll")) { - $this->javaJVM = $this->getJavaBin().DS."client".DS."jvm.dll"; - } elseif (file_exists($this->getJavaBin().DS."server".DS."jvm.dll")) { - $this->javaJVM = $this->getJavaBin().DS."server".DS."jvm.dll"; - } else { - return false; - } - } - - /** - * Get Java JVM path - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return string - */ - public function getJavaJVM() { - return $this->javaJVM; - } - - /** - * Migrate Lucene Service - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return array - */ - function migrate() { - $state = $this->status(); - if($state == '') { - $luceneExe = $this->getLuceneExe(); - $luceneSource = $this->getLuceneSource(); - $luceneDir = $this->getluceneDir(); - if($luceneExe && $luceneSource && $luceneDir) { - $cmd = "\"{$luceneExe}\""." -migrate \"".$this->getName()."\" \"".$this->getJavaJVM(). "\" -Djava.class.path=\"".$luceneSource."\"". " -start ".$this->getLuceneServer(). " -out \"".$this->getLuceneOut()."\" -err \"".$this->getLuceneError()."\" -current \"".$luceneDir."\" -auto"; - $response = $this->util->pexec($cmd); - return $response; - } - return $state; - } - - return $state; - } - -} -?> \ No newline at end of file diff --git a/setup/migrate/lib/services/windowsOpenOffice.php b/setup/migrate/lib/services/windowsOpenOffice.php deleted file mode 100644 index cac5825..0000000 --- a/setup/migrate/lib/services/windowsOpenOffice.php +++ /dev/null @@ -1,162 +0,0 @@ -. -* -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, -* California 94120-7775, or email info@knowledgetree.com. -* -* The interactive user interfaces in modified source and object code versions -* of this program must display Appropriate Legal Notices, as required under -* Section 5 of the GNU General Public License version 3. -* -* In accordance with Section 7(b) of the GNU General Public License version 3, -* these Appropriate Legal Notices must retain the display of the "Powered by -* KnowledgeTree" logo and retain the original copyright notice. If the display of the -* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices -* must display the words "Powered by KnowledgeTree" and retain the original -* copyright notice. -* -* @copyright 2008-2009, KnowledgeTree Inc. -* @license GNU General Public License version 3 -* @author KnowledgeTree Team -* @package Migrater -* @version Version 0.1 -*/ - -class windowsOpenOffice extends windowsService { - - // utility - public $util; - // path to office - private $path; - // host - private $host; - // pid running - private $pidFile; - // port to bind to - private $port; - // bin folder - private $bin; - // office executable - private $soffice; - // office log file - private $log; - private $options; - private $winservice; - - public function __construct() { - $this->name = "openoffice"; - $this->util = new MigrateUtil(); - } - - public function load() { - // hack for testing - $this->setPort("8100"); - $this->setHost("127.0.0.1"); - $this->setLog("openoffice.log"); - $this->setBin("C:\Program Files (x86)\OpenOffice.org 3\program\soffice.bin"); - $this->setBin("C:\Program Files (x86)\ktdms\openoffice\program\soffice.bin"); - $this->setBin("C:\Program Files (x86)\ktdms\openoffice.2.4\program\soffice.bin"); - $this->setWinservice("winserv.exe"); - $this->setOption(); - } - - private function setPort($port = "8100") { - $this->port = $port; - } - - public function getPort() { - return $this->port; - } - - private function setHost($host = "127.0.0.1") { - $this->host = $host; - } - - public function getHost() { - return $this->host; - } - - private function setLog($log = "openoffice.log") { - $this->log = $log; - } - - public function getLog() { - return $this->log; - } - - private function setBin($bin = "soffice") { - $this->bin = $bin; - } - - public function getBin() { - return $this->bin; - } - - private function setWinservice($winservice = "winserv.exe") { - $this->winservice = SYS_BIN_DIR . $winservice; - } - - public function getWinservice() { - return $this->winservice; - } - - private function setOption() { - $this->options = "-displayname {$this->name} -start auto \"{$this->bin}\" -headless -invisible " - . "-accept=socket,host={$this->host},port={$this->port};urp;"; - } - - public function getOption() { - return $this->options; - } - - public function migrate() { - $status = $this->status(); - - if($status == '') { - $cmd = "\"{$this->winservice}\" migrate $this->name $this->options"; - $response = $this->util->pexec($cmd); - return $response; - } - else { - return $status; - } - } - -// public function start() { -// $state = $this->status(); -// if($state != 'STARTED') { -// $cmd = 'sc start ' . $this->name; -// $response = $this->util->pexec($cmd); -// -// return $response; -// } elseif ($state == '') { -// // Start Service -// return true; -// } else { -// // Service Running Already -// return true; -// } -// -// return false; -// } - -} -?> \ No newline at end of file diff --git a/setup/migrate/lib/services/windowsScheduler.php b/setup/migrate/lib/services/windowsScheduler.php deleted file mode 100644 index 04beab5..0000000 --- a/setup/migrate/lib/services/windowsScheduler.php +++ /dev/null @@ -1,199 +0,0 @@ -. -* -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, -* California 94120-7775, or email info@knowledgetree.com. -* -* The interactive user interfaces in modified source and object code versions -* of this program must display Appropriate Legal Notices, as required under -* Section 5 of the GNU General Public License version 3. -* -* In accordance with Section 7(b) of the GNU General Public License version 3, -* these Appropriate Legal Notices must retain the display of the "Powered by -* KnowledgeTree" logo and retain the original copyright notice. If the display of the -* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices -* must display the words "Powered by KnowledgeTree" and retain the original -* copyright notice. -* -* @copyright 2008-2009, KnowledgeTree Inc. -* @license GNU General Public License version 3 -* @author KnowledgeTree Team -* @package Migrater -* @version Version 0.1 -*/ -class windowsScheduler extends windowsService { - /** - * Batch Script to execute - * - * @author KnowledgeTree Team - * @access private - * @var string - */ - private $schedulerScriptPath; - - /** - * Php Script to execute - * - * @author KnowledgeTree Team - * @access private - * @var string - */ - private $schedulerSource; - - /** - * Scheduler Directory - * - * @author KnowledgeTree Team - * @access private - * @var string - */ - private $schedulerDir; - - /** - * Load defaults needed by service - * - * @author KnowledgeTree Team - * @access public - * @param string - * @return void - */ - function load() { - $this->name = "KTSchedulerTest"; - $this->setSchedulerDIR(SYSTEM_DIR."bin".DS."win32"); -// $this->setSchedulerScriptPath("taskrunner_test.bat"); - $this->setSchedulerScriptPath("taskrunner.bat"); - $this->setSchedulerSource("schedulerService.php"); - } - - /** - * Set Batch Script path - * - * @author KnowledgeTree Team - * @access private - * @param string - * @return void - */ - private function setSchedulerScriptPath($schedulerScriptPath) { - $this->schedulerScriptPath = "{$this->getSchedulerDir()}".DS."$schedulerScriptPath"; - } - - /** - * Retrieve Batch Script path - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return string - */ - public function getSchedulerScriptPath() { - if(file_exists($this->schedulerScriptPath)) - return $this->schedulerScriptPath; - return false; - } - - /** - * Set Scheduler Directory path - * - * @author KnowledgeTree Team - * @access private - * @param none - * @return string - */ - private function setSchedulerDIR($schedulerDIR) { - $this->schedulerDir = $schedulerDIR; - } - - /** - * Retrieve Scheduler Directory path - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return string - */ - public function getSchedulerDir() { - if(file_exists($this->schedulerDir)) - return $this->schedulerDir; - return false; - } - - /** - * Set Php Script path - * - * @author KnowledgeTree Team - * @access private - * @param none - * @return string - */ - private function setSchedulerSource($schedulerSource) { - $this->schedulerSource = $this->getSchedulerDir().DS.$schedulerSource; - } - - /** - * Retrieve Php Script path - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return string - */ - public function getSchedulerSource() { - if(file_exists($this->schedulerSource)) - return $this->schedulerSource; - return false; - } - - /** - * Migrate Scheduler Service - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return array - */ - public function migrate() { - $state = $this->status(); - if($state == '') { - if(is_readable(SYS_BIN_DIR) && is_writable(SYS_BIN_DIR)) { - if(!file_exists($this->getSchedulerScriptPath())) { - $fp = fopen($this->getSchedulerScriptPath(), "w+"); - $content = "@echo off\n"; - $content .= "\"".PHP_DIR."php.exe\" "."\"{$this->getSchedulerSource()}\""; - fwrite($fp, $content); - fclose($fp); - } - } - - // TODO what if it does not exist? check how the dmsctl.bat does this - if (function_exists('win32_create_service')) - { - $response = win32_create_service(array( - 'service' => $this->name, - 'display' => $this->name, - 'path' => $this->getSchedulerScriptPath() - )); - return $response; - } - } - return $state; - } -} -?> \ No newline at end of file diff --git a/setup/migrate/lib/services/windowsService.php b/setup/migrate/lib/services/windowsService.php deleted file mode 100644 index dfc7836..0000000 --- a/setup/migrate/lib/services/windowsService.php +++ /dev/null @@ -1,181 +0,0 @@ -. -* -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, -* California 94120-7775, or email info@knowledgetree.com. -* -* The interactive user interfaces in modified source and object code versions -* of this program must display Appropriate Legal Notices, as required under -* Section 5 of the GNU General Public License version 3. -* -* In accordance with Section 7(b) of the GNU General Public License version 3, -* these Appropriate Legal Notices must retain the display of the "Powered by -* KnowledgeTree" logo and retain the original copyright notice. If the display of the -* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices -* must display the words "Powered by KnowledgeTree" and retain the original -* copyright notice. -* -* @copyright 2008-2009, KnowledgeTree Inc. -* @license GNU General Public License version 3 -* @author KnowledgeTree Team -* @package Migrater -* @version Version 0.1 -*/ - -class windowsService extends Service { - public $name; - public $util; - - public function __construct() { - $this->util = new MigrateUtil(); - } - - /** - * Retrieve Service name - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return string - */ - public function getName() { - return $this->name; - } - - /** - * Start Service - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return array - */ - public function start() { - $status = $this->status(); - if ($status != 'RUNNING') { - $cmd = "sc start {$this->name}"; - $response = $this->util->pexec($cmd); - return $response; - } - return $status; - } - - /** - * Stop Service - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return array - */ - public function stop() { - $status = $this->status(); - if ($status != 'STOPPED') { - $cmd = "sc stop {$this->name}"; - $response = $this->util->pexec($cmd); - return $response; - } - return $status; - } - - public function migrate() {} - - /** - * Restart Service - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return array - */ - public function restart() { - $response = $this->stop(); - sleep(10); - $this->start(); - } - - /** - * Unmigrate Service - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return array - */ - public function unmigrate() { - $status = $this->status(); - if ($status != '') { - $cmd = "sc delete {$this->name}"; - $response = $this->util->pexec($cmd); - sleep(10); - return $response; - } - return $status; - } - - /** - * Retrieve Status Service - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return string - */ - public function status() { - $cmd = "sc query {$this->name}"; - $response = $this->util->pexec($cmd); - if($response['out']) { - $state = preg_replace('/^STATE *\: *\d */', '', trim($response['out'][3])); // Status store in third key - return $state; - } - - return ''; - } - - /** - * Pause Service - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return array - */ - public function pause() { - $cmd = "sc pause {$this->name}"; - $response = $this->util->pexec($cmd); - return $response; - } - - /** - * Continue Service - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return array - */ - public function cont() { - $cmd = "sc continue {$this->name}"; - $response = $this->util->pexec($cmd); - return $response; - } -} -?> \ No newline at end of file diff --git a/setup/migrate/migrateUtil.php b/setup/migrate/migrateUtil.php index 0af2cd2..7bf3000 100644 --- a/setup/migrate/migrateUtil.php +++ b/setup/migrate/migrateUtil.php @@ -39,7 +39,9 @@ * @package Migrater * @version Version 0.1 */ + class MigrateUtil { + private $bootstrap = null; /** * Constructs migrateation object * @@ -47,6 +49,8 @@ class MigrateUtil { * @access public */ public function __construct() { + require_once("../wizard/installUtil.php"); + $this->bootstrap = new InstallUtil(); } /** @@ -90,148 +94,13 @@ class MigrateUtil { */ public function checkStructurePermissions() { // Check if Wizard Directory is writable - if(!$this->_checkPermission(MIGRATE_DIR)) { - return 'wizard'; + if(!$this->_checkPermission(WIZARD_DIR)) { + return 'migrate'; } return true; } - - function getInstallServices() { - require_once("../wizard/installUtil.php"); - require_once("../wizard/steps/services.php"); - - return new services(); - } - /** - * Redirect - * - * This function redirects the client. This is done by issuing - * a "Location" header and exiting if wanted. If you set $rfc2616 to true - * HTTP will output a hypertext note with the location of the redirect. - * - * @static - * @access public - * have already been sent. - * @param string $url URL where the redirect should go to. - * @param bool $exit Whether to exit immediately after redirection. - * @param bool $rfc2616 Wheter to output a hypertext note where we're - * redirecting to (Redirecting to ....) - * @return mixed Returns true on succes (or exits) or false if headers - */ - public function redirect($url, $exit = true, $rfc2616 = false) - { - if (headers_sent()) { - return false; - } - - $url = $this->absoluteURI($url); - header('Location: '. $url); - - if ( $rfc2616 && isset($_SERVER['REQUEST_METHOD']) && - $_SERVER['REQUEST_METHOD'] != 'HEAD') { - printf('Redirecting to: %s.', $url, $url); - } - if ($exit) { - exit; - } - return true; - } - - /** - * Absolute URI - * - * This function returns the absolute URI for the partial URL passed. - * The current scheme (HTTP/HTTPS), host server, port, current script - * location are used if necessary to resolve any relative URLs. - * - * Offsets potentially created by PATH_INFO are taken care of to resolve - * relative URLs to the current script. - * - * You can choose a new protocol while resolving the URI. This is - * particularly useful when redirecting a web browser using relative URIs - * and to switch from HTTP to HTTPS, or vice-versa, at the same time. - * - * @author Philippe Jausions - * @static - * @access public - * @param string $url Absolute or relative URI the redirect should go to. - * @param string $protocol Protocol to use when redirecting URIs. - * @param integer $port A new port number. - * @return string The absolute URI. - */ - public function absoluteURI($url = null, $protocol = null, $port = null) - { - // filter CR/LF - $url = str_replace(array("\r", "\n"), ' ', $url); - - // Mess around with already absolute URIs - if (preg_match('!^([a-z0-9]+)://!i', $url)) { - if (empty($protocol) && empty($port)) { - return $url; - } - if (!empty($protocol)) { - $url = $protocol .':'. end($array = explode(':', $url, 2)); - } - if (!empty($port)) { - $url = preg_replace('!^(([a-z0-9]+)://[^/:]+)(:[\d]+)?!i', - '\1:'. $port, $url); - } - return $url; - } - - $host = 'localhost'; - if (!empty($_SERVER['HTTP_HOST'])) { - list($host) = explode(':', $_SERVER['HTTP_HOST']); - } elseif (!empty($_SERVER['SERVER_NAME'])) { - list($host) = explode(':', $_SERVER['SERVER_NAME']); - } - - if (empty($protocol)) { - if (isset($_SERVER['HTTPS']) && !strcasecmp($_SERVER['HTTPS'], 'on')) { - $protocol = 'https'; - } else { - $protocol = 'http'; - } - if (!isset($port) || $port != intval($port)) { - $port = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : 80; - } - } - - if ($protocol == 'http' && $port == 80) { - unset($port); - } - if ($protocol == 'https' && $port == 443) { - unset($port); - } - - $server = $protocol .'://'. $host . (isset($port) ? ':'. $port : ''); - - if (!strlen($url)) { - $url = isset($_SERVER['REQUEST_URI']) ? - $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF']; - } - - if ($url{0} == '/') { - return $server . $url; - } - - // Check for PATH_INFO - if (isset($_SERVER['PATH_INFO']) && strlen($_SERVER['PATH_INFO']) && - $_SERVER['PHP_SELF'] != $_SERVER['PATH_INFO']) { - $path = dirname(substr($_SERVER['PHP_SELF'], 0, -strlen($_SERVER['PATH_INFO']))); - } else { - $path = dirname($_SERVER['PHP_SELF']); - } - - if (substr($path = strtr($path, '\\', '/'), -1) != '/') { - $path .= '/'; - } - - return $server . $path . $url; - } - /** * Check whether a given directory / file path exists and is writable * @@ -251,306 +120,39 @@ class MigrateUtil { } - /** - * Check whether a given directory / file path exists and is writable - * - * @author KnowledgeTree Team - * @access private - * @param string $dir The directory / file to check - * @param boolean $create Whether to create the directory if it doesn't exist - * @return array The message and css class to use - */ - public function checkPermission($dir, $create=false) - { - $exist = 'Directory doesn\'t exist'; - $write = 'Directory not writable'; - $ret = array('class' => 'cross'); - - if(!file_exists($dir)){ - if($create === false){ - $this->done = false; - $ret['msg'] = $exist; - return $ret; - } - $par_dir = dirname($dir); - if(!file_exists($par_dir)){ - $this->done = false; - $ret['msg'] = $exist; - return $ret; - } - if(!is_writable($par_dir)){ - $this->done = false; - $ret['msg'] = $exist; - return $ret; - } - mkdir($dir, '0755'); - } - - if(is_writable($dir)){ - $ret['class'] = 'tick'; - - return $ret; - } - - $this->done = false; - $ret['msg'] = $write; - return $ret; - } - - /** - * Change permissions on a directory helper - * - * @author KnowledgeTree Team - * @access public - * @param string $folderPath The directory / file to check - * @return boolean - */ - public function canChangePermissions($folderPath) { - return $this->_chmodRecursive($folderPath, 0755); - } - - /** - * Change permissions on a directory (recursive) - * - * @author KnowledgeTree Team - * @access private - * @param string $folderPath The directory / file to check - * @param boolean $create Whether to create the directory if it doesn't exist - * @return boolean - */ - private function _chmodRecursive($path, $filemode) { - if (!is_dir($path)) - return chmod($path, $filemode); - $dh = opendir($path); - while (($file = readdir($dh)) !== false) { - if($file != '.' && $file != '..') { - $fullpath = $path.'/'.$file; - if(is_link($fullpath)) - return false; - elseif(!is_dir($fullpath)) { - $perms = substr(sprintf('%o', fileperms($fullpath)), -4); - if($perms != $filemode) - if (!chmod($fullpath, $filemode)) - return false; - } elseif(!$this->chmodRecursive($fullpath, $filemode)) - return false; - } - } - closedir($dh); - $perms = substr(sprintf('%o', fileperms($path)), -4); - if($perms != $filemode) { - if(chmod($path, $filemode)) - return true; - else - return false; - } else { - return true; - } - } - - /** - * Check if a file can be written to a folder - * - * @author KnowledgeTree Team - * @access public - * @param string $filename the path to the file to create - * @return boolean - */ - public function canWriteFile($filename) { - $fh = fopen($filename, "w+"); - if($fr = fwrite($fh, 'test') === false) { - return false; - } - - fclose($fh); - return true; - } - - /** - * Attempt using the php-java bridge - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return boolean - */ - public function javaBridge() { - try { - $javaSystem = new Java('java.lang.System'); - } catch (JavaException $e) { - return false; - } - return true; - } - - /** - * Attempt java detection - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return boolean - */ - public function tryJava1() { - $response = $this->pexec("java -version"); // Java Runtime Check - if(empty($response['out'])) { - return false; - } - - return 'java'; - } - - /** - * Attempt java detection - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return boolean - */ - public function tryJava2() { - $response = $this->pexec("java"); // Java Runtime Check - if(empty($response['out'])) { - return false; - } - - return 'java'; - } - - /** - * Attempt java detection - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return boolean - */ - public function tryJava3() { - $response = $this->pexec("whereis java"); // Java Runtime Check - if(empty($response['out'])) { - return false; - } - $broke = explode(' ', $response['out'][0]); - foreach ($broke as $r) { - $match = preg_match('/bin/', $r); - if($match) { - return preg_replace('/java:/', '', $r); - } - } + public function loadInstallDBUtil() { + require_once("../wizard/dbUtil.php"); + return new dbUtil(); } - /** - * Check if user entered location of JRE - * - * @author KnowledgeTree Team - * @param none - * @access private - * @return mixed - */ - public function javaSpecified() { - if(isset($_POST['java'])) { - if($_POST['java'] != '') { - return $_POST['java']; - } else { - return false; - } - } else { - return false; - } + public function loadInstallUtil() { + require_once("../wizard/steps/services.php"); + return new services(); } - /** - * Check if user entered location of PHP - * - * @author KnowledgeTree Team - * @param none - * @access private - * @return mixed - */ - public function phpSpecified() { - if(isset($_POST['php'])) { - if($_POST['php'] != '') { - return $_POST['php']; - } else { - return false; - } - } else { - return false; - } + public function loadInstallServices() { + $s = $this->loadInstallUtil(); + return $s->getServices(); } - /** - * Determine the location of JAVA_HOME - * - * @author KnowledgeTree Team - * @param none - * @access private - * @return mixed - */ - function getJava() { - $response = $this->tryJava1(); - if(!is_array($response)) { - $response = $this->tryJava2(); - if(!is_array($response)) { - $response = $this->tryJava3(); - } - } -// return false; - return $response; + public function loadInstallService($serviceName) { + require_once("../wizard/lib/services/service.php"); + require_once("../wizard/lib/services/".OS."Service.php"); + require_once("../wizard/lib/services/$serviceName.php"); + return new $serviceName(); } - /** - * Determine the location of PHP - * - * @author KnowledgeTree Team - * @param none - * @access private - * @return mixed - */ - function getPhp() { - $cmd = "whereis php"; - $res = $this->getPhpHelper($cmd); - if($res != '') { - return $res; - } - $cmd = "which php"; - return $this->getPhpHelper($cmd); + public function redirect($url, $exit = true, $rfc2616 = false) + { + return $this->bootstrap->redirect($url, $exit = true, $rfc2616 = false); } - - function getPhpHelper($cmd) { - $response = $this->pexec($cmd); - if(is_array($response['out'])) { - if (isset($response['out'][0])) { - $broke = explode(' ', $response['out'][0]); - foreach ($broke as $r) { - $match = preg_match('/bin/', $r); - if($match) { - return preg_replace('/php:/', '', $r); - } - } - } - } - - return ''; + + public function absoluteURI($url = null, $protocol = null, $port = null) + { + return $this->bootstrap->absoluteURI($url = null, $protocol = null, $port = null); } - function getOpenOffice() { - $cmd = "whereis soffice"; - $response = $this->pexec($cmd); - if(is_array($response['out'])) { - if (isset($response['out'][0])) { - $broke = explode(' ', $response['out'][0]); - foreach ($broke as $r) { - $match = preg_match('/bin/', $r); - if($match) { - return preg_replace('/soffice:/', '', $r); - } - } - } - } - - return ''; - } + /** * Portably execute a command on any of the supported platforms. * @@ -561,88 +163,7 @@ class MigrateUtil { * @return array */ public function pexec($aCmd, $aOptions = null) { - if (is_array($aCmd)) { - $sCmd = $this->safeShellString($aCmd); - } else { - $sCmd = $aCmd; - } - $sAppend = $this->arrayGet($aOptions, 'append'); - if ($sAppend) { - $sCmd .= " >> " . escapeshellarg($sAppend); - } - $sPopen = $this->arrayGet($aOptions, 'popen'); - if ($sPopen) { - if (WINDOWS_OS) { - $sCmd = "start /b \"kt\" " . $sCmd; - } - return popen($sCmd, $sPopen); - } - // for exec, check return code and output... - $aRet = array(); - $aOutput = array(); - $iRet = ''; - if(WINDOWS_OS) { - $sCmd = 'call '.$sCmd; - } - - exec($sCmd, $aOutput, $iRet); - $aRet['ret'] = $iRet; - $aRet['out'] = $aOutput; - - return $aRet; - } - - /** - * - * - * @author KnowledgeTree Team - * @access public - * @return string - */ - public function arrayGet($aArray, $sKey, $mDefault = null, $bDefaultIfEmpty = true) { - if (!is_array($aArray)) { - $aArray = (array) $aArray; - } - - if ($aArray !== 0 && $aArray !== '0' && empty($aArray)) { - return $mDefault; - } - if (array_key_exists($sKey, $aArray)) { - $mVal =& $aArray[$sKey]; - if (empty($mVal) && $bDefaultIfEmpty) { - return $mDefault; - } - return $mVal; - } - return $mDefault; + return $this->bootstrap->pexec($aCmd, $aOptions = null); } - - /** - * - * - * @author KnowledgeTree Team - * @access public - * @return string - */ - public function safeShellString () { - $aArgs = func_get_args(); - $aSafeArgs = array(); - if (is_array($aArgs[0])) { - $aArgs = $aArgs[0]; - } - $aSafeArgs[] = escapeshellarg(array_shift($aArgs)); - if (is_array($aArgs[0])) { - $aArgs = $aArgs; - } - foreach ($aArgs as $sArg) { - if (empty($sArg)) { - $aSafeArgs[] = "''"; - } else { - $aSafeArgs[] = escapeshellarg($sArg); - } - } - return join(" ", $aSafeArgs); - } - } ?> \ No newline at end of file diff --git a/setup/migrate/migrateWizard.php b/setup/migrate/migrateWizard.php index 5858f71..0e56ed8 100644 --- a/setup/migrate/migrateWizard.php +++ b/setup/migrate/migrateWizard.php @@ -39,7 +39,7 @@ * @package Migrater * @version Version 0.1 */ -include("path.php"); // Paths +include("../wizard/path.php"); // Paths /** * Auto loader to bind migrater package @@ -49,8 +49,8 @@ include("path.php"); // Paths */ function __autoload($class) { // Attempt and autoload classes $class = strtolower(substr($class,0,1)).substr($class,1); // Linux Systems. - if(file_exists(MIGRATE_DIR."$class.php")) { - require_once(MIGRATE_DIR."$class.php"); + if(file_exists(WIZARD_DIR."$class.php")) { + require_once(WIZARD_DIR."$class.php"); } elseif (file_exists(STEP_DIR."$class.php")) { require_once(STEP_DIR."$class.php"); } elseif (file_exists(WIZARD_LIB."$class.php")) { diff --git a/setup/migrate/migrater.php b/setup/migrate/migrater.php index eec9dfb..f329caf 100644 --- a/setup/migrate/migrater.php +++ b/setup/migrate/migrater.php @@ -507,6 +507,9 @@ class Migrater { } elseif (isset($_POST['Install'])) { $this->migraterAction = 'install'; $this->response = 'install'; + } elseif (isset($_POST['BInstall'])) { + $this->migraterAction = 'binstall'; + $this->response = 'binstall'; } else { $this->response = ''; $this->migraterAction = ''; @@ -548,6 +551,10 @@ class Migrater { $iutil = new MigrateUtil(); $iutil->redirect('../wizard/index.php?step_name=installtype'); break; + case 'binstall': + $iutil = new MigrateUtil(); + $iutil->redirect('../wizard/index.php?step_name=dependencies'); + break; default: // TODO : handle silent $this->_landing(); diff --git a/setup/migrate/steps/migrateComplete.php b/setup/migrate/steps/migrateComplete.php index 44cc440..a38a7af 100644 --- a/setup/migrate/steps/migrateComplete.php +++ b/setup/migrate/steps/migrateComplete.php @@ -67,7 +67,6 @@ class migrateComplete extends Step { public function __construct() { $this->temp_variables = array("step_name"=>"complete", "silent"=>$this->silent); - $this->_dbhandler = new dbUtil(); $this->util = new MigrateUtil(); } @@ -78,16 +77,52 @@ class migrateComplete extends Step { function doRun() { $this->checkServices(); + $this->checkSqlDump(); $this->storeSilent();// Set silent mode variables } + private function checkSqlDump() { + $tmpFolder = "/tmp/knowledgtree"; + $sqlFile = $tmpFolder."dms.sql"; + if(file_exists($sqlFile)) { + $this->temp_variables['sql']['class'] = "tick"; + $this->temp_variables['sql']['name'] = "dms.sql"; + $this->temp_variables['sql']['msg'] = "Data file created"; + return true; + } else { + $this->temp_variables['sql']['class'] = "cross"; + $this->temp_variables['sql']['name'] = "dms.sql"; + $this->temp_variables['sql']['msg'] = "Data file has not been created"; + return false; + } + } + private function checkServices() { - $services = new services(); - foreach ($services->getServices() as $serviceName) { - $this->temp_variables[$serviceName."Status"] = 'tick'; - } - return true; + $services = $this->util->loadInstallServices(); // Use installer services class + foreach ($services as $serviceName) { + $className = OS.$serviceName; + $serv = $this->util->loadInstallService($className); + $serv->load(); + $sStatus = $serv->status(true); + if($sStatus == 'STARTED') { + $state = 'cross'; + $this->error[] = "Service : {$serv->getName()} could not be uninstalled.
"; + $this->services_check = 'cross'; + $stopmsg = OS.'GetStopMsg'; + $this->temp_variables['services'][$serv->getName()]['msg'] = $serv->$stopmsg($this->conf['location']); + } else { + $state = 'tick'; + $this->temp_variables['services'][$serv->getName()]['msg'] = "Service has been uninstalled"; + } + $this->temp_variables['services'][$serv->getName()]['class'] = $state; + $this->temp_variables['services'][$serv->getName()]['name'] = $serv->getName(); + } + if ($this->services_check != 'tick') { + return false; + } + + return true; } /** @@ -95,7 +130,7 @@ class migrateComplete extends Step { * */ private function storeSilent() { - $this->temp_variables['services_check'] = $this->services_check; + $this->temp_variables['servicesCheck'] = $this->services_check; } } ?> \ No newline at end of file diff --git a/setup/migrate/steps/migrateDatabase.php b/setup/migrate/steps/migrateDatabase.php index 99c300c..90ce0ba 100644 --- a/setup/migrate/steps/migrateDatabase.php +++ b/setup/migrate/steps/migrateDatabase.php @@ -60,141 +60,7 @@ class migrateDatabase extends Step */ public $_util = null; - /** - * Database type - * - * @author KnowledgeTree Team - * @access private - * @var array - */ - private $dtype = ''; - - /** - * Database types - * - * @author KnowledgeTree Team - * @access private - * @var array - */ - private $dtypes = array(); - - /** - * Database host - * - * @author KnowledgeTree Team - * @access private - * @var string - */ - private $dhost = ''; - - /** - * Database port - * - * @author KnowledgeTree Team - * @access private - * @var string - */ - private $dport = ''; - - /** - * Database name - * - * @author KnowledgeTree Team - * @access private - * @var string - */ - private $dname = ''; - - /** - * Database root username - * - * @author KnowledgeTree Team - * @access private - * @var string - */ - private $duname = ''; - - /** - * Database root password - * - * @author KnowledgeTree Team - * @access private - * @var string - */ - private $dpassword = ''; - - /** - * Database dms username - * - * @author KnowledgeTree Team - * @access private - * @var string - */ - private $dmsname = ''; - - /** - * Database dms password - * - * @author KnowledgeTree Team - * @access private - * @var string - */ - private $dmspassword = ''; - - /** - * Default dms user username - * - * @author KnowledgeTree Team - * @access private - * @var boolean - */ - private $dmsusername = ''; - - /** - * Default dms user password - * - * @author KnowledgeTree Team - * @access private - * @var boolean - */ - private $dmsuserpassword = ''; - - /** - * Location of database binaries. - * - * @author KnowledgeTree Team - * @access private - * @var string - */ - private $mysqlDir; // TODO:multiple databases - - /** - * Name of database binary. - * - * @author KnowledgeTree Team - * @access private - * @var string - */ - private $dbbinary = ''; // TODO:multiple databases - - /** - * Database table prefix - * - * @author KnowledgeTree Team - * @access private - * @var string - */ - private $tprefix = ''; - - /** - * Flag to drop database - * - * @author KnowledgeTree Team - * @access private - * @var boolean - */ - private $ddrop = false; - + /** * List of errors encountered * @@ -205,15 +71,6 @@ class migrateDatabase extends Step public $error = array(); /** - * List of errors used in template - * - * @author KnowledgeTree Team - * @access public - * @var array - */ - public $templateErrors = array('dmspassword', 'dmsuserpassword', 'con', 'dname', 'dtype', 'duname', 'dpassword'); - - /** * Flag to store class information in session * * @author KnowledgeTree Team @@ -239,6 +96,15 @@ class migrateDatabase extends Step * @var array */ protected $silent = true; + + /** + * List of errors used in template + * + * @author KnowledgeTree Team + * @access public + * @var array + */ + public $templateErrors = array('dmspassword', 'dmsuserpassword', 'con', 'dname', 'dtype', 'duname', 'dpassword'); /** * Constructs database object @@ -249,8 +115,7 @@ class migrateDatabase extends Step */ public function __construct() { $this->temp_variables = array("step_name"=>"database", "silent"=>$this->silent); - $this->_dbhandler = new dbUtil(); - $this->_util = new MigrateUtil(); + $this->util = new MigrateUtil(); if(WINDOWS_OS) $this->mysqlDir = MYSQL_BIN; $this->wizardLocation = '../wizard'; @@ -265,13 +130,15 @@ class migrateDatabase extends Step * @return string */ public function doStep() { - $this->initErrors(); + $this->initErrors(); // Load template errors $this->setDetails(); // Set any posted variables if(!$this->inStep("database")) { return 'landing'; } if($this->next()) { - return 'next'; + if($this->exportDatabase()) { + return 'next'; + } } else if($this->previous()) { return 'previous'; } @@ -279,6 +146,28 @@ class migrateDatabase extends Step return 'landing'; } + public function exportDatabase() { + if(WINDOWS_OS) { + + } else { + $tmpFolder = "/tmp/knowledgtree"; + } + @mkdir($tmpFolder); + $installation = $this->getDataFromSession("installation"); // Get installation directory + $dbSettings = $installation['dbSettings']; + $uname = $this->temp_variables['duname']; + $pwrd = $this->temp_variables['dpassword']; + $sqlFile = $tmpFolder."dms.sql"; + $dbName = $dbSettings['dbName']; + $cmd = "mysqldump -u{$uname} -p{$pwrd} {$dbName} > ".$sqlFile; + $response = $this->util->pexec($cmd); + if(file_exists($sqlFile)) { + return true; + } else { + return false; + } + } + /** * Store options * @@ -288,11 +177,8 @@ class migrateDatabase extends Step * @return void */ private function setDetails() { - $this->temp_variables['dhost'] = $this->getPostSafe('dhost'); - $this->temp_variables['dport'] = $this->getPostSafe('dport'); $this->temp_variables['duname'] = $this->getPostSafe('duname'); $this->temp_variables['dpassword'] = $this->getPostSafe('dpassword'); - $this->temp_variables['dbbinary'] = $this->getPostSafe('dbbinary'); // create lock file to indicate migration mode $this->createMigrateFile(); } @@ -344,7 +230,7 @@ class migrateDatabase extends Step return $this->error; } - + /** * Initialize errors to false * diff --git a/setup/migrate/steps/migrateServices.php b/setup/migrate/steps/migrateServices.php index d84dcc4..8d914b2 100644 --- a/setup/migrate/steps/migrateServices.php +++ b/setup/migrate/steps/migrateServices.php @@ -137,21 +137,6 @@ class migrateServices extends Step $this->util = new MigrateUtil(); } - public function loadInstallUtil() { - require("../wizard/installUtil.php"); - require("../wizard/steps/services.php"); - $this->installServices = new services(); - } - - public function loadInstallServices() { - $this->services = $this->installServices->getServices(); - } - - private function loadInstallService($serviceName) { - require_once("../wizard/lib/services/$serviceName.php"); - return new $serviceName(); - } - /** * Main control of services setup * @@ -162,8 +147,8 @@ class migrateServices extends Step */ public function doStep() { - $this->loadInstallUtil(); // Use installer utility class - $this->loadInstallServices(); // Use installer services class + $this->installServices = $this->util->loadInstallUtil(); // Use installer utility class + $this->services = $this->util->loadInstallServices(); // Use installer services class $this->storeSilent(); if(!$this->inStep("services")) { $this->doRun(); @@ -191,11 +176,10 @@ class migrateServices extends Step * @return boolean */ private function doRun() { - if(!$this->alreadyUninstalled()) { // Pre-check if services are stopped - $this->stopServices(); - + if(!$this->alreadyUninstalled()) { // Pre-check if services are uninstalled + $this->uninstallServices(); } - $this->stopServices(); + $this->uninstallServices(); return $this->checkServices(); } @@ -208,7 +192,7 @@ class migrateServices extends Step $alreadyUninstalled = true; foreach ($this->services as $serviceName) { $className = OS.$serviceName; - $serv = $this->loadInstallService($className); + $serv = $this->util->loadInstallService($className); $serv->load(); $sStatus = $serv->status(); if($sStatus != '') { @@ -220,23 +204,52 @@ class migrateServices extends Step } /** - * Attempt to stop services + * Attempt to uninstall services * */ - private function stopServices() { + private function uninstallServices() { $this->conf = $this->getDataFromSession("installation"); // Get installation directory if($this->conf['location'] != '') { - $cmd = $this->conf['location']."/dmsctl.sh stop"; // Try the dmsctl - - $res = $this->util->pexec($cmd); + $func = OS."Stop";// Try the dmsctl + $this->$func(); } $this->shutdown(); } + /** + * Attempt to uninstall unix services + * + */ + public function unixStop() { + $cmd = $this->conf['location']."/dmsctl.sh stop lucene"; + $res = $this->util->pexec($cmd); + $cmd = $this->conf['location']."/dmsctl.sh stop scheduler"; + $res = $this->util->pexec($cmd); + $cmd = $this->conf['location']."/dmsctl.sh stop soffice"; + $res = $this->util->pexec($cmd); + } + + /** + * Attempt to uninstall windows services + * + */ + public function windowsStop() { + $cmd = "sc delete KTLucene"; + $res = $this->util->pexec($cmd); + $cmd = "sc delete KTScheduler"; + $res = $this->util->pexec($cmd); + $cmd = "sc delete KTOpenoffice"; + $res = $this->util->pexec($cmd); + } + + /** + * Attempt to uninstall services created by webserver + * + */ public function shutdown() { foreach ($this->services as $serviceName) { $className = OS.$serviceName; - $serv = $this->loadInstallService($className); + $serv = $this->util->loadInstallService($className); $serv->load(); $sStatus = $serv->status(); if($sStatus != '') { @@ -245,24 +258,28 @@ class migrateServices extends Step } } + /** + * Check if services are uninstall + * + */ public function checkServices() { foreach ($this->services as $serviceName) { $className = OS.$serviceName; - $serv = $this->loadInstallService($className); + $serv = $this->util->loadInstallService($className); $serv->load(); - $sStatus = $serv->status(); + $sStatus = $serv->status(true); if($sStatus == 'STARTED') { $state = 'cross'; - $this->error[] = "Service : {$serv->getName()} could not be stopped.
"; + $this->error[] = "Service : {$serv->getName()} could not be uninstalled.
"; $this->serviceCheck = 'cross'; - + $stopmsg = OS.'GetStopMsg'; + $this->temp_variables['services'][$serv->getName()]['msg'] = $serv->$stopmsg($this->conf['location']); } else { $state = 'tick'; + $this->temp_variables['services'][$serv->getName()]['msg'] = "Service has been uninstalled"; } $this->temp_variables['services'][$serv->getName()]['class'] = $state; $this->temp_variables['services'][$serv->getName()]['name'] = $serv->getName(); - $stopmsg = OS.'GetStopMsg'; - $this->temp_variables['services'][$serv->getName()]['msg'] = $serv->$stopmsg($this->conf['location']); } if ($this->serviceCheck != 'tick') { return false; @@ -270,6 +287,7 @@ class migrateServices extends Step return true; } + /** * Returns services errors * diff --git a/setup/migrate/templates/complete.tpl b/setup/migrate/templates/complete.tpl index f0487b2..82339b9 100644 --- a/setup/migrate/templates/complete.tpl +++ b/setup/migrate/templates/complete.tpl @@ -1,4 +1,4 @@ -
+

Migration Completed

This allows you to check that your KnowledgeTree configuration is set @@ -14,40 +14,33 @@ ?>

-

-
-

     "; ?>Services

- -
Show Details
- - + + + + + + + + + + + + + + + + +
'>     
'>      Refresh
-
- Goto Installer +
\ No newline at end of file diff --git a/setup/migrate/templates/database.tpl b/setup/migrate/templates/database.tpl index b481441..c5da9c0 100644 --- a/setup/migrate/templates/database.tpl +++ b/setup/migrate/templates/database.tpl @@ -27,4 +27,7 @@ - \ No newline at end of file + + \ No newline at end of file diff --git a/setup/migrate/templates/services.tpl b/setup/migrate/templates/services.tpl index 9acae2f..62b2417 100644 --- a/setup/migrate/templates/services.tpl +++ b/setup/migrate/templates/services.tpl @@ -44,10 +44,8 @@ $details = 'Hide Details'; $display = 'block'; } else { - $details = 'Hide Details'; - $display = 'block'; -// $details = 'Show Details'; -// $display = 'none'; + $details = 'Show Details'; + $display = 'none'; } ?>
@@ -65,7 +63,7 @@ - + Refresh diff --git a/setup/wizard/dbUtil.php b/setup/wizard/dbUtil.php index 512ec0d..a66ab22 100644 --- a/setup/wizard/dbUtil.php +++ b/setup/wizard/dbUtil.php @@ -109,6 +109,9 @@ class dbUtil { $this->dbuname = $duname; $this->dbpassword = $dpassword; $this->dbconnection = @mysql_connect($dhost, $duname, $dpassword); + if(!$this->dbconnection) { + $this->error[] = @mysql_error(); + } $this->dbname = $dbname; } diff --git a/setup/wizard/index.php b/setup/wizard/index.php index 268329d..f771d84 100644 --- a/setup/wizard/index.php +++ b/setup/wizard/index.php @@ -39,5 +39,6 @@ * @package Installer * @version Version 0.1 */ +$_GET['type'] = 'install'; require_once("installWizard.php"); ?> \ No newline at end of file diff --git a/setup/wizard/lib/services/unixOpenOffice.php b/setup/wizard/lib/services/unixOpenOffice.php index 9ea3b4b..5ca89cb 100644 --- a/setup/wizard/lib/services/unixOpenOffice.php +++ b/setup/wizard/lib/services/unixOpenOffice.php @@ -56,19 +56,16 @@ class unixOpenOffice extends unixService { private $bin; // office executable private $soffice; - // office log file - private $log; + private $options; -// private $office; public $name = "KTOpenOffice"; public function load() { $this->util = new InstallUtil(); -// $this->office = 'openoffice'; $this->setPort("8100"); $this->setHost("localhost"); - $this->setLog("openoffice.log"); - $this->setBin($this->soffice = $this->util->getOpenOffice()); + $this->soffice = $this->util->getOpenOffice(); + $this->setBin($this->soffice); $this->setOption(); } @@ -88,14 +85,6 @@ class unixOpenOffice extends unixService { return $this->host; } - private function setLog($log = "openoffice.log") { - $this->log = $log; - } - - public function getLog() { - return $this->log; - } - private function setBin($bin = "soffice") { $this->bin = $bin; } @@ -121,17 +110,13 @@ class unixOpenOffice extends unixService { } } -// private function setOfficeName($office) { -// $this->office = $office; -// } - -// public function getOfficeName() { -// return $this->office; -// } - - public function status() { + public function status($updrade = false) { sleep(1); - $cmd = "netstat -npa | grep ".$this->getPort(); + if($updrade) { + $cmd = "ps ax | grep soffice"; + } else { + $cmd = "netstat -npa | grep ".$this->getPort(); + } $response = $this->util->pexec($cmd); if(is_array($response['out'])) { if(count($response['out']) > 0) { @@ -152,7 +137,7 @@ class unixOpenOffice extends unixService { public function start() { $state = $this->status(); if($state != 'STARTED') { - $cmd = "nohup {$this->getBin()} ".$this->getOption()." > ".$this->outputDir."{$this->getLog()} 2>&1 & echo $!"; + $cmd = "nohup {$this->getBin()} ".$this->getOption()." > ".$this->outputDir."openoffice.log 2>&1 & echo $!"; if(DEBUG) { echo "Command : $cmd
"; return ; @@ -173,9 +158,9 @@ class unixOpenOffice extends unixService { } function stop() { -// $cmd = "pkill -f ".$this->office; -// $response = $this->util->pexec($cmd); -// return $response; + $cmd = "pkill -f ".$this->soffice; + $response = $this->util->pexec($cmd); + return $response; } function uninstall() { diff --git a/setup/wizard/migrate.lock b/setup/wizard/migrate.lock new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/setup/wizard/migrate.lock diff --git a/setup/wizard/path.php b/setup/wizard/path.php index c20dd46..6bd3be3 100644 --- a/setup/wizard/path.php +++ b/setup/wizard/path.php @@ -56,7 +56,18 @@ define('DS', '/'); } // Define environment root - $wizard = realpath(dirname(__FILE__)); + if($_GET['type'] == 'migrate') { + $wizard = realpath(dirname(__FILE__)); + $xdir = explode(DS, $wizard); + array_pop($xdir); + $sys = ''; + foreach ($xdir as $k=>$v) { + $sys .= $v.DS; + } + $wizard = $sys.'migrate'; + } else { + $wizard = realpath(dirname(__FILE__)); + } $xdir = explode(DS, $wizard); array_pop($xdir); array_pop($xdir); @@ -94,7 +105,7 @@ define('SYSTEM_ROOT', $asys); define('SQL_DIR', SYSTEM_DIR."sql".DS); define('SQL_INSTALL_DIR', SQL_DIR."mysql".DS."install".DS); - define('SQL_MIGRATE_DIR', SYS_VAR_DIR."tmp".DS); + define('SQL_MIGRATE_DIR', SQL_DIR."mysql".DS."migrate".DS); // Install Type preg_match('/Zend/', $sys, $matches); // TODO: Dirty if($matches) { -- libgit2 0.21.4