Commit 71ceb5dd37c1947e9194ed6cf76217cbc96efc2a
1 parent
c53dddf2
Story Id:1166869 Daily Commit
Committed by: Jarrett Jordaan Reviewed by: Prince Mbekwa
Showing
27 changed files
with
238 additions
and
2791 deletions
setup/migrate/dbUtil.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | -* Migrater Database Control. | |
| 4 | -* | |
| 5 | -* KnowledgeTree Community Edition | |
| 6 | -* Document Management Made Simple | |
| 7 | -* Copyright (C) 2008,2009 KnowledgeTree Inc. | |
| 8 | -* Portions copyright The Jam Warehouse Software (Pty) Limited | |
| 9 | -* | |
| 10 | -* This program is free software; you can redistribute it and/or modify it under | |
| 11 | -* the terms of the GNU General Public License version 3 as published by the | |
| 12 | -* Free Software Foundation. | |
| 13 | -* | |
| 14 | -* This program is distributed in the hope that it will be useful, but WITHOUT | |
| 15 | -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 16 | -* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 17 | -* details. | |
| 18 | -* | |
| 19 | -* You should have received a copy of the GNU General Public License | |
| 20 | -* along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 21 | -* | |
| 22 | -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 23 | -* California 94120-7775, or email info@knowledgetree.com. | |
| 24 | -* | |
| 25 | -* The interactive user interfaces in modified source and object code versions | |
| 26 | -* of this program must display Appropriate Legal Notices, as required under | |
| 27 | -* Section 5 of the GNU General Public License version 3. | |
| 28 | -* | |
| 29 | -* In accordance with Section 7(b) of the GNU General Public License version 3, | |
| 30 | -* these Appropriate Legal Notices must retain the display of the "Powered by | |
| 31 | -* KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 32 | -* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | |
| 33 | -* must display the words "Powered by KnowledgeTree" and retain the original | |
| 34 | -* copyright notice. | |
| 35 | -* | |
| 36 | -* @copyright 2008-2009, KnowledgeTree Inc. | |
| 37 | -* @license GNU General Public License version 3 | |
| 38 | -* @author KnowledgeTree Team | |
| 39 | -* @package Migrater | |
| 40 | -* @version Version 0.1 | |
| 41 | -*/ | |
| 42 | -class dbUtil { | |
| 43 | - /** | |
| 44 | - * Host | |
| 45 | - * | |
| 46 | - * @author KnowledgeTree Team | |
| 47 | - * @access protected | |
| 48 | - * @var string | |
| 49 | - */ | |
| 50 | - protected $dbhost = ''; | |
| 51 | - | |
| 52 | - /** | |
| 53 | - * Host | |
| 54 | - * | |
| 55 | - * @author KnowledgeTree Team | |
| 56 | - * @access protected | |
| 57 | - * @var string | |
| 58 | - */ | |
| 59 | - protected $dbname = ''; | |
| 60 | - | |
| 61 | - /** | |
| 62 | - * Host | |
| 63 | - * | |
| 64 | - * @author KnowledgeTree Team | |
| 65 | - * @access protected | |
| 66 | - * @var string | |
| 67 | - */ | |
| 68 | - protected $dbuname = ''; | |
| 69 | - | |
| 70 | - /** | |
| 71 | - * Host | |
| 72 | - * | |
| 73 | - * @author KnowledgeTree Team | |
| 74 | - * @access protected | |
| 75 | - * @var string | |
| 76 | - */ | |
| 77 | - protected $dbpassword = ''; | |
| 78 | - | |
| 79 | - /** | |
| 80 | - * Host | |
| 81 | - * | |
| 82 | - * @author KnowledgeTree Team | |
| 83 | - * @access protected | |
| 84 | - * @var object mysql connection | |
| 85 | - */ | |
| 86 | - protected $dbconnection = ''; | |
| 87 | - | |
| 88 | - /** | |
| 89 | - * Any errors encountered | |
| 90 | - * | |
| 91 | - * @author KnowledgeTree Team | |
| 92 | - * @access protected | |
| 93 | - * @var array | |
| 94 | - */ | |
| 95 | - protected $error = array(); | |
| 96 | - | |
| 97 | - /** | |
| 98 | - * Constructs database connection object | |
| 99 | - * | |
| 100 | - * @author KnowledgeTree Team | |
| 101 | - * @access public | |
| 102 | - */ | |
| 103 | - public function __construct() { | |
| 104 | - | |
| 105 | - } | |
| 106 | - | |
| 107 | - public function load($dhost = 'localhost', $duname, $dpassword, $dbname) { | |
| 108 | - $this->dbhost = $dhost; | |
| 109 | - $this->dbuname = $duname; | |
| 110 | - $this->dbpassword = $dpassword; | |
| 111 | - $this->dbconnection = @mysql_connect($dhost, $duname, $dpassword); | |
| 112 | - if($dbname != '') { | |
| 113 | - $this->setDb($dbname); | |
| 114 | - $this->useDb($dbname); | |
| 115 | - } | |
| 116 | - if($this->dbconnection) | |
| 117 | - return $this->dbconnection; | |
| 118 | - else { | |
| 119 | - $this->error[] = @mysql_error($this->dbconnection); | |
| 120 | - return false; | |
| 121 | - } | |
| 122 | - } | |
| 123 | - | |
| 124 | - /** | |
| 125 | - * Choose a database to use | |
| 126 | - * | |
| 127 | - * @param string $dbname name of the database | |
| 128 | - * @access public | |
| 129 | - * @return boolean | |
| 130 | - */ | |
| 131 | - public function useDb($dbname = '') { | |
| 132 | - if($dbname != '') { | |
| 133 | - $this->setDb($dbname); | |
| 134 | - } | |
| 135 | - | |
| 136 | - if(@mysql_select_db($this->dbname, $this->dbconnection)) | |
| 137 | - return true; | |
| 138 | - else { | |
| 139 | - $this->error[] = @mysql_error($this->dbconnection); | |
| 140 | - return false; | |
| 141 | - } | |
| 142 | - } | |
| 143 | - | |
| 144 | - public function setDb($dbname) { | |
| 145 | - $this->dbname = $dbname; | |
| 146 | - } | |
| 147 | - | |
| 148 | - /** | |
| 149 | - * Query the database. | |
| 150 | - * | |
| 151 | - * @param $query the sql query. | |
| 152 | - * @access public | |
| 153 | - * @return object The result of the query. | |
| 154 | - */ | |
| 155 | - public function query($query) { | |
| 156 | - $result = @mysql_query($query, $this->dbconnection); | |
| 157 | - if($result) { | |
| 158 | - return $result; | |
| 159 | - } else { | |
| 160 | - $this->error[] = @mysql_error($this->dbconnection); | |
| 161 | - return false; | |
| 162 | - } | |
| 163 | - } | |
| 164 | - | |
| 165 | - /** | |
| 166 | - * Do the same as query. | |
| 167 | - * | |
| 168 | - * @param $query the sql query. | |
| 169 | - * @access public | |
| 170 | - * @return boolean | |
| 171 | - */ | |
| 172 | - public function execute($query) { | |
| 173 | - $result = @mysql_query($query, $this->dbconnection); | |
| 174 | - if($result) { | |
| 175 | - return true; | |
| 176 | - } else { | |
| 177 | - $this->error[] = @mysql_error($this->dbconnection); | |
| 178 | - return false; | |
| 179 | - } | |
| 180 | - } | |
| 181 | - | |
| 182 | - /** | |
| 183 | - * Convenience method for mysql_fetch_object(). | |
| 184 | - * | |
| 185 | - * @param $result The resource returned by query(). | |
| 186 | - * @access public | |
| 187 | - * @return object An object representing a data row. | |
| 188 | - */ | |
| 189 | - public function fetchNextObject($result = NULL) { | |
| 190 | - if ($result == NULL || @mysql_num_rows($result) < 1) | |
| 191 | - return NULL; | |
| 192 | - else | |
| 193 | - return @mysql_fetch_object($result); | |
| 194 | - } | |
| 195 | - | |
| 196 | - /** | |
| 197 | - * Convenience method for mysql_fetch_assoc(). | |
| 198 | - * | |
| 199 | - * @param $result The resource returned by query(). | |
| 200 | - * @access public | |
| 201 | - * @return array Returns an associative array of strings. | |
| 202 | - */ | |
| 203 | - public function fetchAssoc($result = NULL) { | |
| 204 | - $r = array(); | |
| 205 | - if ($result == NULL || @mysql_num_rows($result) < 1) | |
| 206 | - return NULL; | |
| 207 | - else { | |
| 208 | - $row = @mysql_fetch_assoc($result); | |
| 209 | - while ($row) { | |
| 210 | - $r[] = $row; | |
| 211 | - } | |
| 212 | - return $r; | |
| 213 | - } | |
| 214 | - } | |
| 215 | - | |
| 216 | - /** | |
| 217 | - * Close the connection with the database server. | |
| 218 | - * | |
| 219 | - * @param none. | |
| 220 | - * @access public | |
| 221 | - * @return void. | |
| 222 | - */ | |
| 223 | - public function close() { | |
| 224 | - @mysql_close($this->dbconnection); | |
| 225 | - } | |
| 226 | - | |
| 227 | - /** | |
| 228 | - * Get database errors. | |
| 229 | - * | |
| 230 | - * @param none. | |
| 231 | - * @access public | |
| 232 | - * @return array. | |
| 233 | - */ | |
| 234 | - public function getErrors() { | |
| 235 | - return $this->error; | |
| 236 | - } | |
| 237 | - | |
| 238 | - /** | |
| 239 | - * Fetches the last generated error | |
| 240 | - | |
| 241 | - * @return string | |
| 242 | - */ | |
| 243 | - function getLastError() { | |
| 244 | - return end($this->error); | |
| 245 | - } | |
| 246 | - | |
| 247 | - /** | |
| 248 | - * Start a database transaction | |
| 249 | - */ | |
| 250 | - public function startTransaction() { | |
| 251 | - $this->query("START TRANSACTION"); | |
| 252 | - } | |
| 253 | - | |
| 254 | - /** | |
| 255 | - * Roll back a database transaction | |
| 256 | - */ | |
| 257 | - public function rollback() { | |
| 258 | - $this->query("ROLLBACK"); | |
| 259 | - } | |
| 260 | -} | |
| 261 | -?> | |
| 262 | 0 | \ No newline at end of file |
setup/migrate/index.php
setup/migrate/lib/services/service.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | -* Service Controller. | |
| 4 | -* | |
| 5 | -* KnowledgeTree Community Edition | |
| 6 | -* Document Management Made Simple | |
| 7 | -* Copyright(C) 2008,2009 KnowledgeTree Inc. | |
| 8 | -* Portions copyright The Jam Warehouse Software(Pty) Limited | |
| 9 | -* | |
| 10 | -* This program is free software; you can redistribute it and/or modify it under | |
| 11 | -* the terms of the GNU General Public License version 3 as published by the | |
| 12 | -* Free Software Foundation. | |
| 13 | -* | |
| 14 | -* This program is distributed in the hope that it will be useful, but WITHOUT | |
| 15 | -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 16 | -* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 17 | -* details. | |
| 18 | -* | |
| 19 | -* You should have received a copy of the GNU General Public License | |
| 20 | -* along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 21 | -* | |
| 22 | -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 23 | -* California 94120-7775, or email info@knowledgetree.com. | |
| 24 | -* | |
| 25 | -* The interactive user interfaces in modified source and object code versions | |
| 26 | -* of this program must display Appropriate Legal Notices, as required under | |
| 27 | -* Section 5 of the GNU General Public License version 3. | |
| 28 | -* | |
| 29 | -* In accordance with Section 7(b) of the GNU General Public License version 3, | |
| 30 | -* these Appropriate Legal Notices must retain the display of the "Powered by | |
| 31 | -* KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 32 | -* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | |
| 33 | -* must display the words "Powered by KnowledgeTree" and retain the original | |
| 34 | -* copyright notice. | |
| 35 | -* | |
| 36 | -* @copyright 2008-2009, KnowledgeTree Inc. | |
| 37 | -* @license GNU General Public License version 3 | |
| 38 | -* @author KnowledgeTree Team | |
| 39 | -* @package Migrater | |
| 40 | -* @version Version 0.1 | |
| 41 | -*/ | |
| 42 | - | |
| 43 | -class Service { | |
| 44 | - public function __construct() {} | |
| 45 | - | |
| 46 | - public function load() {} | |
| 47 | - | |
| 48 | - public function start() {} | |
| 49 | - | |
| 50 | - public function stop() {} | |
| 51 | - | |
| 52 | - public function migrate() {} | |
| 53 | - | |
| 54 | - public function restart() {} | |
| 55 | - | |
| 56 | - public function unmigrate() {} | |
| 57 | - | |
| 58 | - public function status() {} | |
| 59 | - | |
| 60 | - public function pause() {} | |
| 61 | - | |
| 62 | - public function cont() {} | |
| 63 | -} | |
| 64 | -?> | |
| 65 | 0 | \ No newline at end of file |
setup/migrate/lib/services/unixAgent.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | -* Unix Agent Service Controller. | |
| 4 | -* | |
| 5 | -* KnowledgeTree Community Edition | |
| 6 | -* Document Management Made Simple | |
| 7 | -* Copyright(C) 2008,2009 KnowledgeTree Inc. | |
| 8 | -* Portions copyright The Jam Warehouse Software(Pty) Limited | |
| 9 | -* | |
| 10 | -* This program is free software; you can redistribute it and/or modify it under | |
| 11 | -* the terms of the GNU General Public License version 3 as published by the | |
| 12 | -* Free Software Foundation. | |
| 13 | -* | |
| 14 | -* This program is distributed in the hope that it will be useful, but WITHOUT | |
| 15 | -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 16 | -* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 17 | -* details. | |
| 18 | -* | |
| 19 | -* You should have received a copy of the GNU General Public License | |
| 20 | -* along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 21 | -* | |
| 22 | -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 23 | -* California 94120-7775, or email info@knowledgetree.com. | |
| 24 | -* | |
| 25 | -* The interactive user interfaces in modified source and object code versions | |
| 26 | -* of this program must display Appropriate Legal Notices, as required under | |
| 27 | -* Section 5 of the GNU General Public License version 3. | |
| 28 | -* | |
| 29 | -* In accordance with Section 7(b) of the GNU General Public License version 3, | |
| 30 | -* these Appropriate Legal Notices must retain the display of the "Powered by | |
| 31 | -* KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 32 | -* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | |
| 33 | -* must display the words "Powered by KnowledgeTree" and retain the original | |
| 34 | -* copyright notice. | |
| 35 | -* | |
| 36 | -* @copyright 2008-2009, KnowledgeTree Inc. | |
| 37 | -* @license GNU General Public License version 3 | |
| 38 | -* @author KnowledgeTree Team | |
| 39 | -* @package Migrater | |
| 40 | -* @version Version 0.1 | |
| 41 | -*/ | |
| 42 | - | |
| 43 | -class unixAgent extends unixService { | |
| 44 | - | |
| 45 | - public function __construct() { | |
| 46 | - $this->name = "KTAgentTest"; | |
| 47 | - } | |
| 48 | - | |
| 49 | - | |
| 50 | -} | |
| 51 | -?> | |
| 52 | 0 | \ No newline at end of file |
setup/migrate/lib/services/unixLucene.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | -* Unix Lucene Service Controller. | |
| 4 | -* | |
| 5 | -* KnowledgeTree Community Edition | |
| 6 | -* Document Management Made Simple | |
| 7 | -* Copyright(C) 2008,2009 KnowledgeTree Inc. | |
| 8 | -* Portions copyright The Jam Warehouse Software(Pty) Limited | |
| 9 | -* | |
| 10 | -* This program is free software; you can redistribute it and/or modify it under | |
| 11 | -* the terms of the GNU General Public License version 3 as published by the | |
| 12 | -* Free Software Foundation. | |
| 13 | -* | |
| 14 | -* This program is distributed in the hope that it will be useful, but WITHOUT | |
| 15 | -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 16 | -* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 17 | -* details. | |
| 18 | -* | |
| 19 | -* You should have received a copy of the GNU General Public License | |
| 20 | -* along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 21 | -* | |
| 22 | -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 23 | -* California 94120-7775, or email info@knowledgetree.com. | |
| 24 | -* | |
| 25 | -* The interactive user interfaces in modified source and object code versions | |
| 26 | -* of this program must display Appropriate Legal Notices, as required under | |
| 27 | -* Section 5 of the GNU General Public License version 3. | |
| 28 | -* | |
| 29 | -* In accordance with Section 7(b) of the GNU General Public License version 3, | |
| 30 | -* these Appropriate Legal Notices must retain the display of the "Powered by | |
| 31 | -* KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 32 | -* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | |
| 33 | -* must display the words "Powered by KnowledgeTree" and retain the original | |
| 34 | -* copyright notice. | |
| 35 | -* | |
| 36 | -* @copyright 2008-2009, KnowledgeTree Inc. | |
| 37 | -* @license GNU General Public License version 3 | |
| 38 | -* @author KnowledgeTree Team | |
| 39 | -* @package Migrater | |
| 40 | -* @version Version 0.1 | |
| 41 | -*/ | |
| 42 | - | |
| 43 | -class unixLucene extends unixService { | |
| 44 | - public $util; | |
| 45 | - private $shutdownScript; | |
| 46 | - private $indexerDir; | |
| 47 | - private $lucenePidFile; | |
| 48 | - private $luceneDir; | |
| 49 | - private $luceneSource; | |
| 50 | - private $luceneSourceLoc; | |
| 51 | - private $javaXms; | |
| 52 | - private $javaXmx; | |
| 53 | - | |
| 54 | - public function __construct() { | |
| 55 | - $this->name = "KTLuceneTest"; | |
| 56 | - $this->setLuceneSource("ktlucene.jar"); | |
| 57 | - $this->util = new MigrateUtil(); | |
| 58 | - } | |
| 59 | - | |
| 60 | - public function load() { | |
| 61 | - $this->setLuceneDir(SYSTEM_DIR."bin".DS."luceneserver".DS); | |
| 62 | - $this->setIndexerDir(SYSTEM_DIR."search2".DS."indexing".DS."bin".DS); | |
| 63 | - $this->setLucenePidFile("lucene_test.pid"); | |
| 64 | - $this->setJavaXms(512); | |
| 65 | - $this->setJavaXmx(512); | |
| 66 | - $this->setLuceneSourceLoc("ktlucene.jar"); | |
| 67 | - $this->setShutdownScript("shutdown.php"); | |
| 68 | - } | |
| 69 | - | |
| 70 | - public function setIndexerDir($indexerDir) { | |
| 71 | - $this->indexerDir = $indexerDir; | |
| 72 | - } | |
| 73 | - | |
| 74 | - private function getIndexerDir() { | |
| 75 | - return $this->indexerDir; | |
| 76 | - } | |
| 77 | - | |
| 78 | - private function setShutdownScript($shutdownScript) { | |
| 79 | - $this->shutdownScript = $shutdownScript; | |
| 80 | - } | |
| 81 | - | |
| 82 | - public function getShutdownScript() { | |
| 83 | - return $this->shutdownScript; | |
| 84 | - } | |
| 85 | - | |
| 86 | - private function setLucenePidFile($lucenePidFile) { | |
| 87 | - $this->lucenePidFile = $lucenePidFile; | |
| 88 | - } | |
| 89 | - | |
| 90 | - private function getLucenePidFile() { | |
| 91 | - return $this->lucenePidFile; | |
| 92 | - } | |
| 93 | - | |
| 94 | - private function setLuceneDir($luceneDir) { | |
| 95 | - $this->luceneDir = $luceneDir; | |
| 96 | - } | |
| 97 | - | |
| 98 | - public function getLuceneDir() { | |
| 99 | - return $this->luceneDir; | |
| 100 | - } | |
| 101 | - | |
| 102 | - private function setJavaXms($javaXms) { | |
| 103 | - $this->javaXms = "-Xms$javaXms"; | |
| 104 | - } | |
| 105 | - | |
| 106 | - public function getJavaXms() { | |
| 107 | - return $this->javaXms; | |
| 108 | - } | |
| 109 | - | |
| 110 | - private function setJavaXmx($javaXmx) { | |
| 111 | - $this->javaXmx = "-Xmx$javaXmx"; | |
| 112 | - } | |
| 113 | - | |
| 114 | - public function getJavaXmx() { | |
| 115 | - return $this->javaXmx; | |
| 116 | - } | |
| 117 | - | |
| 118 | - private function setLuceneSource($luceneSource) { | |
| 119 | - $this->luceneSource = $luceneSource; | |
| 120 | - } | |
| 121 | - | |
| 122 | - public function getLuceneSource() { | |
| 123 | - return $this->luceneSource; | |
| 124 | - } | |
| 125 | - | |
| 126 | - private function setLuceneSourceLoc($luceneSourceLoc) { | |
| 127 | - $this->luceneSourceLoc = $this->getLuceneDir().$luceneSourceLoc; | |
| 128 | - } | |
| 129 | - | |
| 130 | - public function getLuceneSourceLoc() { | |
| 131 | - return $this->luceneSourceLoc; | |
| 132 | - } | |
| 133 | - | |
| 134 | - public function getJavaOptions() { | |
| 135 | - return " {$this->getJavaXmx()} {$this->getJavaXmx()} -jar "; | |
| 136 | - } | |
| 137 | - | |
| 138 | - public function stop() { | |
| 139 | - // TODO: Breaks things | |
| 140 | - $state = $this->status(); | |
| 141 | - if($state != '') { | |
| 142 | - $cmd = "pkill -f ".$this->getLuceneSource(); | |
| 143 | - $response = $this->util->pexec($cmd); | |
| 144 | - return $response; | |
| 145 | - } | |
| 146 | - | |
| 147 | - } | |
| 148 | - | |
| 149 | - public function migrate() { | |
| 150 | - $status = $this->status(); | |
| 151 | - if($status == '') { | |
| 152 | - return $this->start(); | |
| 153 | - } else { | |
| 154 | - return $status; | |
| 155 | - } | |
| 156 | - } | |
| 157 | - | |
| 158 | - public function status() { | |
| 159 | - $cmd = "ps ax | grep ".$this->getLuceneSource(); | |
| 160 | - $response = $this->util->pexec($cmd); | |
| 161 | - if(is_array($response['out'])) { | |
| 162 | - if(count($response['out']) > 1) { | |
| 163 | - foreach ($response['out'] as $r) { | |
| 164 | - preg_match('/grep/', $r, $matches); // Ignore grep | |
| 165 | - if(!$matches) { | |
| 166 | - return 'STARTED'; | |
| 167 | - } | |
| 168 | - } | |
| 169 | - } else { | |
| 170 | - return ''; | |
| 171 | - } | |
| 172 | - } | |
| 173 | - | |
| 174 | - return ''; | |
| 175 | - } | |
| 176 | - | |
| 177 | - public function unmigrate() { | |
| 178 | - $this->stop(); | |
| 179 | - } | |
| 180 | - | |
| 181 | - public function start() { | |
| 182 | - $state = $this->status(); | |
| 183 | - return ; | |
| 184 | - if($state != 'STARTED') { | |
| 185 | - $cmd = "cd ".$this->getLuceneDir()."; "; | |
| 186 | - $cmd .= "nohup java -jar ".$this->getLuceneSource()." > ".SYS_LOG_DIR."lucene.log 2>&1 & echo $!"; | |
| 187 | - $response = $this->util->pexec($cmd); | |
| 188 | - | |
| 189 | - return $response; | |
| 190 | - } elseif ($state == '') { | |
| 191 | - // Start Service | |
| 192 | - return true; | |
| 193 | - } else { | |
| 194 | - // Service Running Already | |
| 195 | - return true; | |
| 196 | - } | |
| 197 | - | |
| 198 | - return false; | |
| 199 | - } | |
| 200 | - | |
| 201 | - | |
| 202 | -} | |
| 203 | -?> | |
| 204 | 0 | \ No newline at end of file |
setup/migrate/lib/services/unixOpenOffice.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | -* Unix Agent Service Controller. | |
| 4 | -* | |
| 5 | -* KnowledgeTree Community Edition | |
| 6 | -* Document Management Made Simple | |
| 7 | -* Copyright(C) 2008,2009 KnowledgeTree Inc. | |
| 8 | -* Portions copyright The Jam Warehouse Software(Pty) Limited | |
| 9 | -* | |
| 10 | -* This program is free software; you can redistribute it and/or modify it under | |
| 11 | -* the terms of the GNU General Public License version 3 as published by the | |
| 12 | -* Free Software Foundation. | |
| 13 | -* | |
| 14 | -* This program is distributed in the hope that it will be useful, but WITHOUT | |
| 15 | -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 16 | -* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 17 | -* details. | |
| 18 | -* | |
| 19 | -* You should have received a copy of the GNU General Public License | |
| 20 | -* along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 21 | -* | |
| 22 | -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 23 | -* California 94120-7775, or email info@knowledgetree.com. | |
| 24 | -* | |
| 25 | -* The interactive user interfaces in modified source and object code versions | |
| 26 | -* of this program must display Appropriate Legal Notices, as required under | |
| 27 | -* Section 5 of the GNU General Public License version 3. | |
| 28 | -* | |
| 29 | -* In accordance with Section 7(b) of the GNU General Public License version 3, | |
| 30 | -* these Appropriate Legal Notices must retain the display of the "Powered by | |
| 31 | -* KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 32 | -* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | |
| 33 | -* must display the words "Powered by KnowledgeTree" and retain the original | |
| 34 | -* copyright notice. | |
| 35 | -* | |
| 36 | -* @copyright 2008-2009, KnowledgeTree Inc. | |
| 37 | -* @license GNU General Public License version 3 | |
| 38 | -* @author KnowledgeTree Team | |
| 39 | -* @package Migrater | |
| 40 | -* @version Version 0.1 | |
| 41 | -*/ | |
| 42 | - | |
| 43 | -class unixOpenOffice extends unixService { | |
| 44 | - | |
| 45 | - // utility | |
| 46 | - public $util; | |
| 47 | - // path to office | |
| 48 | - private $path; | |
| 49 | - // host | |
| 50 | - private $host; | |
| 51 | - // pid running | |
| 52 | - private $pidFile; | |
| 53 | - // port to bind to | |
| 54 | - private $port; | |
| 55 | - // bin folder | |
| 56 | - private $bin; | |
| 57 | - // office executable | |
| 58 | - private $soffice; | |
| 59 | - // office log file | |
| 60 | - private $log; | |
| 61 | - private $options; | |
| 62 | - | |
| 63 | - # 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 & | |
| 64 | - public function __construct() { | |
| 65 | - $this->name = "openoffice"; | |
| 66 | - $this->util = new MigrateUtil(); | |
| 67 | - } | |
| 68 | - | |
| 69 | - public function load() { | |
| 70 | - $this->setPort("8100"); | |
| 71 | - $this->setHost("localhost"); | |
| 72 | - $this->setLog("openoffice.log"); | |
| 73 | - $this->setBin("soffice"); | |
| 74 | - $this->setOption(); | |
| 75 | - } | |
| 76 | - | |
| 77 | - private function setPort($port = "8100") { | |
| 78 | - $this->port = $port; | |
| 79 | - } | |
| 80 | - | |
| 81 | - public function getPort() { | |
| 82 | - return $this->port; | |
| 83 | - } | |
| 84 | - | |
| 85 | - private function setHost($host = "localhost") { | |
| 86 | - $this->host = $host; | |
| 87 | - } | |
| 88 | - | |
| 89 | - public function getHost() { | |
| 90 | - return $this->host; | |
| 91 | - } | |
| 92 | - | |
| 93 | - private function setLog($log = "openoffice.log") { | |
| 94 | - $this->log = $log; | |
| 95 | - } | |
| 96 | - | |
| 97 | - public function getLog() { | |
| 98 | - return $this->log; | |
| 99 | - } | |
| 100 | - | |
| 101 | - private function setBin($bin = "soffice") { | |
| 102 | - $this->bin = $bin; | |
| 103 | - } | |
| 104 | - | |
| 105 | - public function getBin() { | |
| 106 | - return $this->bin; | |
| 107 | - } | |
| 108 | - | |
| 109 | - private function setOption() { | |
| 110 | - $this->options = "-nofirststartwizard -nologo -headless -accept=\"socket,host={$this->getHost()},port={$this->getPort()};urp;StarOffice.ServiceManager\""; | |
| 111 | - } | |
| 112 | - | |
| 113 | - public function getOption() { | |
| 114 | - return $this->options; | |
| 115 | - } | |
| 116 | - | |
| 117 | - public function migrate() { | |
| 118 | - $status = $this->status(); | |
| 119 | - if($status == '') { | |
| 120 | - return $this->start(); | |
| 121 | - } else { | |
| 122 | - return $status; | |
| 123 | - } | |
| 124 | - } | |
| 125 | - | |
| 126 | - public function start() { | |
| 127 | - $state = $this->status(); | |
| 128 | - return ; | |
| 129 | - if($state != 'STARTED') { | |
| 130 | - $cmd = "nohup {$this->getBin()} ".$this->getOption()." > ".SYS_LOG_DIR."{$this->getLog()} 2>&1 & echo $!"; | |
| 131 | - $response = $this->util->pexec($cmd); | |
| 132 | - | |
| 133 | - return $response; | |
| 134 | - } elseif ($state == '') { | |
| 135 | - // Start Service | |
| 136 | - return true; | |
| 137 | - } else { | |
| 138 | - // Service Running Already | |
| 139 | - return true; | |
| 140 | - } | |
| 141 | - | |
| 142 | - return false; | |
| 143 | - } | |
| 144 | -} | |
| 145 | -?> | |
| 146 | 0 | \ No newline at end of file |
setup/migrate/lib/services/unixScheduler.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | -* Unix Scheduler Service Controller. | |
| 4 | -* | |
| 5 | -* KnowledgeTree Community Edition | |
| 6 | -* Document Management Made Simple | |
| 7 | -* Copyright(C) 2008,2009 KnowledgeTree Inc. | |
| 8 | -* Portions copyright The Jam Warehouse Software(Pty) Limited | |
| 9 | -* | |
| 10 | -* This program is free software; you can redistribute it and/or modify it under | |
| 11 | -* the terms of the GNU General Public License version 3 as published by the | |
| 12 | -* Free Software Foundation. | |
| 13 | -* | |
| 14 | -* This program is distributed in the hope that it will be useful, but WITHOUT | |
| 15 | -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 16 | -* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 17 | -* details. | |
| 18 | -* | |
| 19 | -* You should have received a copy of the GNU General Public License | |
| 20 | -* along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 21 | -* | |
| 22 | -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 23 | -* California 94120-7775, or email info@knowledgetree.com. | |
| 24 | -* | |
| 25 | -* The interactive user interfaces in modified source and object code versions | |
| 26 | -* of this program must display Appropriate Legal Notices, as required under | |
| 27 | -* Section 5 of the GNU General Public License version 3. | |
| 28 | -* | |
| 29 | -* In accordance with Section 7(b) of the GNU General Public License version 3, | |
| 30 | -* these Appropriate Legal Notices must retain the display of the "Powered by | |
| 31 | -* KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 32 | -* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | |
| 33 | -* must display the words "Powered by KnowledgeTree" and retain the original | |
| 34 | -* copyright notice. | |
| 35 | -* | |
| 36 | -* @copyright 2008-2009, KnowledgeTree Inc. | |
| 37 | -* @license GNU General Public License version 3 | |
| 38 | -* @author KnowledgeTree Team | |
| 39 | -* @package Migrater | |
| 40 | -* @version Version 0.1 | |
| 41 | -*/ | |
| 42 | - | |
| 43 | -class unixScheduler extends unixService { | |
| 44 | - private $schedulerDir; | |
| 45 | - private $schedulerSource; | |
| 46 | - private $schedulerSourceLoc; | |
| 47 | - private $systemDir; | |
| 48 | - | |
| 49 | - public function __construct() { | |
| 50 | - $this->name = "KTSchedulerTest"; | |
| 51 | - $this->util = new MigrateUtil(); | |
| 52 | - } | |
| 53 | - | |
| 54 | - public function load() { | |
| 55 | - $this->setSystemDir(SYSTEM_ROOT."bin".DS); | |
| 56 | - $this->setSchedulerDir(SYSTEM_DIR."bin".DS); | |
| 57 | - $this->setSchedulerSource('schedulerTask.sh'); | |
| 58 | - $this->setSchedulerSourceLoc('schedulerTask.sh'); | |
| 59 | - } | |
| 60 | - | |
| 61 | - function setSystemDir($systemDir) { | |
| 62 | - $this->systemDir = $systemDir; | |
| 63 | - } | |
| 64 | - | |
| 65 | - function getSystemDir() { | |
| 66 | - if(file_exists($this->systemDir)) | |
| 67 | - return $this->systemDir; | |
| 68 | - return false; | |
| 69 | - } | |
| 70 | - | |
| 71 | - function setSchedulerDir($schedulerDir) { | |
| 72 | - $this->schedulerDir = $schedulerDir; | |
| 73 | - } | |
| 74 | - | |
| 75 | - function getSchedulerDir() { | |
| 76 | - return $this->schedulerDir; | |
| 77 | - } | |
| 78 | - | |
| 79 | - function setSchedulerSource($schedulerSource) { | |
| 80 | - $this->schedulerSource = $schedulerSource; | |
| 81 | - } | |
| 82 | - | |
| 83 | - function getSchedulerSource() { | |
| 84 | - return $this->schedulerSource; | |
| 85 | - } | |
| 86 | - | |
| 87 | - function setSchedulerSourceLoc($schedulerSourceLoc) { | |
| 88 | - $this->schedulerSourceLoc = $this->getSchedulerDir().$schedulerSourceLoc; | |
| 89 | - } | |
| 90 | - | |
| 91 | - function getSchedulerSourceLoc() { | |
| 92 | - if(file_exists($this->schedulerSourceLoc)) | |
| 93 | - return $this->schedulerSourceLoc; | |
| 94 | - return false; | |
| 95 | - } | |
| 96 | - | |
| 97 | - function writeSchedulerTask() { | |
| 98 | - $fLoc = $this->getSchedulerDir().$this->getSchedulerSource(); | |
| 99 | - $fp = @fopen($fLoc, "w+"); | |
| 100 | - $content = "#!/bin/sh\n"; | |
| 101 | - $content .= "cd ".$this->getSchedulerDir()."\n"; | |
| 102 | - $content .= "while true; do\n"; | |
| 103 | - // TODO : This will not work without CLI | |
| 104 | - $content .= "php -Cq scheduler.php\n"; | |
| 105 | - $content .= "sleep 30\n"; | |
| 106 | - $content .= "done"; | |
| 107 | - @fwrite($fp, $content); | |
| 108 | - @fclose($fp); | |
| 109 | - @chmod($fLoc, '0644'); | |
| 110 | - } | |
| 111 | - | |
| 112 | - function migrate() { | |
| 113 | - $status = $this->status(); | |
| 114 | - if($status == '') { | |
| 115 | - return $this->start(); | |
| 116 | - } else { | |
| 117 | - return $status; | |
| 118 | - } | |
| 119 | - } | |
| 120 | - | |
| 121 | - function unmigrate() { | |
| 122 | - $this->stop(); | |
| 123 | - } | |
| 124 | - | |
| 125 | - function stop() { | |
| 126 | - $cmd = "pkill -f ".$this->schedulerSource; | |
| 127 | - $response = $this->util->pexec($cmd); | |
| 128 | - return $response; | |
| 129 | - } | |
| 130 | - | |
| 131 | - function status() { | |
| 132 | - $cmd = "ps ax | grep ".$this->getSchedulerSource(); | |
| 133 | - $response = $this->util->pexec($cmd); | |
| 134 | - if(is_array($response['out'])) { | |
| 135 | - if(count($response['out']) > 1) { | |
| 136 | - foreach ($response['out'] as $r) { | |
| 137 | - preg_match('/grep/', $r, $matches); // Ignore grep | |
| 138 | - if(!$matches) { | |
| 139 | - return 'STARTED'; | |
| 140 | - } | |
| 141 | - } | |
| 142 | - } else { | |
| 143 | - return ''; | |
| 144 | - } | |
| 145 | - } | |
| 146 | - | |
| 147 | - return ''; | |
| 148 | - } | |
| 149 | - | |
| 150 | - function start() { | |
| 151 | - // TODO : Write sh on the fly? Not sure the reasoning here | |
| 152 | - $source = $this->getSchedulerSourceLoc(); | |
| 153 | - return ; | |
| 154 | - if($source) { // Source | |
| 155 | - $cmd = "nohup ".$source." > ".SYS_LOG_DIR."scheduler.log 2>&1 & echo $!"; | |
| 156 | - $response = $this->util->pexec($cmd); | |
| 157 | - return $response; | |
| 158 | - } else { // Could be Stack | |
| 159 | - $source = SYS_BIN_DIR.$this->schedulerSource; | |
| 160 | - if(!file_exists($source)) { | |
| 161 | - // Write it | |
| 162 | - $this->writeSchedulerTask(); | |
| 163 | - } | |
| 164 | - $cmd = "nohup ".$source." > ".SYS_LOG_DIR."scheduler.log 2>&1 & echo $!"; | |
| 165 | - $response = $this->util->pexec($cmd); | |
| 166 | - return $response; | |
| 167 | - } | |
| 168 | - | |
| 169 | - return false; | |
| 170 | - } | |
| 171 | - | |
| 172 | - | |
| 173 | - | |
| 174 | -} | |
| 175 | -?> | |
| 176 | 0 | \ No newline at end of file |
setup/migrate/lib/services/unixService.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | -* Unix Service Controller. | |
| 4 | -* | |
| 5 | -* KnowledgeTree Community Edition | |
| 6 | -* Document Management Made Simple | |
| 7 | -* Copyright(C) 2008,2009 KnowledgeTree Inc. | |
| 8 | -* Portions copyright The Jam Warehouse Software(Pty) Limited | |
| 9 | -* | |
| 10 | -* This program is free software; you can redistribute it and/or modify it under | |
| 11 | -* the terms of the GNU General Public License version 3 as published by the | |
| 12 | -* Free Software Foundation. | |
| 13 | -* | |
| 14 | -* This program is distributed in the hope that it will be useful, but WITHOUT | |
| 15 | -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 16 | -* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 17 | -* details. | |
| 18 | -* | |
| 19 | -* You should have received a copy of the GNU General Public License | |
| 20 | -* along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 21 | -* | |
| 22 | -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 23 | -* California 94120-7775, or email info@knowledgetree.com. | |
| 24 | -* | |
| 25 | -* The interactive user interfaces in modified source and object code versions | |
| 26 | -* of this program must display Appropriate Legal Notices, as required under | |
| 27 | -* Section 5 of the GNU General Public License version 3. | |
| 28 | -* | |
| 29 | -* In accordance with Section 7(b) of the GNU General Public License version 3, | |
| 30 | -* these Appropriate Legal Notices must retain the display of the "Powered by | |
| 31 | -* KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 32 | -* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | |
| 33 | -* must display the words "Powered by KnowledgeTree" and retain the original | |
| 34 | -* copyright notice. | |
| 35 | -* | |
| 36 | -* @copyright 2008-2009, KnowledgeTree Inc. | |
| 37 | -* @license GNU General Public License version 3 | |
| 38 | -* @author KnowledgeTree Team | |
| 39 | -* @package Migrater | |
| 40 | -* @version Version 0.1 | |
| 41 | -*/ | |
| 42 | - | |
| 43 | -class unixService extends Service { | |
| 44 | - public $name; | |
| 45 | - | |
| 46 | - /** | |
| 47 | - * Retrieve Service name | |
| 48 | - * | |
| 49 | - * @author KnowledgeTree Team | |
| 50 | - * @access public | |
| 51 | - * @param none | |
| 52 | - * @return string | |
| 53 | - */ | |
| 54 | - public function getName() { | |
| 55 | - return $this->name; | |
| 56 | - } | |
| 57 | - | |
| 58 | - public function load() {} | |
| 59 | - | |
| 60 | - /** | |
| 61 | - * Start Service | |
| 62 | - * | |
| 63 | - * @author KnowledgeTree Team | |
| 64 | - * @access public | |
| 65 | - * @param none | |
| 66 | - * @return mixed | |
| 67 | - */ | |
| 68 | - public function start() { | |
| 69 | - | |
| 70 | - } | |
| 71 | - | |
| 72 | - /** | |
| 73 | - * Stop Service | |
| 74 | - * | |
| 75 | - * @author KnowledgeTree Team | |
| 76 | - * @access public | |
| 77 | - * @param none | |
| 78 | - * @return mixed | |
| 79 | - */ | |
| 80 | - public function stop() { | |
| 81 | - | |
| 82 | - } | |
| 83 | - | |
| 84 | - public function migrate() {} | |
| 85 | - | |
| 86 | - /** | |
| 87 | - * Restart Service | |
| 88 | - * | |
| 89 | - * @author KnowledgeTree Team | |
| 90 | - * @access public | |
| 91 | - * @param none | |
| 92 | - * @return mixed | |
| 93 | - */ | |
| 94 | - public function restart() { | |
| 95 | - | |
| 96 | - } | |
| 97 | - | |
| 98 | - /** | |
| 99 | - * Unmigrate Service | |
| 100 | - * | |
| 101 | - * @author KnowledgeTree Team | |
| 102 | - * @access public | |
| 103 | - * @param none | |
| 104 | - * @return mixed | |
| 105 | - */ | |
| 106 | - public function unmigrate() { | |
| 107 | - | |
| 108 | - } | |
| 109 | - | |
| 110 | - /** | |
| 111 | - * Retrieve Status Service | |
| 112 | - * | |
| 113 | - * @author KnowledgeTree Team | |
| 114 | - * @access public | |
| 115 | - * @param none | |
| 116 | - * @return mixed | |
| 117 | - */ | |
| 118 | - public function status() { | |
| 119 | - | |
| 120 | - } | |
| 121 | - | |
| 122 | - /** | |
| 123 | - * Pause Service | |
| 124 | - * | |
| 125 | - * @author KnowledgeTree Team | |
| 126 | - * @access public | |
| 127 | - * @param none | |
| 128 | - * @return mixed | |
| 129 | - */ | |
| 130 | - public function pause() { | |
| 131 | - | |
| 132 | - } | |
| 133 | - | |
| 134 | - /** | |
| 135 | - * Continue Service | |
| 136 | - * | |
| 137 | - * @author KnowledgeTree Team | |
| 138 | - * @access public | |
| 139 | - * @param none | |
| 140 | - * @return mixed | |
| 141 | - */ | |
| 142 | - public function cont() { | |
| 143 | - | |
| 144 | - } | |
| 145 | - | |
| 146 | - | |
| 147 | -} | |
| 148 | -?> | |
| 149 | 0 | \ No newline at end of file |
setup/migrate/lib/services/windowsAgent.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | -* Windows Agent Service Controller. | |
| 4 | -* | |
| 5 | -* KnowledgeTree Community Edition | |
| 6 | -* Document Management Made Simple | |
| 7 | -* Copyright(C) 2008,2009 KnowledgeTree Inc. | |
| 8 | -* Portions copyright The Jam Warehouse Software(Pty) Limited | |
| 9 | -* | |
| 10 | -* This program is free software; you can redistribute it and/or modify it under | |
| 11 | -* the terms of the GNU General Public License version 3 as published by the | |
| 12 | -* Free Software Foundation. | |
| 13 | -* | |
| 14 | -* This program is distributed in the hope that it will be useful, but WITHOUT | |
| 15 | -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 16 | -* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 17 | -* details. | |
| 18 | -* | |
| 19 | -* You should have received a copy of the GNU General Public License | |
| 20 | -* along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 21 | -* | |
| 22 | -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 23 | -* California 94120-7775, or email info@knowledgetree.com. | |
| 24 | -* | |
| 25 | -* The interactive user interfaces in modified source and object code versions | |
| 26 | -* of this program must display Appropriate Legal Notices, as required under | |
| 27 | -* Section 5 of the GNU General Public License version 3. | |
| 28 | -* | |
| 29 | -* In accordance with Section 7(b) of the GNU General Public License version 3, | |
| 30 | -* these Appropriate Legal Notices must retain the display of the "Powered by | |
| 31 | -* KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 32 | -* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | |
| 33 | -* must display the words "Powered by KnowledgeTree" and retain the original | |
| 34 | -* copyright notice. | |
| 35 | -* | |
| 36 | -* @copyright 2008-2009, KnowledgeTree Inc. | |
| 37 | -* @license GNU General Public License version 3 | |
| 38 | -* @author KnowledgeTree Team | |
| 39 | -* @package Migrater | |
| 40 | -* @version Version 0.1 | |
| 41 | -*/ | |
| 42 | - | |
| 43 | -class windowsAgent extends windowsService { | |
| 44 | - | |
| 45 | - | |
| 46 | - public function __construct() { | |
| 47 | - $this->name = "KTAgentTest"; | |
| 48 | - } | |
| 49 | - | |
| 50 | -} | |
| 51 | -?> | |
| 52 | 0 | \ No newline at end of file |
setup/migrate/lib/services/windowsLucene.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | -* Windows Lucene Service Controller. | |
| 4 | -* | |
| 5 | -* KnowledgeTree Community Edition | |
| 6 | -* Document Management Made Simple | |
| 7 | -* Copyright (C) 2008,2009 KnowledgeTree Inc. | |
| 8 | -* Portions copyright The Jam Warehouse Software (Pty) Limited | |
| 9 | -* | |
| 10 | -* This program is free software; you can redistribute it and/or modify it under | |
| 11 | -* the terms of the GNU General Public License version 3 as published by the | |
| 12 | -* Free Software Foundation. | |
| 13 | -* | |
| 14 | -* This program is distributed in the hope that it will be useful, but WITHOUT | |
| 15 | -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 16 | -* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 17 | -* details. | |
| 18 | -* | |
| 19 | -* You should have received a copy of the GNU General Public License | |
| 20 | -* along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 21 | -* | |
| 22 | -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 23 | -* California 94120-7775, or email info@knowledgetree.com. | |
| 24 | -* | |
| 25 | -* The interactive user interfaces in modified source and object code versions | |
| 26 | -* of this program must display Appropriate Legal Notices, as required under | |
| 27 | -* Section 5 of the GNU General Public License version 3. | |
| 28 | -* | |
| 29 | -* In accordance with Section 7(b) of the GNU General Public License version 3, | |
| 30 | -* these Appropriate Legal Notices must retain the display of the "Powered by | |
| 31 | -* KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 32 | -* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | |
| 33 | -* must display the words "Powered by KnowledgeTree" and retain the original | |
| 34 | -* copyright notice. | |
| 35 | -* | |
| 36 | -* @copyright 2008-2009, KnowledgeTree Inc. | |
| 37 | -* @license GNU General Public License version 3 | |
| 38 | -* @author KnowledgeTree Team | |
| 39 | -* @package Migrater | |
| 40 | -* @version Version 0.1 | |
| 41 | -*/ | |
| 42 | -class windowsLucene extends windowsService { | |
| 43 | - /** | |
| 44 | - * Java Directory path | |
| 45 | - * | |
| 46 | - * @author KnowledgeTree Team | |
| 47 | - * @access private | |
| 48 | - * @var string | |
| 49 | - */ | |
| 50 | - private $javaBin; | |
| 51 | - | |
| 52 | - /** | |
| 53 | - * Java JVM path | |
| 54 | - * | |
| 55 | - * @author KnowledgeTree Team | |
| 56 | - * @access private | |
| 57 | - * @var string | |
| 58 | - */ | |
| 59 | - private $javaJVM; | |
| 60 | - | |
| 61 | - /** | |
| 62 | - * Java System object | |
| 63 | - * | |
| 64 | - * @author KnowledgeTree Team | |
| 65 | - * @access private | |
| 66 | - * @var object | |
| 67 | - */ | |
| 68 | - private $javaSystem; | |
| 69 | - | |
| 70 | - /** | |
| 71 | - * Lucene executable path | |
| 72 | - * | |
| 73 | - * @author KnowledgeTree Team | |
| 74 | - * @access private | |
| 75 | - * @var string | |
| 76 | - */ | |
| 77 | - private $luceneExe; | |
| 78 | - | |
| 79 | - /** | |
| 80 | - * Lucene jar path | |
| 81 | - * | |
| 82 | - * @author KnowledgeTree Team | |
| 83 | - * @access private | |
| 84 | - * @var string | |
| 85 | - */ | |
| 86 | - private $luceneSource; | |
| 87 | - | |
| 88 | - /** | |
| 89 | - * Lucene package name | |
| 90 | - * | |
| 91 | - * @author KnowledgeTree Team | |
| 92 | - * @access private | |
| 93 | - * @var string | |
| 94 | - */ | |
| 95 | - private $luceneServer; | |
| 96 | - | |
| 97 | - /** | |
| 98 | - * Lucene output log path | |
| 99 | - * | |
| 100 | - * @author KnowledgeTree Team | |
| 101 | - * @access private | |
| 102 | - * @var string | |
| 103 | - */ | |
| 104 | - private $luceneOut; | |
| 105 | - | |
| 106 | - /** | |
| 107 | - * Lucene error log path | |
| 108 | - * | |
| 109 | - * @author KnowledgeTree Team | |
| 110 | - * @access private | |
| 111 | - * @var string | |
| 112 | - */ | |
| 113 | - private $luceneError; | |
| 114 | - | |
| 115 | - /** | |
| 116 | - * Lucene directory path | |
| 117 | - * | |
| 118 | - * @author KnowledgeTree Team | |
| 119 | - * @access private | |
| 120 | - * @var string | |
| 121 | - */ | |
| 122 | - private $luceneDir; | |
| 123 | - | |
| 124 | - /** | |
| 125 | - * Load defaults needed by service | |
| 126 | - * | |
| 127 | - * @author KnowledgeTree Team | |
| 128 | - * @access public | |
| 129 | - * @param string | |
| 130 | - * @return void | |
| 131 | - */ | |
| 132 | - public function load() { | |
| 133 | - $this->name = "KTLuceneTest"; | |
| 134 | - $this->javaSystem = new Java('java.lang.System'); | |
| 135 | - $this->setJavaBin($this->javaSystem->getProperty('java.home').DS."bin"); | |
| 136 | - $this->setLuceneDIR(SYSTEM_DIR."bin".DS."luceneserver"); | |
| 137 | - $this->setLuceneExe("KTLuceneService.exe"); | |
| 138 | - $this->setJavaJVM(); | |
| 139 | - $this->setLuceneSource("ktlucene.jar"); | |
| 140 | - $this->setLuceneServer("com.knowledgetree.lucene.KTLuceneServer"); | |
| 141 | - $this->setLuceneOut("lucene-out.txt"); | |
| 142 | - $this->setLuceneError("lucene-err.txt"); | |
| 143 | - } | |
| 144 | - | |
| 145 | - /** | |
| 146 | - * Set Java Directory path | |
| 147 | - * | |
| 148 | - * @author KnowledgeTree Team | |
| 149 | - * @access private | |
| 150 | - * @param string | |
| 151 | - * @return void | |
| 152 | - */ | |
| 153 | - private function setJavaBin($javaBin) { | |
| 154 | - $this->javaBin = $javaBin; | |
| 155 | - } | |
| 156 | - | |
| 157 | - /** | |
| 158 | - * Get Java Directory path | |
| 159 | - * | |
| 160 | - * @author KnowledgeTree Team | |
| 161 | - * @access public | |
| 162 | - * @param none | |
| 163 | - * @return string | |
| 164 | - */ | |
| 165 | - public function getJavaBin() { | |
| 166 | - return $this->javaBin; | |
| 167 | - } | |
| 168 | - | |
| 169 | - /** | |
| 170 | - * Set Lucene directory path | |
| 171 | - * | |
| 172 | - * @author KnowledgeTree Team | |
| 173 | - * @access private | |
| 174 | - * @param string | |
| 175 | - * @return void | |
| 176 | - */ | |
| 177 | - private function setLuceneDIR($luceneDir) { | |
| 178 | - $this->luceneDir = $luceneDir; | |
| 179 | - } | |
| 180 | - | |
| 181 | - /** | |
| 182 | - * Get Lucene directory path | |
| 183 | - * | |
| 184 | - * @author KnowledgeTree Team | |
| 185 | - * @access public | |
| 186 | - * @param none | |
| 187 | - * @return string | |
| 188 | - */ | |
| 189 | - public function getluceneDir() { | |
| 190 | - if(file_exists($this->luceneDir)) | |
| 191 | - return $this->luceneDir; | |
| 192 | - return false; | |
| 193 | - } | |
| 194 | - | |
| 195 | - /** | |
| 196 | - * Set Lucene executable path | |
| 197 | - * | |
| 198 | - * @author KnowledgeTree Team | |
| 199 | - * @access private | |
| 200 | - * @param string | |
| 201 | - * @return void | |
| 202 | - */ | |
| 203 | - private function setLuceneExe($luceneExe) { | |
| 204 | - $this->luceneExe = $this->getluceneDir().DS.$luceneExe; | |
| 205 | - } | |
| 206 | - | |
| 207 | - /** | |
| 208 | - * Get Lucene executable path | |
| 209 | - * | |
| 210 | - * @author KnowledgeTree Team | |
| 211 | - * @access public | |
| 212 | - * @param string | |
| 213 | - * @return void | |
| 214 | - */ | |
| 215 | - public function getLuceneExe() { | |
| 216 | - if(file_exists($this->luceneExe)) | |
| 217 | - return $this->luceneExe; | |
| 218 | - return false; | |
| 219 | - } | |
| 220 | - | |
| 221 | - /** | |
| 222 | - * Set Lucene source path | |
| 223 | - * | |
| 224 | - * @author KnowledgeTree Team | |
| 225 | - * @access private | |
| 226 | - * @param string | |
| 227 | - * @return void | |
| 228 | - */ | |
| 229 | - private function setLuceneSource($luceneSource) { | |
| 230 | - $this->luceneSource = $this->getluceneDir().DS.$luceneSource; | |
| 231 | - } | |
| 232 | - | |
| 233 | - /** | |
| 234 | - * Get Lucene source path | |
| 235 | - * | |
| 236 | - * @author KnowledgeTree Team | |
| 237 | - * @access public | |
| 238 | - * @param none | |
| 239 | - * @return string | |
| 240 | - */ | |
| 241 | - public function getLuceneSource() { | |
| 242 | - if(file_exists($this->luceneSource)) | |
| 243 | - return $this->luceneSource; | |
| 244 | - return false; | |
| 245 | - } | |
| 246 | - | |
| 247 | - /** | |
| 248 | - * Set Lucene package name | |
| 249 | - * | |
| 250 | - * @author KnowledgeTree Team | |
| 251 | - * @access private | |
| 252 | - * @param string | |
| 253 | - * @return void | |
| 254 | - */ | |
| 255 | - private function setLuceneServer($luceneServer) { | |
| 256 | - $this->luceneServer = $luceneServer; | |
| 257 | - } | |
| 258 | - | |
| 259 | - /** | |
| 260 | - * Get Lucene package name | |
| 261 | - * | |
| 262 | - * @author KnowledgeTree Team | |
| 263 | - * @access public | |
| 264 | - * @param none | |
| 265 | - * @return string | |
| 266 | - */ | |
| 267 | - public function getLuceneServer() { | |
| 268 | - return $this->luceneServer; | |
| 269 | - } | |
| 270 | - | |
| 271 | - /** | |
| 272 | - * Set Lucene output file path | |
| 273 | - * | |
| 274 | - * @author KnowledgeTree Team | |
| 275 | - * @access private | |
| 276 | - * @param string | |
| 277 | - * @return void | |
| 278 | - */ | |
| 279 | - private function setLuceneOut($luceneOut) { | |
| 280 | - $this->luceneOut = SYS_LOG_DIR.$luceneOut; | |
| 281 | - } | |
| 282 | - | |
| 283 | - /** | |
| 284 | - * Get Lucene output file path | |
| 285 | - * | |
| 286 | - * @author KnowledgeTree Team | |
| 287 | - * @access public | |
| 288 | - * @param none | |
| 289 | - * @return string | |
| 290 | - */ | |
| 291 | - public function getLuceneOut() { | |
| 292 | - return $this->luceneOut; | |
| 293 | - } | |
| 294 | - | |
| 295 | - /** | |
| 296 | - * Set Lucene error file path | |
| 297 | - * | |
| 298 | - * @author KnowledgeTree Team | |
| 299 | - * @access private | |
| 300 | - * @param string | |
| 301 | - * @return void | |
| 302 | - */ | |
| 303 | - private function setLuceneError($luceneError) { | |
| 304 | - $this->luceneError = SYS_LOG_DIR.$luceneError; | |
| 305 | - } | |
| 306 | - | |
| 307 | - /** | |
| 308 | - * Get Lucene error file path | |
| 309 | - * | |
| 310 | - * @author KnowledgeTree Team | |
| 311 | - * @access public | |
| 312 | - * @param none | |
| 313 | - * @return string | |
| 314 | - */ | |
| 315 | - public function getLuceneError() { | |
| 316 | - return $this->luceneError; | |
| 317 | - } | |
| 318 | - | |
| 319 | - /** | |
| 320 | - * Set Java JVM path | |
| 321 | - * | |
| 322 | - * @author KnowledgeTree Team | |
| 323 | - * @access private | |
| 324 | - * @param string | |
| 325 | - * @return void | |
| 326 | - */ | |
| 327 | - private function setJavaJVM() { | |
| 328 | - if(file_exists($this->getJavaBin().DS."client".DS."jvm.dll")) { | |
| 329 | - $this->javaJVM = $this->getJavaBin().DS."client".DS."jvm.dll"; | |
| 330 | - } elseif (file_exists($this->getJavaBin().DS."server".DS."jvm.dll")) { | |
| 331 | - $this->javaJVM = $this->getJavaBin().DS."server".DS."jvm.dll"; | |
| 332 | - } else { | |
| 333 | - return false; | |
| 334 | - } | |
| 335 | - } | |
| 336 | - | |
| 337 | - /** | |
| 338 | - * Get Java JVM path | |
| 339 | - * | |
| 340 | - * @author KnowledgeTree Team | |
| 341 | - * @access public | |
| 342 | - * @param none | |
| 343 | - * @return string | |
| 344 | - */ | |
| 345 | - public function getJavaJVM() { | |
| 346 | - return $this->javaJVM; | |
| 347 | - } | |
| 348 | - | |
| 349 | - /** | |
| 350 | - * Migrate Lucene Service | |
| 351 | - * | |
| 352 | - * @author KnowledgeTree Team | |
| 353 | - * @access public | |
| 354 | - * @param none | |
| 355 | - * @return array | |
| 356 | - */ | |
| 357 | - function migrate() { | |
| 358 | - $state = $this->status(); | |
| 359 | - if($state == '') { | |
| 360 | - $luceneExe = $this->getLuceneExe(); | |
| 361 | - $luceneSource = $this->getLuceneSource(); | |
| 362 | - $luceneDir = $this->getluceneDir(); | |
| 363 | - if($luceneExe && $luceneSource && $luceneDir) { | |
| 364 | - $cmd = "\"{$luceneExe}\""." -migrate \"".$this->getName()."\" \"".$this->getJavaJVM(). "\" -Djava.class.path=\"".$luceneSource."\"". " -start ".$this->getLuceneServer(). " -out \"".$this->getLuceneOut()."\" -err \"".$this->getLuceneError()."\" -current \"".$luceneDir."\" -auto"; | |
| 365 | - $response = $this->util->pexec($cmd); | |
| 366 | - return $response; | |
| 367 | - } | |
| 368 | - return $state; | |
| 369 | - } | |
| 370 | - | |
| 371 | - return $state; | |
| 372 | - } | |
| 373 | - | |
| 374 | -} | |
| 375 | -?> | |
| 376 | 0 | \ No newline at end of file |
setup/migrate/lib/services/windowsOpenOffice.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | -* Windows Agent Service Controller. | |
| 4 | -* | |
| 5 | -* KnowledgeTree Community Edition | |
| 6 | -* Document Management Made Simple | |
| 7 | -* Copyright(C) 2008,2009 KnowledgeTree Inc. | |
| 8 | -* Portions copyright The Jam Warehouse Software(Pty) Limited | |
| 9 | -* | |
| 10 | -* This program is free software; you can redistribute it and/or modify it under | |
| 11 | -* the terms of the GNU General Public License version 3 as published by the | |
| 12 | -* Free Software Foundation. | |
| 13 | -* | |
| 14 | -* This program is distributed in the hope that it will be useful, but WITHOUT | |
| 15 | -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 16 | -* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 17 | -* details. | |
| 18 | -* | |
| 19 | -* You should have received a copy of the GNU General Public License | |
| 20 | -* along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 21 | -* | |
| 22 | -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 23 | -* California 94120-7775, or email info@knowledgetree.com. | |
| 24 | -* | |
| 25 | -* The interactive user interfaces in modified source and object code versions | |
| 26 | -* of this program must display Appropriate Legal Notices, as required under | |
| 27 | -* Section 5 of the GNU General Public License version 3. | |
| 28 | -* | |
| 29 | -* In accordance with Section 7(b) of the GNU General Public License version 3, | |
| 30 | -* these Appropriate Legal Notices must retain the display of the "Powered by | |
| 31 | -* KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 32 | -* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | |
| 33 | -* must display the words "Powered by KnowledgeTree" and retain the original | |
| 34 | -* copyright notice. | |
| 35 | -* | |
| 36 | -* @copyright 2008-2009, KnowledgeTree Inc. | |
| 37 | -* @license GNU General Public License version 3 | |
| 38 | -* @author KnowledgeTree Team | |
| 39 | -* @package Migrater | |
| 40 | -* @version Version 0.1 | |
| 41 | -*/ | |
| 42 | - | |
| 43 | -class windowsOpenOffice extends windowsService { | |
| 44 | - | |
| 45 | - // utility | |
| 46 | - public $util; | |
| 47 | - // path to office | |
| 48 | - private $path; | |
| 49 | - // host | |
| 50 | - private $host; | |
| 51 | - // pid running | |
| 52 | - private $pidFile; | |
| 53 | - // port to bind to | |
| 54 | - private $port; | |
| 55 | - // bin folder | |
| 56 | - private $bin; | |
| 57 | - // office executable | |
| 58 | - private $soffice; | |
| 59 | - // office log file | |
| 60 | - private $log; | |
| 61 | - private $options; | |
| 62 | - private $winservice; | |
| 63 | - | |
| 64 | - public function __construct() { | |
| 65 | - $this->name = "openoffice"; | |
| 66 | - $this->util = new MigrateUtil(); | |
| 67 | - } | |
| 68 | - | |
| 69 | - public function load() { | |
| 70 | - // hack for testing | |
| 71 | - $this->setPort("8100"); | |
| 72 | - $this->setHost("127.0.0.1"); | |
| 73 | - $this->setLog("openoffice.log"); | |
| 74 | - $this->setBin("C:\Program Files (x86)\OpenOffice.org 3\program\soffice.bin"); | |
| 75 | - $this->setBin("C:\Program Files (x86)\ktdms\openoffice\program\soffice.bin"); | |
| 76 | - $this->setBin("C:\Program Files (x86)\ktdms\openoffice.2.4\program\soffice.bin"); | |
| 77 | - $this->setWinservice("winserv.exe"); | |
| 78 | - $this->setOption(); | |
| 79 | - } | |
| 80 | - | |
| 81 | - private function setPort($port = "8100") { | |
| 82 | - $this->port = $port; | |
| 83 | - } | |
| 84 | - | |
| 85 | - public function getPort() { | |
| 86 | - return $this->port; | |
| 87 | - } | |
| 88 | - | |
| 89 | - private function setHost($host = "127.0.0.1") { | |
| 90 | - $this->host = $host; | |
| 91 | - } | |
| 92 | - | |
| 93 | - public function getHost() { | |
| 94 | - return $this->host; | |
| 95 | - } | |
| 96 | - | |
| 97 | - private function setLog($log = "openoffice.log") { | |
| 98 | - $this->log = $log; | |
| 99 | - } | |
| 100 | - | |
| 101 | - public function getLog() { | |
| 102 | - return $this->log; | |
| 103 | - } | |
| 104 | - | |
| 105 | - private function setBin($bin = "soffice") { | |
| 106 | - $this->bin = $bin; | |
| 107 | - } | |
| 108 | - | |
| 109 | - public function getBin() { | |
| 110 | - return $this->bin; | |
| 111 | - } | |
| 112 | - | |
| 113 | - private function setWinservice($winservice = "winserv.exe") { | |
| 114 | - $this->winservice = SYS_BIN_DIR . $winservice; | |
| 115 | - } | |
| 116 | - | |
| 117 | - public function getWinservice() { | |
| 118 | - return $this->winservice; | |
| 119 | - } | |
| 120 | - | |
| 121 | - private function setOption() { | |
| 122 | - $this->options = "-displayname {$this->name} -start auto \"{$this->bin}\" -headless -invisible " | |
| 123 | - . "-accept=socket,host={$this->host},port={$this->port};urp;"; | |
| 124 | - } | |
| 125 | - | |
| 126 | - public function getOption() { | |
| 127 | - return $this->options; | |
| 128 | - } | |
| 129 | - | |
| 130 | - public function migrate() { | |
| 131 | - $status = $this->status(); | |
| 132 | - | |
| 133 | - if($status == '') { | |
| 134 | - $cmd = "\"{$this->winservice}\" migrate $this->name $this->options"; | |
| 135 | - $response = $this->util->pexec($cmd); | |
| 136 | - return $response; | |
| 137 | - } | |
| 138 | - else { | |
| 139 | - return $status; | |
| 140 | - } | |
| 141 | - } | |
| 142 | - | |
| 143 | -// public function start() { | |
| 144 | -// $state = $this->status(); | |
| 145 | -// if($state != 'STARTED') { | |
| 146 | -// $cmd = 'sc start ' . $this->name; | |
| 147 | -// $response = $this->util->pexec($cmd); | |
| 148 | -// | |
| 149 | -// return $response; | |
| 150 | -// } elseif ($state == '') { | |
| 151 | -// // Start Service | |
| 152 | -// return true; | |
| 153 | -// } else { | |
| 154 | -// // Service Running Already | |
| 155 | -// return true; | |
| 156 | -// } | |
| 157 | -// | |
| 158 | -// return false; | |
| 159 | -// } | |
| 160 | - | |
| 161 | -} | |
| 162 | -?> | |
| 163 | 0 | \ No newline at end of file |
setup/migrate/lib/services/windowsScheduler.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | -* Windows Scheduler Service Controller. | |
| 4 | -* | |
| 5 | -* KnowledgeTree Community Edition | |
| 6 | -* Document Management Made Simple | |
| 7 | -* Copyright (C) 2008,2009 KnowledgeTree Inc. | |
| 8 | -* Portions copyright The Jam Warehouse Software (Pty) Limited | |
| 9 | -* | |
| 10 | -* This program is free software; you can redistribute it and/or modify it under | |
| 11 | -* the terms of the GNU General Public License version 3 as published by the | |
| 12 | -* Free Software Foundation. | |
| 13 | -* | |
| 14 | -* This program is distributed in the hope that it will be useful, but WITHOUT | |
| 15 | -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 16 | -* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 17 | -* details. | |
| 18 | -* | |
| 19 | -* You should have received a copy of the GNU General Public License | |
| 20 | -* along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 21 | -* | |
| 22 | -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 23 | -* California 94120-7775, or email info@knowledgetree.com. | |
| 24 | -* | |
| 25 | -* The interactive user interfaces in modified source and object code versions | |
| 26 | -* of this program must display Appropriate Legal Notices, as required under | |
| 27 | -* Section 5 of the GNU General Public License version 3. | |
| 28 | -* | |
| 29 | -* In accordance with Section 7(b) of the GNU General Public License version 3, | |
| 30 | -* these Appropriate Legal Notices must retain the display of the "Powered by | |
| 31 | -* KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 32 | -* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | |
| 33 | -* must display the words "Powered by KnowledgeTree" and retain the original | |
| 34 | -* copyright notice. | |
| 35 | -* | |
| 36 | -* @copyright 2008-2009, KnowledgeTree Inc. | |
| 37 | -* @license GNU General Public License version 3 | |
| 38 | -* @author KnowledgeTree Team | |
| 39 | -* @package Migrater | |
| 40 | -* @version Version 0.1 | |
| 41 | -*/ | |
| 42 | -class windowsScheduler extends windowsService { | |
| 43 | - /** | |
| 44 | - * Batch Script to execute | |
| 45 | - * | |
| 46 | - * @author KnowledgeTree Team | |
| 47 | - * @access private | |
| 48 | - * @var string | |
| 49 | - */ | |
| 50 | - private $schedulerScriptPath; | |
| 51 | - | |
| 52 | - /** | |
| 53 | - * Php Script to execute | |
| 54 | - * | |
| 55 | - * @author KnowledgeTree Team | |
| 56 | - * @access private | |
| 57 | - * @var string | |
| 58 | - */ | |
| 59 | - private $schedulerSource; | |
| 60 | - | |
| 61 | - /** | |
| 62 | - * Scheduler Directory | |
| 63 | - * | |
| 64 | - * @author KnowledgeTree Team | |
| 65 | - * @access private | |
| 66 | - * @var string | |
| 67 | - */ | |
| 68 | - private $schedulerDir; | |
| 69 | - | |
| 70 | - /** | |
| 71 | - * Load defaults needed by service | |
| 72 | - * | |
| 73 | - * @author KnowledgeTree Team | |
| 74 | - * @access public | |
| 75 | - * @param string | |
| 76 | - * @return void | |
| 77 | - */ | |
| 78 | - function load() { | |
| 79 | - $this->name = "KTSchedulerTest"; | |
| 80 | - $this->setSchedulerDIR(SYSTEM_DIR."bin".DS."win32"); | |
| 81 | -// $this->setSchedulerScriptPath("taskrunner_test.bat"); | |
| 82 | - $this->setSchedulerScriptPath("taskrunner.bat"); | |
| 83 | - $this->setSchedulerSource("schedulerService.php"); | |
| 84 | - } | |
| 85 | - | |
| 86 | - /** | |
| 87 | - * Set Batch Script path | |
| 88 | - * | |
| 89 | - * @author KnowledgeTree Team | |
| 90 | - * @access private | |
| 91 | - * @param string | |
| 92 | - * @return void | |
| 93 | - */ | |
| 94 | - private function setSchedulerScriptPath($schedulerScriptPath) { | |
| 95 | - $this->schedulerScriptPath = "{$this->getSchedulerDir()}".DS."$schedulerScriptPath"; | |
| 96 | - } | |
| 97 | - | |
| 98 | - /** | |
| 99 | - * Retrieve Batch Script path | |
| 100 | - * | |
| 101 | - * @author KnowledgeTree Team | |
| 102 | - * @access public | |
| 103 | - * @param none | |
| 104 | - * @return string | |
| 105 | - */ | |
| 106 | - public function getSchedulerScriptPath() { | |
| 107 | - if(file_exists($this->schedulerScriptPath)) | |
| 108 | - return $this->schedulerScriptPath; | |
| 109 | - return false; | |
| 110 | - } | |
| 111 | - | |
| 112 | - /** | |
| 113 | - * Set Scheduler Directory path | |
| 114 | - * | |
| 115 | - * @author KnowledgeTree Team | |
| 116 | - * @access private | |
| 117 | - * @param none | |
| 118 | - * @return string | |
| 119 | - */ | |
| 120 | - private function setSchedulerDIR($schedulerDIR) { | |
| 121 | - $this->schedulerDir = $schedulerDIR; | |
| 122 | - } | |
| 123 | - | |
| 124 | - /** | |
| 125 | - * Retrieve Scheduler Directory path | |
| 126 | - * | |
| 127 | - * @author KnowledgeTree Team | |
| 128 | - * @access public | |
| 129 | - * @param none | |
| 130 | - * @return string | |
| 131 | - */ | |
| 132 | - public function getSchedulerDir() { | |
| 133 | - if(file_exists($this->schedulerDir)) | |
| 134 | - return $this->schedulerDir; | |
| 135 | - return false; | |
| 136 | - } | |
| 137 | - | |
| 138 | - /** | |
| 139 | - * Set Php Script path | |
| 140 | - * | |
| 141 | - * @author KnowledgeTree Team | |
| 142 | - * @access private | |
| 143 | - * @param none | |
| 144 | - * @return string | |
| 145 | - */ | |
| 146 | - private function setSchedulerSource($schedulerSource) { | |
| 147 | - $this->schedulerSource = $this->getSchedulerDir().DS.$schedulerSource; | |
| 148 | - } | |
| 149 | - | |
| 150 | - /** | |
| 151 | - * Retrieve Php Script path | |
| 152 | - * | |
| 153 | - * @author KnowledgeTree Team | |
| 154 | - * @access public | |
| 155 | - * @param none | |
| 156 | - * @return string | |
| 157 | - */ | |
| 158 | - public function getSchedulerSource() { | |
| 159 | - if(file_exists($this->schedulerSource)) | |
| 160 | - return $this->schedulerSource; | |
| 161 | - return false; | |
| 162 | - } | |
| 163 | - | |
| 164 | - /** | |
| 165 | - * Migrate Scheduler Service | |
| 166 | - * | |
| 167 | - * @author KnowledgeTree Team | |
| 168 | - * @access public | |
| 169 | - * @param none | |
| 170 | - * @return array | |
| 171 | - */ | |
| 172 | - public function migrate() { | |
| 173 | - $state = $this->status(); | |
| 174 | - if($state == '') { | |
| 175 | - if(is_readable(SYS_BIN_DIR) && is_writable(SYS_BIN_DIR)) { | |
| 176 | - if(!file_exists($this->getSchedulerScriptPath())) { | |
| 177 | - $fp = fopen($this->getSchedulerScriptPath(), "w+"); | |
| 178 | - $content = "@echo off\n"; | |
| 179 | - $content .= "\"".PHP_DIR."php.exe\" "."\"{$this->getSchedulerSource()}\""; | |
| 180 | - fwrite($fp, $content); | |
| 181 | - fclose($fp); | |
| 182 | - } | |
| 183 | - } | |
| 184 | - | |
| 185 | - // TODO what if it does not exist? check how the dmsctl.bat does this | |
| 186 | - if (function_exists('win32_create_service')) | |
| 187 | - { | |
| 188 | - $response = win32_create_service(array( | |
| 189 | - 'service' => $this->name, | |
| 190 | - 'display' => $this->name, | |
| 191 | - 'path' => $this->getSchedulerScriptPath() | |
| 192 | - )); | |
| 193 | - return $response; | |
| 194 | - } | |
| 195 | - } | |
| 196 | - return $state; | |
| 197 | - } | |
| 198 | -} | |
| 199 | -?> | |
| 200 | 0 | \ No newline at end of file |
setup/migrate/lib/services/windowsService.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | -* Service Controller. | |
| 4 | -* | |
| 5 | -* KnowledgeTree Community Edition | |
| 6 | -* Document Management Made Simple | |
| 7 | -* Copyright(C) 2008,2009 KnowledgeTree Inc. | |
| 8 | -* Portions copyright The Jam Warehouse Software(Pty) Limited | |
| 9 | -* | |
| 10 | -* This program is free software; you can redistribute it and/or modify it under | |
| 11 | -* the terms of the GNU General Public License version 3 as published by the | |
| 12 | -* Free Software Foundation. | |
| 13 | -* | |
| 14 | -* This program is distributed in the hope that it will be useful, but WITHOUT | |
| 15 | -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 16 | -* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 17 | -* details. | |
| 18 | -* | |
| 19 | -* You should have received a copy of the GNU General Public License | |
| 20 | -* along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 21 | -* | |
| 22 | -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 23 | -* California 94120-7775, or email info@knowledgetree.com. | |
| 24 | -* | |
| 25 | -* The interactive user interfaces in modified source and object code versions | |
| 26 | -* of this program must display Appropriate Legal Notices, as required under | |
| 27 | -* Section 5 of the GNU General Public License version 3. | |
| 28 | -* | |
| 29 | -* In accordance with Section 7(b) of the GNU General Public License version 3, | |
| 30 | -* these Appropriate Legal Notices must retain the display of the "Powered by | |
| 31 | -* KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 32 | -* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | |
| 33 | -* must display the words "Powered by KnowledgeTree" and retain the original | |
| 34 | -* copyright notice. | |
| 35 | -* | |
| 36 | -* @copyright 2008-2009, KnowledgeTree Inc. | |
| 37 | -* @license GNU General Public License version 3 | |
| 38 | -* @author KnowledgeTree Team | |
| 39 | -* @package Migrater | |
| 40 | -* @version Version 0.1 | |
| 41 | -*/ | |
| 42 | - | |
| 43 | -class windowsService extends Service { | |
| 44 | - public $name; | |
| 45 | - public $util; | |
| 46 | - | |
| 47 | - public function __construct() { | |
| 48 | - $this->util = new MigrateUtil(); | |
| 49 | - } | |
| 50 | - | |
| 51 | - /** | |
| 52 | - * Retrieve Service name | |
| 53 | - * | |
| 54 | - * @author KnowledgeTree Team | |
| 55 | - * @access public | |
| 56 | - * @param none | |
| 57 | - * @return string | |
| 58 | - */ | |
| 59 | - public function getName() { | |
| 60 | - return $this->name; | |
| 61 | - } | |
| 62 | - | |
| 63 | - /** | |
| 64 | - * Start Service | |
| 65 | - * | |
| 66 | - * @author KnowledgeTree Team | |
| 67 | - * @access public | |
| 68 | - * @param none | |
| 69 | - * @return array | |
| 70 | - */ | |
| 71 | - public function start() { | |
| 72 | - $status = $this->status(); | |
| 73 | - if ($status != 'RUNNING') { | |
| 74 | - $cmd = "sc start {$this->name}"; | |
| 75 | - $response = $this->util->pexec($cmd); | |
| 76 | - return $response; | |
| 77 | - } | |
| 78 | - return $status; | |
| 79 | - } | |
| 80 | - | |
| 81 | - /** | |
| 82 | - * Stop Service | |
| 83 | - * | |
| 84 | - * @author KnowledgeTree Team | |
| 85 | - * @access public | |
| 86 | - * @param none | |
| 87 | - * @return array | |
| 88 | - */ | |
| 89 | - public function stop() { | |
| 90 | - $status = $this->status(); | |
| 91 | - if ($status != 'STOPPED') { | |
| 92 | - $cmd = "sc stop {$this->name}"; | |
| 93 | - $response = $this->util->pexec($cmd); | |
| 94 | - return $response; | |
| 95 | - } | |
| 96 | - return $status; | |
| 97 | - } | |
| 98 | - | |
| 99 | - public function migrate() {} | |
| 100 | - | |
| 101 | - /** | |
| 102 | - * Restart Service | |
| 103 | - * | |
| 104 | - * @author KnowledgeTree Team | |
| 105 | - * @access public | |
| 106 | - * @param none | |
| 107 | - * @return array | |
| 108 | - */ | |
| 109 | - public function restart() { | |
| 110 | - $response = $this->stop(); | |
| 111 | - sleep(10); | |
| 112 | - $this->start(); | |
| 113 | - } | |
| 114 | - | |
| 115 | - /** | |
| 116 | - * Unmigrate Service | |
| 117 | - * | |
| 118 | - * @author KnowledgeTree Team | |
| 119 | - * @access public | |
| 120 | - * @param none | |
| 121 | - * @return array | |
| 122 | - */ | |
| 123 | - public function unmigrate() { | |
| 124 | - $status = $this->status(); | |
| 125 | - if ($status != '') { | |
| 126 | - $cmd = "sc delete {$this->name}"; | |
| 127 | - $response = $this->util->pexec($cmd); | |
| 128 | - sleep(10); | |
| 129 | - return $response; | |
| 130 | - } | |
| 131 | - return $status; | |
| 132 | - } | |
| 133 | - | |
| 134 | - /** | |
| 135 | - * Retrieve Status Service | |
| 136 | - * | |
| 137 | - * @author KnowledgeTree Team | |
| 138 | - * @access public | |
| 139 | - * @param none | |
| 140 | - * @return string | |
| 141 | - */ | |
| 142 | - public function status() { | |
| 143 | - $cmd = "sc query {$this->name}"; | |
| 144 | - $response = $this->util->pexec($cmd); | |
| 145 | - if($response['out']) { | |
| 146 | - $state = preg_replace('/^STATE *\: *\d */', '', trim($response['out'][3])); // Status store in third key | |
| 147 | - return $state; | |
| 148 | - } | |
| 149 | - | |
| 150 | - return ''; | |
| 151 | - } | |
| 152 | - | |
| 153 | - /** | |
| 154 | - * Pause Service | |
| 155 | - * | |
| 156 | - * @author KnowledgeTree Team | |
| 157 | - * @access public | |
| 158 | - * @param none | |
| 159 | - * @return array | |
| 160 | - */ | |
| 161 | - public function pause() { | |
| 162 | - $cmd = "sc pause {$this->name}"; | |
| 163 | - $response = $this->util->pexec($cmd); | |
| 164 | - return $response; | |
| 165 | - } | |
| 166 | - | |
| 167 | - /** | |
| 168 | - * Continue Service | |
| 169 | - * | |
| 170 | - * @author KnowledgeTree Team | |
| 171 | - * @access public | |
| 172 | - * @param none | |
| 173 | - * @return array | |
| 174 | - */ | |
| 175 | - public function cont() { | |
| 176 | - $cmd = "sc continue {$this->name}"; | |
| 177 | - $response = $this->util->pexec($cmd); | |
| 178 | - return $response; | |
| 179 | - } | |
| 180 | -} | |
| 181 | -?> | |
| 182 | 0 | \ No newline at end of file |
setup/migrate/migrateUtil.php
| ... | ... | @@ -39,7 +39,9 @@ |
| 39 | 39 | * @package Migrater |
| 40 | 40 | * @version Version 0.1 |
| 41 | 41 | */ |
| 42 | + | |
| 42 | 43 | class MigrateUtil { |
| 44 | + private $bootstrap = null; | |
| 43 | 45 | /** |
| 44 | 46 | * Constructs migrateation object |
| 45 | 47 | * |
| ... | ... | @@ -47,6 +49,8 @@ class MigrateUtil { |
| 47 | 49 | * @access public |
| 48 | 50 | */ |
| 49 | 51 | public function __construct() { |
| 52 | + require_once("../wizard/installUtil.php"); | |
| 53 | + $this->bootstrap = new InstallUtil(); | |
| 50 | 54 | } |
| 51 | 55 | |
| 52 | 56 | /** |
| ... | ... | @@ -90,148 +94,13 @@ class MigrateUtil { |
| 90 | 94 | */ |
| 91 | 95 | public function checkStructurePermissions() { |
| 92 | 96 | // Check if Wizard Directory is writable |
| 93 | - if(!$this->_checkPermission(MIGRATE_DIR)) { | |
| 94 | - return 'wizard'; | |
| 97 | + if(!$this->_checkPermission(WIZARD_DIR)) { | |
| 98 | + return 'migrate'; | |
| 95 | 99 | } |
| 96 | 100 | |
| 97 | 101 | return true; |
| 98 | 102 | } |
| 99 | 103 | |
| 100 | - | |
| 101 | - function getInstallServices() { | |
| 102 | - require_once("../wizard/installUtil.php"); | |
| 103 | - require_once("../wizard/steps/services.php"); | |
| 104 | - | |
| 105 | - return new services(); | |
| 106 | - } | |
| 107 | - /** | |
| 108 | - * Redirect | |
| 109 | - * | |
| 110 | - * This function redirects the client. This is done by issuing | |
| 111 | - * a "Location" header and exiting if wanted. If you set $rfc2616 to true | |
| 112 | - * HTTP will output a hypertext note with the location of the redirect. | |
| 113 | - * | |
| 114 | - * @static | |
| 115 | - * @access public | |
| 116 | - * have already been sent. | |
| 117 | - * @param string $url URL where the redirect should go to. | |
| 118 | - * @param bool $exit Whether to exit immediately after redirection. | |
| 119 | - * @param bool $rfc2616 Wheter to output a hypertext note where we're | |
| 120 | - * redirecting to (Redirecting to <a href="...">...</a>.) | |
| 121 | - * @return mixed Returns true on succes (or exits) or false if headers | |
| 122 | - */ | |
| 123 | - public function redirect($url, $exit = true, $rfc2616 = false) | |
| 124 | - { | |
| 125 | - if (headers_sent()) { | |
| 126 | - return false; | |
| 127 | - } | |
| 128 | - | |
| 129 | - $url = $this->absoluteURI($url); | |
| 130 | - header('Location: '. $url); | |
| 131 | - | |
| 132 | - if ( $rfc2616 && isset($_SERVER['REQUEST_METHOD']) && | |
| 133 | - $_SERVER['REQUEST_METHOD'] != 'HEAD') { | |
| 134 | - printf('Redirecting to: <a href="%s">%s</a>.', $url, $url); | |
| 135 | - } | |
| 136 | - if ($exit) { | |
| 137 | - exit; | |
| 138 | - } | |
| 139 | - return true; | |
| 140 | - } | |
| 141 | - | |
| 142 | - /** | |
| 143 | - * Absolute URI | |
| 144 | - * | |
| 145 | - * This function returns the absolute URI for the partial URL passed. | |
| 146 | - * The current scheme (HTTP/HTTPS), host server, port, current script | |
| 147 | - * location are used if necessary to resolve any relative URLs. | |
| 148 | - * | |
| 149 | - * Offsets potentially created by PATH_INFO are taken care of to resolve | |
| 150 | - * relative URLs to the current script. | |
| 151 | - * | |
| 152 | - * You can choose a new protocol while resolving the URI. This is | |
| 153 | - * particularly useful when redirecting a web browser using relative URIs | |
| 154 | - * and to switch from HTTP to HTTPS, or vice-versa, at the same time. | |
| 155 | - * | |
| 156 | - * @author Philippe Jausions <Philippe.Jausions@11abacus.com> | |
| 157 | - * @static | |
| 158 | - * @access public | |
| 159 | - * @param string $url Absolute or relative URI the redirect should go to. | |
| 160 | - * @param string $protocol Protocol to use when redirecting URIs. | |
| 161 | - * @param integer $port A new port number. | |
| 162 | - * @return string The absolute URI. | |
| 163 | - */ | |
| 164 | - public function absoluteURI($url = null, $protocol = null, $port = null) | |
| 165 | - { | |
| 166 | - // filter CR/LF | |
| 167 | - $url = str_replace(array("\r", "\n"), ' ', $url); | |
| 168 | - | |
| 169 | - // Mess around with already absolute URIs | |
| 170 | - if (preg_match('!^([a-z0-9]+)://!i', $url)) { | |
| 171 | - if (empty($protocol) && empty($port)) { | |
| 172 | - return $url; | |
| 173 | - } | |
| 174 | - if (!empty($protocol)) { | |
| 175 | - $url = $protocol .':'. end($array = explode(':', $url, 2)); | |
| 176 | - } | |
| 177 | - if (!empty($port)) { | |
| 178 | - $url = preg_replace('!^(([a-z0-9]+)://[^/:]+)(:[\d]+)?!i', | |
| 179 | - '\1:'. $port, $url); | |
| 180 | - } | |
| 181 | - return $url; | |
| 182 | - } | |
| 183 | - | |
| 184 | - $host = 'localhost'; | |
| 185 | - if (!empty($_SERVER['HTTP_HOST'])) { | |
| 186 | - list($host) = explode(':', $_SERVER['HTTP_HOST']); | |
| 187 | - } elseif (!empty($_SERVER['SERVER_NAME'])) { | |
| 188 | - list($host) = explode(':', $_SERVER['SERVER_NAME']); | |
| 189 | - } | |
| 190 | - | |
| 191 | - if (empty($protocol)) { | |
| 192 | - if (isset($_SERVER['HTTPS']) && !strcasecmp($_SERVER['HTTPS'], 'on')) { | |
| 193 | - $protocol = 'https'; | |
| 194 | - } else { | |
| 195 | - $protocol = 'http'; | |
| 196 | - } | |
| 197 | - if (!isset($port) || $port != intval($port)) { | |
| 198 | - $port = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : 80; | |
| 199 | - } | |
| 200 | - } | |
| 201 | - | |
| 202 | - if ($protocol == 'http' && $port == 80) { | |
| 203 | - unset($port); | |
| 204 | - } | |
| 205 | - if ($protocol == 'https' && $port == 443) { | |
| 206 | - unset($port); | |
| 207 | - } | |
| 208 | - | |
| 209 | - $server = $protocol .'://'. $host . (isset($port) ? ':'. $port : ''); | |
| 210 | - | |
| 211 | - if (!strlen($url)) { | |
| 212 | - $url = isset($_SERVER['REQUEST_URI']) ? | |
| 213 | - $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF']; | |
| 214 | - } | |
| 215 | - | |
| 216 | - if ($url{0} == '/') { | |
| 217 | - return $server . $url; | |
| 218 | - } | |
| 219 | - | |
| 220 | - // Check for PATH_INFO | |
| 221 | - if (isset($_SERVER['PATH_INFO']) && strlen($_SERVER['PATH_INFO']) && | |
| 222 | - $_SERVER['PHP_SELF'] != $_SERVER['PATH_INFO']) { | |
| 223 | - $path = dirname(substr($_SERVER['PHP_SELF'], 0, -strlen($_SERVER['PATH_INFO']))); | |
| 224 | - } else { | |
| 225 | - $path = dirname($_SERVER['PHP_SELF']); | |
| 226 | - } | |
| 227 | - | |
| 228 | - if (substr($path = strtr($path, '\\', '/'), -1) != '/') { | |
| 229 | - $path .= '/'; | |
| 230 | - } | |
| 231 | - | |
| 232 | - return $server . $path . $url; | |
| 233 | - } | |
| 234 | - | |
| 235 | 104 | /** |
| 236 | 105 | * Check whether a given directory / file path exists and is writable |
| 237 | 106 | * |
| ... | ... | @@ -251,306 +120,39 @@ class MigrateUtil { |
| 251 | 120 | |
| 252 | 121 | } |
| 253 | 122 | |
| 254 | - /** | |
| 255 | - * Check whether a given directory / file path exists and is writable | |
| 256 | - * | |
| 257 | - * @author KnowledgeTree Team | |
| 258 | - * @access private | |
| 259 | - * @param string $dir The directory / file to check | |
| 260 | - * @param boolean $create Whether to create the directory if it doesn't exist | |
| 261 | - * @return array The message and css class to use | |
| 262 | - */ | |
| 263 | - public function checkPermission($dir, $create=false) | |
| 264 | - { | |
| 265 | - $exist = 'Directory doesn\'t exist'; | |
| 266 | - $write = 'Directory not writable'; | |
| 267 | - $ret = array('class' => 'cross'); | |
| 268 | - | |
| 269 | - if(!file_exists($dir)){ | |
| 270 | - if($create === false){ | |
| 271 | - $this->done = false; | |
| 272 | - $ret['msg'] = $exist; | |
| 273 | - return $ret; | |
| 274 | - } | |
| 275 | - $par_dir = dirname($dir); | |
| 276 | - if(!file_exists($par_dir)){ | |
| 277 | - $this->done = false; | |
| 278 | - $ret['msg'] = $exist; | |
| 279 | - return $ret; | |
| 280 | - } | |
| 281 | - if(!is_writable($par_dir)){ | |
| 282 | - $this->done = false; | |
| 283 | - $ret['msg'] = $exist; | |
| 284 | - return $ret; | |
| 285 | - } | |
| 286 | - mkdir($dir, '0755'); | |
| 287 | - } | |
| 288 | - | |
| 289 | - if(is_writable($dir)){ | |
| 290 | - $ret['class'] = 'tick'; | |
| 291 | - | |
| 292 | - return $ret; | |
| 293 | - } | |
| 294 | - | |
| 295 | - $this->done = false; | |
| 296 | - $ret['msg'] = $write; | |
| 297 | - return $ret; | |
| 298 | - } | |
| 299 | - | |
| 300 | - /** | |
| 301 | - * Change permissions on a directory helper | |
| 302 | - * | |
| 303 | - * @author KnowledgeTree Team | |
| 304 | - * @access public | |
| 305 | - * @param string $folderPath The directory / file to check | |
| 306 | - * @return boolean | |
| 307 | - */ | |
| 308 | - public function canChangePermissions($folderPath) { | |
| 309 | - return $this->_chmodRecursive($folderPath, 0755); | |
| 310 | - } | |
| 311 | - | |
| 312 | - /** | |
| 313 | - * Change permissions on a directory (recursive) | |
| 314 | - * | |
| 315 | - * @author KnowledgeTree Team | |
| 316 | - * @access private | |
| 317 | - * @param string $folderPath The directory / file to check | |
| 318 | - * @param boolean $create Whether to create the directory if it doesn't exist | |
| 319 | - * @return boolean | |
| 320 | - */ | |
| 321 | - private function _chmodRecursive($path, $filemode) { | |
| 322 | - if (!is_dir($path)) | |
| 323 | - return chmod($path, $filemode); | |
| 324 | - $dh = opendir($path); | |
| 325 | - while (($file = readdir($dh)) !== false) { | |
| 326 | - if($file != '.' && $file != '..') { | |
| 327 | - $fullpath = $path.'/'.$file; | |
| 328 | - if(is_link($fullpath)) | |
| 329 | - return false; | |
| 330 | - elseif(!is_dir($fullpath)) { | |
| 331 | - $perms = substr(sprintf('%o', fileperms($fullpath)), -4); | |
| 332 | - if($perms != $filemode) | |
| 333 | - if (!chmod($fullpath, $filemode)) | |
| 334 | - return false; | |
| 335 | - } elseif(!$this->chmodRecursive($fullpath, $filemode)) | |
| 336 | - return false; | |
| 337 | - } | |
| 338 | - } | |
| 339 | - closedir($dh); | |
| 340 | - $perms = substr(sprintf('%o', fileperms($path)), -4); | |
| 341 | - if($perms != $filemode) { | |
| 342 | - if(chmod($path, $filemode)) | |
| 343 | - return true; | |
| 344 | - else | |
| 345 | - return false; | |
| 346 | - } else { | |
| 347 | - return true; | |
| 348 | - } | |
| 349 | - } | |
| 350 | - | |
| 351 | - /** | |
| 352 | - * Check if a file can be written to a folder | |
| 353 | - * | |
| 354 | - * @author KnowledgeTree Team | |
| 355 | - * @access public | |
| 356 | - * @param string $filename the path to the file to create | |
| 357 | - * @return boolean | |
| 358 | - */ | |
| 359 | - public function canWriteFile($filename) { | |
| 360 | - $fh = fopen($filename, "w+"); | |
| 361 | - if($fr = fwrite($fh, 'test') === false) { | |
| 362 | - return false; | |
| 363 | - } | |
| 364 | - | |
| 365 | - fclose($fh); | |
| 366 | - return true; | |
| 367 | - } | |
| 368 | - | |
| 369 | - /** | |
| 370 | - * Attempt using the php-java bridge | |
| 371 | - * | |
| 372 | - * @author KnowledgeTree Team | |
| 373 | - * @access public | |
| 374 | - * @param none | |
| 375 | - * @return boolean | |
| 376 | - */ | |
| 377 | - public function javaBridge() { | |
| 378 | - try { | |
| 379 | - $javaSystem = new Java('java.lang.System'); | |
| 380 | - } catch (JavaException $e) { | |
| 381 | - return false; | |
| 382 | - } | |
| 383 | - return true; | |
| 384 | - } | |
| 385 | - | |
| 386 | - /** | |
| 387 | - * Attempt java detection | |
| 388 | - * | |
| 389 | - * @author KnowledgeTree Team | |
| 390 | - * @access public | |
| 391 | - * @param none | |
| 392 | - * @return boolean | |
| 393 | - */ | |
| 394 | - public function tryJava1() { | |
| 395 | - $response = $this->pexec("java -version"); // Java Runtime Check | |
| 396 | - if(empty($response['out'])) { | |
| 397 | - return false; | |
| 398 | - } | |
| 399 | - | |
| 400 | - return 'java'; | |
| 401 | - } | |
| 402 | - | |
| 403 | - /** | |
| 404 | - * Attempt java detection | |
| 405 | - * | |
| 406 | - * @author KnowledgeTree Team | |
| 407 | - * @access public | |
| 408 | - * @param none | |
| 409 | - * @return boolean | |
| 410 | - */ | |
| 411 | - public function tryJava2() { | |
| 412 | - $response = $this->pexec("java"); // Java Runtime Check | |
| 413 | - if(empty($response['out'])) { | |
| 414 | - return false; | |
| 415 | - } | |
| 416 | - | |
| 417 | - return 'java'; | |
| 418 | - } | |
| 419 | - | |
| 420 | - /** | |
| 421 | - * Attempt java detection | |
| 422 | - * | |
| 423 | - * @author KnowledgeTree Team | |
| 424 | - * @access public | |
| 425 | - * @param none | |
| 426 | - * @return boolean | |
| 427 | - */ | |
| 428 | - public function tryJava3() { | |
| 429 | - $response = $this->pexec("whereis java"); // Java Runtime Check | |
| 430 | - if(empty($response['out'])) { | |
| 431 | - return false; | |
| 432 | - } | |
| 433 | - $broke = explode(' ', $response['out'][0]); | |
| 434 | - foreach ($broke as $r) { | |
| 435 | - $match = preg_match('/bin/', $r); | |
| 436 | - if($match) { | |
| 437 | - return preg_replace('/java:/', '', $r); | |
| 438 | - } | |
| 439 | - } | |
| 123 | + public function loadInstallDBUtil() { | |
| 124 | + require_once("../wizard/dbUtil.php"); | |
| 125 | + return new dbUtil(); | |
| 440 | 126 | } |
| 441 | 127 | |
| 442 | - /** | |
| 443 | - * Check if user entered location of JRE | |
| 444 | - * | |
| 445 | - * @author KnowledgeTree Team | |
| 446 | - * @param none | |
| 447 | - * @access private | |
| 448 | - * @return mixed | |
| 449 | - */ | |
| 450 | - public function javaSpecified() { | |
| 451 | - if(isset($_POST['java'])) { | |
| 452 | - if($_POST['java'] != '') { | |
| 453 | - return $_POST['java']; | |
| 454 | - } else { | |
| 455 | - return false; | |
| 456 | - } | |
| 457 | - } else { | |
| 458 | - return false; | |
| 459 | - } | |
| 128 | + public function loadInstallUtil() { | |
| 129 | + require_once("../wizard/steps/services.php"); | |
| 130 | + return new services(); | |
| 460 | 131 | } |
| 461 | 132 | |
| 462 | - /** | |
| 463 | - * Check if user entered location of PHP | |
| 464 | - * | |
| 465 | - * @author KnowledgeTree Team | |
| 466 | - * @param none | |
| 467 | - * @access private | |
| 468 | - * @return mixed | |
| 469 | - */ | |
| 470 | - public function phpSpecified() { | |
| 471 | - if(isset($_POST['php'])) { | |
| 472 | - if($_POST['php'] != '') { | |
| 473 | - return $_POST['php']; | |
| 474 | - } else { | |
| 475 | - return false; | |
| 476 | - } | |
| 477 | - } else { | |
| 478 | - return false; | |
| 479 | - } | |
| 133 | + public function loadInstallServices() { | |
| 134 | + $s = $this->loadInstallUtil(); | |
| 135 | + return $s->getServices(); | |
| 480 | 136 | } |
| 481 | 137 | |
| 482 | - /** | |
| 483 | - * Determine the location of JAVA_HOME | |
| 484 | - * | |
| 485 | - * @author KnowledgeTree Team | |
| 486 | - * @param none | |
| 487 | - * @access private | |
| 488 | - * @return mixed | |
| 489 | - */ | |
| 490 | - function getJava() { | |
| 491 | - $response = $this->tryJava1(); | |
| 492 | - if(!is_array($response)) { | |
| 493 | - $response = $this->tryJava2(); | |
| 494 | - if(!is_array($response)) { | |
| 495 | - $response = $this->tryJava3(); | |
| 496 | - } | |
| 497 | - } | |
| 498 | -// return false; | |
| 499 | - return $response; | |
| 138 | + public function loadInstallService($serviceName) { | |
| 139 | + require_once("../wizard/lib/services/service.php"); | |
| 140 | + require_once("../wizard/lib/services/".OS."Service.php"); | |
| 141 | + require_once("../wizard/lib/services/$serviceName.php"); | |
| 142 | + return new $serviceName(); | |
| 500 | 143 | } |
| 501 | 144 | |
| 502 | - /** | |
| 503 | - * Determine the location of PHP | |
| 504 | - * | |
| 505 | - * @author KnowledgeTree Team | |
| 506 | - * @param none | |
| 507 | - * @access private | |
| 508 | - * @return mixed | |
| 509 | - */ | |
| 510 | - function getPhp() { | |
| 511 | - $cmd = "whereis php"; | |
| 512 | - $res = $this->getPhpHelper($cmd); | |
| 513 | - if($res != '') { | |
| 514 | - return $res; | |
| 515 | - } | |
| 516 | - $cmd = "which php"; | |
| 517 | - return $this->getPhpHelper($cmd); | |
| 145 | + public function redirect($url, $exit = true, $rfc2616 = false) | |
| 146 | + { | |
| 147 | + return $this->bootstrap->redirect($url, $exit = true, $rfc2616 = false); | |
| 518 | 148 | } |
| 519 | - | |
| 520 | - function getPhpHelper($cmd) { | |
| 521 | - $response = $this->pexec($cmd); | |
| 522 | - if(is_array($response['out'])) { | |
| 523 | - if (isset($response['out'][0])) { | |
| 524 | - $broke = explode(' ', $response['out'][0]); | |
| 525 | - foreach ($broke as $r) { | |
| 526 | - $match = preg_match('/bin/', $r); | |
| 527 | - if($match) { | |
| 528 | - return preg_replace('/php:/', '', $r); | |
| 529 | - } | |
| 530 | - } | |
| 531 | - } | |
| 532 | - } | |
| 533 | - | |
| 534 | - return ''; | |
| 149 | + | |
| 150 | + public function absoluteURI($url = null, $protocol = null, $port = null) | |
| 151 | + { | |
| 152 | + return $this->bootstrap->absoluteURI($url = null, $protocol = null, $port = null); | |
| 535 | 153 | } |
| 536 | 154 | |
| 537 | - function getOpenOffice() { | |
| 538 | - $cmd = "whereis soffice"; | |
| 539 | - $response = $this->pexec($cmd); | |
| 540 | - if(is_array($response['out'])) { | |
| 541 | - if (isset($response['out'][0])) { | |
| 542 | - $broke = explode(' ', $response['out'][0]); | |
| 543 | - foreach ($broke as $r) { | |
| 544 | - $match = preg_match('/bin/', $r); | |
| 545 | - if($match) { | |
| 546 | - return preg_replace('/soffice:/', '', $r); | |
| 547 | - } | |
| 548 | - } | |
| 549 | - } | |
| 550 | - } | |
| 551 | - | |
| 552 | - return ''; | |
| 553 | - } | |
| 155 | + | |
| 554 | 156 | /** |
| 555 | 157 | * Portably execute a command on any of the supported platforms. |
| 556 | 158 | * |
| ... | ... | @@ -561,88 +163,7 @@ class MigrateUtil { |
| 561 | 163 | * @return array |
| 562 | 164 | */ |
| 563 | 165 | public function pexec($aCmd, $aOptions = null) { |
| 564 | - if (is_array($aCmd)) { | |
| 565 | - $sCmd = $this->safeShellString($aCmd); | |
| 566 | - } else { | |
| 567 | - $sCmd = $aCmd; | |
| 568 | - } | |
| 569 | - $sAppend = $this->arrayGet($aOptions, 'append'); | |
| 570 | - if ($sAppend) { | |
| 571 | - $sCmd .= " >> " . escapeshellarg($sAppend); | |
| 572 | - } | |
| 573 | - $sPopen = $this->arrayGet($aOptions, 'popen'); | |
| 574 | - if ($sPopen) { | |
| 575 | - if (WINDOWS_OS) { | |
| 576 | - $sCmd = "start /b \"kt\" " . $sCmd; | |
| 577 | - } | |
| 578 | - return popen($sCmd, $sPopen); | |
| 579 | - } | |
| 580 | - // for exec, check return code and output... | |
| 581 | - $aRet = array(); | |
| 582 | - $aOutput = array(); | |
| 583 | - $iRet = ''; | |
| 584 | - if(WINDOWS_OS) { | |
| 585 | - $sCmd = 'call '.$sCmd; | |
| 586 | - } | |
| 587 | - | |
| 588 | - exec($sCmd, $aOutput, $iRet); | |
| 589 | - $aRet['ret'] = $iRet; | |
| 590 | - $aRet['out'] = $aOutput; | |
| 591 | - | |
| 592 | - return $aRet; | |
| 593 | - } | |
| 594 | - | |
| 595 | - /** | |
| 596 | - * | |
| 597 | - * | |
| 598 | - * @author KnowledgeTree Team | |
| 599 | - * @access public | |
| 600 | - * @return string | |
| 601 | - */ | |
| 602 | - public function arrayGet($aArray, $sKey, $mDefault = null, $bDefaultIfEmpty = true) { | |
| 603 | - if (!is_array($aArray)) { | |
| 604 | - $aArray = (array) $aArray; | |
| 605 | - } | |
| 606 | - | |
| 607 | - if ($aArray !== 0 && $aArray !== '0' && empty($aArray)) { | |
| 608 | - return $mDefault; | |
| 609 | - } | |
| 610 | - if (array_key_exists($sKey, $aArray)) { | |
| 611 | - $mVal =& $aArray[$sKey]; | |
| 612 | - if (empty($mVal) && $bDefaultIfEmpty) { | |
| 613 | - return $mDefault; | |
| 614 | - } | |
| 615 | - return $mVal; | |
| 616 | - } | |
| 617 | - return $mDefault; | |
| 166 | + return $this->bootstrap->pexec($aCmd, $aOptions = null); | |
| 618 | 167 | } |
| 619 | - | |
| 620 | - /** | |
| 621 | - * | |
| 622 | - * | |
| 623 | - * @author KnowledgeTree Team | |
| 624 | - * @access public | |
| 625 | - * @return string | |
| 626 | - */ | |
| 627 | - public function safeShellString () { | |
| 628 | - $aArgs = func_get_args(); | |
| 629 | - $aSafeArgs = array(); | |
| 630 | - if (is_array($aArgs[0])) { | |
| 631 | - $aArgs = $aArgs[0]; | |
| 632 | - } | |
| 633 | - $aSafeArgs[] = escapeshellarg(array_shift($aArgs)); | |
| 634 | - if (is_array($aArgs[0])) { | |
| 635 | - $aArgs = $aArgs; | |
| 636 | - } | |
| 637 | - foreach ($aArgs as $sArg) { | |
| 638 | - if (empty($sArg)) { | |
| 639 | - $aSafeArgs[] = "''"; | |
| 640 | - } else { | |
| 641 | - $aSafeArgs[] = escapeshellarg($sArg); | |
| 642 | - } | |
| 643 | - } | |
| 644 | - return join(" ", $aSafeArgs); | |
| 645 | - } | |
| 646 | - | |
| 647 | 168 | } |
| 648 | 169 | ?> |
| 649 | 170 | \ No newline at end of file | ... | ... |
setup/migrate/migrateWizard.php
| ... | ... | @@ -39,7 +39,7 @@ |
| 39 | 39 | * @package Migrater |
| 40 | 40 | * @version Version 0.1 |
| 41 | 41 | */ |
| 42 | -include("path.php"); // Paths | |
| 42 | +include("../wizard/path.php"); // Paths | |
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | 45 | * Auto loader to bind migrater package |
| ... | ... | @@ -49,8 +49,8 @@ include("path.php"); // Paths |
| 49 | 49 | */ |
| 50 | 50 | function __autoload($class) { // Attempt and autoload classes |
| 51 | 51 | $class = strtolower(substr($class,0,1)).substr($class,1); // Linux Systems. |
| 52 | - if(file_exists(MIGRATE_DIR."$class.php")) { | |
| 53 | - require_once(MIGRATE_DIR."$class.php"); | |
| 52 | + if(file_exists(WIZARD_DIR."$class.php")) { | |
| 53 | + require_once(WIZARD_DIR."$class.php"); | |
| 54 | 54 | } elseif (file_exists(STEP_DIR."$class.php")) { |
| 55 | 55 | require_once(STEP_DIR."$class.php"); |
| 56 | 56 | } elseif (file_exists(WIZARD_LIB."$class.php")) { | ... | ... |
setup/migrate/migrater.php
| ... | ... | @@ -507,6 +507,9 @@ class Migrater { |
| 507 | 507 | } elseif (isset($_POST['Install'])) { |
| 508 | 508 | $this->migraterAction = 'install'; |
| 509 | 509 | $this->response = 'install'; |
| 510 | + } elseif (isset($_POST['BInstall'])) { | |
| 511 | + $this->migraterAction = 'binstall'; | |
| 512 | + $this->response = 'binstall'; | |
| 510 | 513 | } else { |
| 511 | 514 | $this->response = ''; |
| 512 | 515 | $this->migraterAction = ''; |
| ... | ... | @@ -548,6 +551,10 @@ class Migrater { |
| 548 | 551 | $iutil = new MigrateUtil(); |
| 549 | 552 | $iutil->redirect('../wizard/index.php?step_name=installtype'); |
| 550 | 553 | break; |
| 554 | + case 'binstall': | |
| 555 | + $iutil = new MigrateUtil(); | |
| 556 | + $iutil->redirect('../wizard/index.php?step_name=dependencies'); | |
| 557 | + break; | |
| 551 | 558 | default: |
| 552 | 559 | // TODO : handle silent |
| 553 | 560 | $this->_landing(); | ... | ... |
setup/migrate/steps/migrateComplete.php
| ... | ... | @@ -67,7 +67,6 @@ class migrateComplete extends Step { |
| 67 | 67 | |
| 68 | 68 | public function __construct() { |
| 69 | 69 | $this->temp_variables = array("step_name"=>"complete", "silent"=>$this->silent); |
| 70 | - $this->_dbhandler = new dbUtil(); | |
| 71 | 70 | $this->util = new MigrateUtil(); |
| 72 | 71 | } |
| 73 | 72 | |
| ... | ... | @@ -78,16 +77,52 @@ class migrateComplete extends Step { |
| 78 | 77 | |
| 79 | 78 | function doRun() { |
| 80 | 79 | $this->checkServices(); |
| 80 | + $this->checkSqlDump(); | |
| 81 | 81 | $this->storeSilent();// Set silent mode variables |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | + private function checkSqlDump() { | |
| 85 | + $tmpFolder = "/tmp/knowledgtree"; | |
| 86 | + $sqlFile = $tmpFolder."dms.sql"; | |
| 87 | + if(file_exists($sqlFile)) { | |
| 88 | + $this->temp_variables['sql']['class'] = "tick"; | |
| 89 | + $this->temp_variables['sql']['name'] = "dms.sql"; | |
| 90 | + $this->temp_variables['sql']['msg'] = "Data file created"; | |
| 91 | + return true; | |
| 92 | + } else { | |
| 93 | + $this->temp_variables['sql']['class'] = "cross"; | |
| 94 | + $this->temp_variables['sql']['name'] = "dms.sql"; | |
| 95 | + $this->temp_variables['sql']['msg'] = "Data file has not been created"; | |
| 96 | + return false; | |
| 97 | + } | |
| 98 | + } | |
| 99 | + | |
| 84 | 100 | private function checkServices() |
| 85 | 101 | { |
| 86 | - $services = new services(); | |
| 87 | - foreach ($services->getServices() as $serviceName) { | |
| 88 | - $this->temp_variables[$serviceName."Status"] = 'tick'; | |
| 89 | - } | |
| 90 | - return true; | |
| 102 | + $services = $this->util->loadInstallServices(); // Use installer services class | |
| 103 | + foreach ($services as $serviceName) { | |
| 104 | + $className = OS.$serviceName; | |
| 105 | + $serv = $this->util->loadInstallService($className); | |
| 106 | + $serv->load(); | |
| 107 | + $sStatus = $serv->status(true); | |
| 108 | + if($sStatus == 'STARTED') { | |
| 109 | + $state = 'cross'; | |
| 110 | + $this->error[] = "Service : {$serv->getName()} could not be uninstalled.<br/>"; | |
| 111 | + $this->services_check = 'cross'; | |
| 112 | + $stopmsg = OS.'GetStopMsg'; | |
| 113 | + $this->temp_variables['services'][$serv->getName()]['msg'] = $serv->$stopmsg($this->conf['location']); | |
| 114 | + } else { | |
| 115 | + $state = 'tick'; | |
| 116 | + $this->temp_variables['services'][$serv->getName()]['msg'] = "Service has been uninstalled"; | |
| 117 | + } | |
| 118 | + $this->temp_variables['services'][$serv->getName()]['class'] = $state; | |
| 119 | + $this->temp_variables['services'][$serv->getName()]['name'] = $serv->getName(); | |
| 120 | + } | |
| 121 | + if ($this->services_check != 'tick') { | |
| 122 | + return false; | |
| 123 | + } | |
| 124 | + | |
| 125 | + return true; | |
| 91 | 126 | } |
| 92 | 127 | |
| 93 | 128 | /** |
| ... | ... | @@ -95,7 +130,7 @@ class migrateComplete extends Step { |
| 95 | 130 | * |
| 96 | 131 | */ |
| 97 | 132 | private function storeSilent() { |
| 98 | - $this->temp_variables['services_check'] = $this->services_check; | |
| 133 | + $this->temp_variables['servicesCheck'] = $this->services_check; | |
| 99 | 134 | } |
| 100 | 135 | } |
| 101 | 136 | ?> |
| 102 | 137 | \ No newline at end of file | ... | ... |
setup/migrate/steps/migrateDatabase.php
| ... | ... | @@ -60,141 +60,7 @@ class migrateDatabase extends Step |
| 60 | 60 | */ |
| 61 | 61 | public $_util = null; |
| 62 | 62 | |
| 63 | - /** | |
| 64 | - * Database type | |
| 65 | - * | |
| 66 | - * @author KnowledgeTree Team | |
| 67 | - * @access private | |
| 68 | - * @var array | |
| 69 | - */ | |
| 70 | - private $dtype = ''; | |
| 71 | - | |
| 72 | - /** | |
| 73 | - * Database types | |
| 74 | - * | |
| 75 | - * @author KnowledgeTree Team | |
| 76 | - * @access private | |
| 77 | - * @var array | |
| 78 | - */ | |
| 79 | - private $dtypes = array(); | |
| 80 | - | |
| 81 | - /** | |
| 82 | - * Database host | |
| 83 | - * | |
| 84 | - * @author KnowledgeTree Team | |
| 85 | - * @access private | |
| 86 | - * @var string | |
| 87 | - */ | |
| 88 | - private $dhost = ''; | |
| 89 | - | |
| 90 | - /** | |
| 91 | - * Database port | |
| 92 | - * | |
| 93 | - * @author KnowledgeTree Team | |
| 94 | - * @access private | |
| 95 | - * @var string | |
| 96 | - */ | |
| 97 | - private $dport = ''; | |
| 98 | - | |
| 99 | - /** | |
| 100 | - * Database name | |
| 101 | - * | |
| 102 | - * @author KnowledgeTree Team | |
| 103 | - * @access private | |
| 104 | - * @var string | |
| 105 | - */ | |
| 106 | - private $dname = ''; | |
| 107 | - | |
| 108 | - /** | |
| 109 | - * Database root username | |
| 110 | - * | |
| 111 | - * @author KnowledgeTree Team | |
| 112 | - * @access private | |
| 113 | - * @var string | |
| 114 | - */ | |
| 115 | - private $duname = ''; | |
| 116 | - | |
| 117 | - /** | |
| 118 | - * Database root password | |
| 119 | - * | |
| 120 | - * @author KnowledgeTree Team | |
| 121 | - * @access private | |
| 122 | - * @var string | |
| 123 | - */ | |
| 124 | - private $dpassword = ''; | |
| 125 | - | |
| 126 | - /** | |
| 127 | - * Database dms username | |
| 128 | - * | |
| 129 | - * @author KnowledgeTree Team | |
| 130 | - * @access private | |
| 131 | - * @var string | |
| 132 | - */ | |
| 133 | - private $dmsname = ''; | |
| 134 | - | |
| 135 | - /** | |
| 136 | - * Database dms password | |
| 137 | - * | |
| 138 | - * @author KnowledgeTree Team | |
| 139 | - * @access private | |
| 140 | - * @var string | |
| 141 | - */ | |
| 142 | - private $dmspassword = ''; | |
| 143 | - | |
| 144 | - /** | |
| 145 | - * Default dms user username | |
| 146 | - * | |
| 147 | - * @author KnowledgeTree Team | |
| 148 | - * @access private | |
| 149 | - * @var boolean | |
| 150 | - */ | |
| 151 | - private $dmsusername = ''; | |
| 152 | - | |
| 153 | - /** | |
| 154 | - * Default dms user password | |
| 155 | - * | |
| 156 | - * @author KnowledgeTree Team | |
| 157 | - * @access private | |
| 158 | - * @var boolean | |
| 159 | - */ | |
| 160 | - private $dmsuserpassword = ''; | |
| 161 | - | |
| 162 | - /** | |
| 163 | - * Location of database binaries. | |
| 164 | - * | |
| 165 | - * @author KnowledgeTree Team | |
| 166 | - * @access private | |
| 167 | - * @var string | |
| 168 | - */ | |
| 169 | - private $mysqlDir; // TODO:multiple databases | |
| 170 | - | |
| 171 | - /** | |
| 172 | - * Name of database binary. | |
| 173 | - * | |
| 174 | - * @author KnowledgeTree Team | |
| 175 | - * @access private | |
| 176 | - * @var string | |
| 177 | - */ | |
| 178 | - private $dbbinary = ''; // TODO:multiple databases | |
| 179 | - | |
| 180 | - /** | |
| 181 | - * Database table prefix | |
| 182 | - * | |
| 183 | - * @author KnowledgeTree Team | |
| 184 | - * @access private | |
| 185 | - * @var string | |
| 186 | - */ | |
| 187 | - private $tprefix = ''; | |
| 188 | - | |
| 189 | - /** | |
| 190 | - * Flag to drop database | |
| 191 | - * | |
| 192 | - * @author KnowledgeTree Team | |
| 193 | - * @access private | |
| 194 | - * @var boolean | |
| 195 | - */ | |
| 196 | - private $ddrop = false; | |
| 197 | - | |
| 63 | + | |
| 198 | 64 | /** |
| 199 | 65 | * List of errors encountered |
| 200 | 66 | * |
| ... | ... | @@ -205,15 +71,6 @@ class migrateDatabase extends Step |
| 205 | 71 | public $error = array(); |
| 206 | 72 | |
| 207 | 73 | /** |
| 208 | - * List of errors used in template | |
| 209 | - * | |
| 210 | - * @author KnowledgeTree Team | |
| 211 | - * @access public | |
| 212 | - * @var array | |
| 213 | - */ | |
| 214 | - public $templateErrors = array('dmspassword', 'dmsuserpassword', 'con', 'dname', 'dtype', 'duname', 'dpassword'); | |
| 215 | - | |
| 216 | - /** | |
| 217 | 74 | * Flag to store class information in session |
| 218 | 75 | * |
| 219 | 76 | * @author KnowledgeTree Team |
| ... | ... | @@ -239,6 +96,15 @@ class migrateDatabase extends Step |
| 239 | 96 | * @var array |
| 240 | 97 | */ |
| 241 | 98 | protected $silent = true; |
| 99 | + | |
| 100 | + /** | |
| 101 | + * List of errors used in template | |
| 102 | + * | |
| 103 | + * @author KnowledgeTree Team | |
| 104 | + * @access public | |
| 105 | + * @var array | |
| 106 | + */ | |
| 107 | + public $templateErrors = array('dmspassword', 'dmsuserpassword', 'con', 'dname', 'dtype', 'duname', 'dpassword'); | |
| 242 | 108 | |
| 243 | 109 | /** |
| 244 | 110 | * Constructs database object |
| ... | ... | @@ -249,8 +115,7 @@ class migrateDatabase extends Step |
| 249 | 115 | */ |
| 250 | 116 | public function __construct() { |
| 251 | 117 | $this->temp_variables = array("step_name"=>"database", "silent"=>$this->silent); |
| 252 | - $this->_dbhandler = new dbUtil(); | |
| 253 | - $this->_util = new MigrateUtil(); | |
| 118 | + $this->util = new MigrateUtil(); | |
| 254 | 119 | if(WINDOWS_OS) |
| 255 | 120 | $this->mysqlDir = MYSQL_BIN; |
| 256 | 121 | $this->wizardLocation = '../wizard'; |
| ... | ... | @@ -265,13 +130,15 @@ class migrateDatabase extends Step |
| 265 | 130 | * @return string |
| 266 | 131 | */ |
| 267 | 132 | public function doStep() { |
| 268 | - $this->initErrors(); | |
| 133 | + $this->initErrors(); // Load template errors | |
| 269 | 134 | $this->setDetails(); // Set any posted variables |
| 270 | 135 | if(!$this->inStep("database")) { |
| 271 | 136 | return 'landing'; |
| 272 | 137 | } |
| 273 | 138 | if($this->next()) { |
| 274 | - return 'next'; | |
| 139 | + if($this->exportDatabase()) { | |
| 140 | + return 'next'; | |
| 141 | + } | |
| 275 | 142 | } else if($this->previous()) { |
| 276 | 143 | return 'previous'; |
| 277 | 144 | } |
| ... | ... | @@ -279,6 +146,28 @@ class migrateDatabase extends Step |
| 279 | 146 | return 'landing'; |
| 280 | 147 | } |
| 281 | 148 | |
| 149 | + public function exportDatabase() { | |
| 150 | + if(WINDOWS_OS) { | |
| 151 | + | |
| 152 | + } else { | |
| 153 | + $tmpFolder = "/tmp/knowledgtree"; | |
| 154 | + } | |
| 155 | + @mkdir($tmpFolder); | |
| 156 | + $installation = $this->getDataFromSession("installation"); // Get installation directory | |
| 157 | + $dbSettings = $installation['dbSettings']; | |
| 158 | + $uname = $this->temp_variables['duname']; | |
| 159 | + $pwrd = $this->temp_variables['dpassword']; | |
| 160 | + $sqlFile = $tmpFolder."dms.sql"; | |
| 161 | + $dbName = $dbSettings['dbName']; | |
| 162 | + $cmd = "mysqldump -u{$uname} -p{$pwrd} {$dbName} > ".$sqlFile; | |
| 163 | + $response = $this->util->pexec($cmd); | |
| 164 | + if(file_exists($sqlFile)) { | |
| 165 | + return true; | |
| 166 | + } else { | |
| 167 | + return false; | |
| 168 | + } | |
| 169 | + } | |
| 170 | + | |
| 282 | 171 | /** |
| 283 | 172 | * Store options |
| 284 | 173 | * |
| ... | ... | @@ -288,11 +177,8 @@ class migrateDatabase extends Step |
| 288 | 177 | * @return void |
| 289 | 178 | */ |
| 290 | 179 | private function setDetails() { |
| 291 | - $this->temp_variables['dhost'] = $this->getPostSafe('dhost'); | |
| 292 | - $this->temp_variables['dport'] = $this->getPostSafe('dport'); | |
| 293 | 180 | $this->temp_variables['duname'] = $this->getPostSafe('duname'); |
| 294 | 181 | $this->temp_variables['dpassword'] = $this->getPostSafe('dpassword'); |
| 295 | - $this->temp_variables['dbbinary'] = $this->getPostSafe('dbbinary'); | |
| 296 | 182 | // create lock file to indicate migration mode |
| 297 | 183 | $this->createMigrateFile(); |
| 298 | 184 | } |
| ... | ... | @@ -344,7 +230,7 @@ class migrateDatabase extends Step |
| 344 | 230 | |
| 345 | 231 | return $this->error; |
| 346 | 232 | } |
| 347 | - | |
| 233 | + | |
| 348 | 234 | /** |
| 349 | 235 | * Initialize errors to false |
| 350 | 236 | * | ... | ... |
setup/migrate/steps/migrateServices.php
| ... | ... | @@ -137,21 +137,6 @@ class migrateServices extends Step |
| 137 | 137 | $this->util = new MigrateUtil(); |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - public function loadInstallUtil() { | |
| 141 | - require("../wizard/installUtil.php"); | |
| 142 | - require("../wizard/steps/services.php"); | |
| 143 | - $this->installServices = new services(); | |
| 144 | - } | |
| 145 | - | |
| 146 | - public function loadInstallServices() { | |
| 147 | - $this->services = $this->installServices->getServices(); | |
| 148 | - } | |
| 149 | - | |
| 150 | - private function loadInstallService($serviceName) { | |
| 151 | - require_once("../wizard/lib/services/$serviceName.php"); | |
| 152 | - return new $serviceName(); | |
| 153 | - } | |
| 154 | - | |
| 155 | 140 | /** |
| 156 | 141 | * Main control of services setup |
| 157 | 142 | * |
| ... | ... | @@ -162,8 +147,8 @@ class migrateServices extends Step |
| 162 | 147 | */ |
| 163 | 148 | public function doStep() |
| 164 | 149 | { |
| 165 | - $this->loadInstallUtil(); // Use installer utility class | |
| 166 | - $this->loadInstallServices(); // Use installer services class | |
| 150 | + $this->installServices = $this->util->loadInstallUtil(); // Use installer utility class | |
| 151 | + $this->services = $this->util->loadInstallServices(); // Use installer services class | |
| 167 | 152 | $this->storeSilent(); |
| 168 | 153 | if(!$this->inStep("services")) { |
| 169 | 154 | $this->doRun(); |
| ... | ... | @@ -191,11 +176,10 @@ class migrateServices extends Step |
| 191 | 176 | * @return boolean |
| 192 | 177 | */ |
| 193 | 178 | private function doRun() { |
| 194 | - if(!$this->alreadyUninstalled()) { // Pre-check if services are stopped | |
| 195 | - $this->stopServices(); | |
| 196 | - | |
| 179 | + if(!$this->alreadyUninstalled()) { // Pre-check if services are uninstalled | |
| 180 | + $this->uninstallServices(); | |
| 197 | 181 | } |
| 198 | - $this->stopServices(); | |
| 182 | + $this->uninstallServices(); | |
| 199 | 183 | return $this->checkServices(); |
| 200 | 184 | } |
| 201 | 185 | |
| ... | ... | @@ -208,7 +192,7 @@ class migrateServices extends Step |
| 208 | 192 | $alreadyUninstalled = true; |
| 209 | 193 | foreach ($this->services as $serviceName) { |
| 210 | 194 | $className = OS.$serviceName; |
| 211 | - $serv = $this->loadInstallService($className); | |
| 195 | + $serv = $this->util->loadInstallService($className); | |
| 212 | 196 | $serv->load(); |
| 213 | 197 | $sStatus = $serv->status(); |
| 214 | 198 | if($sStatus != '') { |
| ... | ... | @@ -220,23 +204,52 @@ class migrateServices extends Step |
| 220 | 204 | } |
| 221 | 205 | |
| 222 | 206 | /** |
| 223 | - * Attempt to stop services | |
| 207 | + * Attempt to uninstall services | |
| 224 | 208 | * |
| 225 | 209 | */ |
| 226 | - private function stopServices() { | |
| 210 | + private function uninstallServices() { | |
| 227 | 211 | $this->conf = $this->getDataFromSession("installation"); // Get installation directory |
| 228 | 212 | if($this->conf['location'] != '') { |
| 229 | - $cmd = $this->conf['location']."/dmsctl.sh stop"; // Try the dmsctl | |
| 230 | - | |
| 231 | - $res = $this->util->pexec($cmd); | |
| 213 | + $func = OS."Stop";// Try the dmsctl | |
| 214 | + $this->$func(); | |
| 232 | 215 | } |
| 233 | 216 | $this->shutdown(); |
| 234 | 217 | } |
| 235 | 218 | |
| 219 | + /** | |
| 220 | + * Attempt to uninstall unix services | |
| 221 | + * | |
| 222 | + */ | |
| 223 | + public function unixStop() { | |
| 224 | + $cmd = $this->conf['location']."/dmsctl.sh stop lucene"; | |
| 225 | + $res = $this->util->pexec($cmd); | |
| 226 | + $cmd = $this->conf['location']."/dmsctl.sh stop scheduler"; | |
| 227 | + $res = $this->util->pexec($cmd); | |
| 228 | + $cmd = $this->conf['location']."/dmsctl.sh stop soffice"; | |
| 229 | + $res = $this->util->pexec($cmd); | |
| 230 | + } | |
| 231 | + | |
| 232 | + /** | |
| 233 | + * Attempt to uninstall windows services | |
| 234 | + * | |
| 235 | + */ | |
| 236 | + public function windowsStop() { | |
| 237 | + $cmd = "sc delete KTLucene"; | |
| 238 | + $res = $this->util->pexec($cmd); | |
| 239 | + $cmd = "sc delete KTScheduler"; | |
| 240 | + $res = $this->util->pexec($cmd); | |
| 241 | + $cmd = "sc delete KTOpenoffice"; | |
| 242 | + $res = $this->util->pexec($cmd); | |
| 243 | + } | |
| 244 | + | |
| 245 | + /** | |
| 246 | + * Attempt to uninstall services created by webserver | |
| 247 | + * | |
| 248 | + */ | |
| 236 | 249 | public function shutdown() { |
| 237 | 250 | foreach ($this->services as $serviceName) { |
| 238 | 251 | $className = OS.$serviceName; |
| 239 | - $serv = $this->loadInstallService($className); | |
| 252 | + $serv = $this->util->loadInstallService($className); | |
| 240 | 253 | $serv->load(); |
| 241 | 254 | $sStatus = $serv->status(); |
| 242 | 255 | if($sStatus != '') { |
| ... | ... | @@ -245,24 +258,28 @@ class migrateServices extends Step |
| 245 | 258 | } |
| 246 | 259 | } |
| 247 | 260 | |
| 261 | + /** | |
| 262 | + * Check if services are uninstall | |
| 263 | + * | |
| 264 | + */ | |
| 248 | 265 | public function checkServices() { |
| 249 | 266 | foreach ($this->services as $serviceName) { |
| 250 | 267 | $className = OS.$serviceName; |
| 251 | - $serv = $this->loadInstallService($className); | |
| 268 | + $serv = $this->util->loadInstallService($className); | |
| 252 | 269 | $serv->load(); |
| 253 | - $sStatus = $serv->status(); | |
| 270 | + $sStatus = $serv->status(true); | |
| 254 | 271 | if($sStatus == 'STARTED') { |
| 255 | 272 | $state = 'cross'; |
| 256 | - $this->error[] = "Service : {$serv->getName()} could not be stopped.<br/>"; | |
| 273 | + $this->error[] = "Service : {$serv->getName()} could not be uninstalled.<br/>"; | |
| 257 | 274 | $this->serviceCheck = 'cross'; |
| 258 | - | |
| 275 | + $stopmsg = OS.'GetStopMsg'; | |
| 276 | + $this->temp_variables['services'][$serv->getName()]['msg'] = $serv->$stopmsg($this->conf['location']); | |
| 259 | 277 | } else { |
| 260 | 278 | $state = 'tick'; |
| 279 | + $this->temp_variables['services'][$serv->getName()]['msg'] = "Service has been uninstalled"; | |
| 261 | 280 | } |
| 262 | 281 | $this->temp_variables['services'][$serv->getName()]['class'] = $state; |
| 263 | 282 | $this->temp_variables['services'][$serv->getName()]['name'] = $serv->getName(); |
| 264 | - $stopmsg = OS.'GetStopMsg'; | |
| 265 | - $this->temp_variables['services'][$serv->getName()]['msg'] = $serv->$stopmsg($this->conf['location']); | |
| 266 | 283 | } |
| 267 | 284 | if ($this->serviceCheck != 'tick') { |
| 268 | 285 | return false; |
| ... | ... | @@ -270,6 +287,7 @@ class migrateServices extends Step |
| 270 | 287 | |
| 271 | 288 | return true; |
| 272 | 289 | } |
| 290 | + | |
| 273 | 291 | /** |
| 274 | 292 | * Returns services errors |
| 275 | 293 | * | ... | ... |
setup/migrate/templates/complete.tpl
| 1 | -<form> | |
| 1 | +<form action="index.php?step_name=complete" method="post"> | |
| 2 | 2 | <p class="title">Migration Completed</p> |
| 3 | 3 | |
| 4 | 4 | <p class="description">This allows you to check that your KnowledgeTree configuration is set |
| ... | ... | @@ -14,40 +14,33 @@ |
| 14 | 14 | ?> |
| 15 | 15 | <div id="step_content_complete" class="step"> |
| 16 | 16 | <!-- Services --> |
| 17 | - <br/><br/> | |
| 18 | - <div> | |
| 19 | - <h3><?php echo "<span class='{$services_check}'> </span>"; ?>Services</h3> | |
| 20 | - <?php if($silent) { ?> | |
| 21 | - <div id="option2" class="onclick" onclick="javascript:{w.toggleClass('services_check', 'option2');}">Show Details</div> | |
| 22 | - <div class="services_check" style="display:none"> | |
| 23 | - <?php } ?> | |
| 24 | - <table style="width:755px;"> | |
| 25 | - <tr> | |
| 26 | - <td style="width:15px;"> <?php echo "<span class='{$LuceneStatus}'> </span>"; ?> </td> | |
| 27 | - <td style="width:640px;"> Lucene Service <?php if ($LuceneStatus != 'tick') { ?> Could not be stopped <?php } else { ?> Stopped <?php } ?></td> | |
| 28 | - <?php if ($LuceneStatus != 'tick') { ?> | |
| 29 | - <td><a href="javascript:this.location.reload();" class="refresh">Refresh</a></td> | |
| 30 | - <?php } ?> | |
| 31 | - </tr> | |
| 32 | - <tr> | |
| 33 | - <td> <?php echo "<span class='{$SchedulerStatus}'> </span>"; ?> </td> | |
| 34 | - <td> Scheduler Service <?php if ($LuceneStatus != 'tick') { ?> Could not be stopped <?php } else { ?> Stopped <?php } ?></td> | |
| 35 | - <?php if ($SchedulerStatus != 'tick') { ?> | |
| 36 | - <td><a href="javascript:this.location.reload();" class="refresh">Refresh</a></td> | |
| 37 | - <?php } ?> | |
| 38 | - </tr> | |
| 39 | - <tr> | |
| 40 | - <td> <?php echo "<span class='{$OpenOfficeStatus}'> </span>"; ?> </td> | |
| 41 | - <td> OpenOffice Service <?php if ($OpenOfficeStatus != 'tick') { ?> Could not be stopped <?php } else { ?> Stopped <?php } ?></td> | |
| 42 | - <?php if ($OpenOfficeStatus != 'tick') { ?> | |
| 43 | - <td><a href="javascript:this.location.reload();" class="refresh">Refresh</a></td> | |
| 44 | - <?php } ?> | |
| 45 | - </tr> | |
| 46 | - </table> | |
| 47 | - <?php if($silent) { ?> | |
| 48 | - </div> | |
| 49 | - <?php } ?> | |
| 17 | + <table> | |
| 18 | + <tr> | |
| 19 | + <td> <span class='<?php echo $sql['class']; ?>'> </span> </td> | |
| 20 | + <td style="width:20%;"> <?php echo $sql['name']; ?> </td> | |
| 21 | + <td style="width:75%;"> <?php echo $sql['msg']; ?> </td> | |
| 22 | + <tr> | |
| 23 | + <?php | |
| 24 | + if($step_vars) { | |
| 25 | + if(isset($step_vars['services'])) { | |
| 26 | + foreach ($step_vars['services'] as $ser){ | |
| 27 | + ?> | |
| 28 | + <tr> | |
| 29 | + <td> <span class='<?php echo $ser['class']; ?>'> </span> </td> | |
| 30 | + <td style="width:20%;"> <?php echo $ser['name']; ?> </td> | |
| 31 | + <td style="width:75%;"> <?php echo $ser['msg']; ?> </td> | |
| 32 | + <?php if ($ser['class'] != 'tick') { | |
| 33 | + ?> | |
| 34 | + <td><a href="javascript:this.location.reload();" class="refresh">Refresh</a></td> | |
| 35 | + <?php | |
| 36 | + } ?> | |
| 37 | + </tr> | |
| 38 | + <?php | |
| 39 | + } | |
| 40 | + } | |
| 41 | + } | |
| 42 | + ?> | |
| 43 | + </table> | |
| 50 | 44 | </div> |
| 51 | - </div> | |
| 52 | - <a href="../wizard" class="buttons back" style="width:100px;">Goto Installer</a> | |
| 45 | + <input class="button_next" type="submit" value="Back To Installer" name="BInstall"/> | |
| 53 | 46 | </form> |
| 54 | 47 | \ No newline at end of file | ... | ... |
setup/migrate/templates/database.tpl
| ... | ... | @@ -27,4 +27,7 @@ |
| 27 | 27 | </div> |
| 28 | 28 | <input type="button" name="Previous" value="previous" class="button_previous"/> |
| 29 | 29 | <input type="submit" name="Next" value="next" class="button_next"/> |
| 30 | -</form> | |
| 31 | 30 | \ No newline at end of file |
| 31 | +</form> | |
| 32 | +<script type="text/javascript"> | |
| 33 | + $("#duname").focus(); | |
| 34 | +</script> | |
| 32 | 35 | \ No newline at end of file | ... | ... |
setup/migrate/templates/services.tpl
| ... | ... | @@ -44,10 +44,8 @@ |
| 44 | 44 | $details = 'Hide Details'; |
| 45 | 45 | $display = 'block'; |
| 46 | 46 | } else { |
| 47 | - $details = 'Hide Details'; | |
| 48 | - $display = 'block'; | |
| 49 | -// $details = 'Show Details'; | |
| 50 | -// $display = 'none'; | |
| 47 | + $details = 'Show Details'; | |
| 48 | + $display = 'none'; | |
| 51 | 49 | } |
| 52 | 50 | ?> |
| 53 | 51 | <div id="option6" class="onclick" onclick="javascript:{w.toggleClass('service_details', 'option6');}"><?php echo $details; ?></div> |
| ... | ... | @@ -65,7 +63,7 @@ |
| 65 | 63 | <td style="width:75%;"> <?php echo $ser['msg']; ?> </td> |
| 66 | 64 | <?php if ($ser['class'] != 'tick') { |
| 67 | 65 | ?> |
| 68 | -<!-- <td><a href="javascript:this.location.reload();" class="refresh">Refresh</a></td>--> | |
| 66 | + <td><a href="javascript:this.location.reload();" class="refresh">Refresh</a></td> | |
| 69 | 67 | <?php |
| 70 | 68 | } ?> |
| 71 | 69 | </tr> | ... | ... |
setup/wizard/dbUtil.php
| ... | ... | @@ -109,6 +109,9 @@ class dbUtil { |
| 109 | 109 | $this->dbuname = $duname; |
| 110 | 110 | $this->dbpassword = $dpassword; |
| 111 | 111 | $this->dbconnection = @mysql_connect($dhost, $duname, $dpassword); |
| 112 | + if(!$this->dbconnection) { | |
| 113 | + $this->error[] = @mysql_error(); | |
| 114 | + } | |
| 112 | 115 | $this->dbname = $dbname; |
| 113 | 116 | } |
| 114 | 117 | ... | ... |
setup/wizard/index.php
setup/wizard/lib/services/unixOpenOffice.php
| ... | ... | @@ -56,19 +56,16 @@ class unixOpenOffice extends unixService { |
| 56 | 56 | private $bin; |
| 57 | 57 | // office executable |
| 58 | 58 | private $soffice; |
| 59 | - // office log file | |
| 60 | - private $log; | |
| 59 | + | |
| 61 | 60 | private $options; |
| 62 | -// private $office; | |
| 63 | 61 | public $name = "KTOpenOffice"; |
| 64 | 62 | |
| 65 | 63 | public function load() { |
| 66 | 64 | $this->util = new InstallUtil(); |
| 67 | -// $this->office = 'openoffice'; | |
| 68 | 65 | $this->setPort("8100"); |
| 69 | 66 | $this->setHost("localhost"); |
| 70 | - $this->setLog("openoffice.log"); | |
| 71 | - $this->setBin($this->soffice = $this->util->getOpenOffice()); | |
| 67 | + $this->soffice = $this->util->getOpenOffice(); | |
| 68 | + $this->setBin($this->soffice); | |
| 72 | 69 | $this->setOption(); |
| 73 | 70 | } |
| 74 | 71 | |
| ... | ... | @@ -88,14 +85,6 @@ class unixOpenOffice extends unixService { |
| 88 | 85 | return $this->host; |
| 89 | 86 | } |
| 90 | 87 | |
| 91 | - private function setLog($log = "openoffice.log") { | |
| 92 | - $this->log = $log; | |
| 93 | - } | |
| 94 | - | |
| 95 | - public function getLog() { | |
| 96 | - return $this->log; | |
| 97 | - } | |
| 98 | - | |
| 99 | 88 | private function setBin($bin = "soffice") { |
| 100 | 89 | $this->bin = $bin; |
| 101 | 90 | } |
| ... | ... | @@ -121,17 +110,13 @@ class unixOpenOffice extends unixService { |
| 121 | 110 | } |
| 122 | 111 | } |
| 123 | 112 | |
| 124 | -// private function setOfficeName($office) { | |
| 125 | -// $this->office = $office; | |
| 126 | -// } | |
| 127 | - | |
| 128 | -// public function getOfficeName() { | |
| 129 | -// return $this->office; | |
| 130 | -// } | |
| 131 | - | |
| 132 | - public function status() { | |
| 113 | + public function status($updrade = false) { | |
| 133 | 114 | sleep(1); |
| 134 | - $cmd = "netstat -npa | grep ".$this->getPort(); | |
| 115 | + if($updrade) { | |
| 116 | + $cmd = "ps ax | grep soffice"; | |
| 117 | + } else { | |
| 118 | + $cmd = "netstat -npa | grep ".$this->getPort(); | |
| 119 | + } | |
| 135 | 120 | $response = $this->util->pexec($cmd); |
| 136 | 121 | if(is_array($response['out'])) { |
| 137 | 122 | if(count($response['out']) > 0) { |
| ... | ... | @@ -152,7 +137,7 @@ class unixOpenOffice extends unixService { |
| 152 | 137 | public function start() { |
| 153 | 138 | $state = $this->status(); |
| 154 | 139 | if($state != 'STARTED') { |
| 155 | - $cmd = "nohup {$this->getBin()} ".$this->getOption()." > ".$this->outputDir."{$this->getLog()} 2>&1 & echo $!"; | |
| 140 | + $cmd = "nohup {$this->getBin()} ".$this->getOption()." > ".$this->outputDir."openoffice.log 2>&1 & echo $!"; | |
| 156 | 141 | if(DEBUG) { |
| 157 | 142 | echo "Command : $cmd<br/>"; |
| 158 | 143 | return ; |
| ... | ... | @@ -173,9 +158,9 @@ class unixOpenOffice extends unixService { |
| 173 | 158 | } |
| 174 | 159 | |
| 175 | 160 | function stop() { |
| 176 | -// $cmd = "pkill -f ".$this->office; | |
| 177 | -// $response = $this->util->pexec($cmd); | |
| 178 | -// return $response; | |
| 161 | + $cmd = "pkill -f ".$this->soffice; | |
| 162 | + $response = $this->util->pexec($cmd); | |
| 163 | + return $response; | |
| 179 | 164 | } |
| 180 | 165 | |
| 181 | 166 | function uninstall() { | ... | ... |
setup/wizard/migrate.lock
0 → 100644
setup/wizard/path.php
| ... | ... | @@ -56,7 +56,18 @@ |
| 56 | 56 | define('DS', '/'); |
| 57 | 57 | } |
| 58 | 58 | // Define environment root |
| 59 | - $wizard = realpath(dirname(__FILE__)); | |
| 59 | + if($_GET['type'] == 'migrate') { | |
| 60 | + $wizard = realpath(dirname(__FILE__)); | |
| 61 | + $xdir = explode(DS, $wizard); | |
| 62 | + array_pop($xdir); | |
| 63 | + $sys = ''; | |
| 64 | + foreach ($xdir as $k=>$v) { | |
| 65 | + $sys .= $v.DS; | |
| 66 | + } | |
| 67 | + $wizard = $sys.'migrate'; | |
| 68 | + } else { | |
| 69 | + $wizard = realpath(dirname(__FILE__)); | |
| 70 | + } | |
| 60 | 71 | $xdir = explode(DS, $wizard); |
| 61 | 72 | array_pop($xdir); |
| 62 | 73 | array_pop($xdir); |
| ... | ... | @@ -94,7 +105,7 @@ |
| 94 | 105 | define('SYSTEM_ROOT', $asys); |
| 95 | 106 | define('SQL_DIR', SYSTEM_DIR."sql".DS); |
| 96 | 107 | define('SQL_INSTALL_DIR', SQL_DIR."mysql".DS."install".DS); |
| 97 | - define('SQL_MIGRATE_DIR', SYS_VAR_DIR."tmp".DS); | |
| 108 | + define('SQL_MIGRATE_DIR', SQL_DIR."mysql".DS."migrate".DS); | |
| 98 | 109 | // Install Type |
| 99 | 110 | preg_match('/Zend/', $sys, $matches); // TODO: Dirty |
| 100 | 111 | if($matches) { | ... | ... |