Commit 9b72a6cf92d3b35d376ddc66cfd6bbb1b5ed2bd6

Authored by Prince Mbekwa
2 parents fd149616 831fe7ec

Merge branch 'edge' of git@github.com:ktgit/knowledgetree into edge

setup/wizard/ini.php
@@ -205,6 +205,10 @@ class Ini { @@ -205,6 +205,10 @@ class Ini {
205 unset($this->cleanArray[$delSection]); 205 unset($this->cleanArray[$delSection]);
206 return true; 206 return true;
207 } 207 }
208 - 208 +
  209 + public function getFileByLine() {
  210 + $data = $this->read($this->iniFile);
  211 + return $data[''];
  212 + }
209 } 213 }
210 ?> 214 ?>
setup/wizard/lib/helpers/config-path-mock 0 → 100644
  1 +/var/www/installers/knowledgetree/config/config.ini
  2 +/var/www/installers/knowledgetree/var_test/cache
  3 +/var/www/installers/knowledgetree/var_test/Documents
  4 +/var/www/installers/knowledgetree/var_test/indexes
  5 +/var/www/installers/knowledgetree/var_test/log
  6 +/var/www/installers/knowledgetree/var_test/Pdf
  7 +/var/www/installers/knowledgetree/var_test/proxies
  8 +/var/www/installers/knowledgetree/var_test/tmp
  9 +/var/www/installers/knowledgetree/var_test/uploads
0 \ No newline at end of file 10 \ No newline at end of file
setup/wizard/lib/helpers/demo.sh
@@ -5,3 +5,7 @@ rm ../../../../var/log/scheduler.log; @@ -5,3 +5,7 @@ rm ../../../../var/log/scheduler.log;
5 rm ../../../../var/log/openoffice.log; 5 rm ../../../../var/log/openoffice.log;
6 rm ../../../../bin/luceneserver/KnowledgeTreeIndexer.properties; 6 rm ../../../../bin/luceneserver/KnowledgeTreeIndexer.properties;
7 rm ../../../../setup/wizard/output/outJV; 7 rm ../../../../setup/wizard/output/outJV;
  8 +pkill -f lucene;
  9 +pkill -f scheduler;
  10 +pkill -f openoffice;
  11 +
setup/wizard/lib/services/unixLucene.php
@@ -181,9 +181,13 @@ class unixLucene extends unixService { @@ -181,9 +181,13 @@ class unixLucene extends unixService {
181 public function start() { 181 public function start() {
182 $state = $this->status(); 182 $state = $this->status();
183 if($state != 'STARTED') { 183 if($state != 'STARTED') {
184 - $this->writeLuceneProperties(); 184 + //$this->writeLuceneProperties();
185 $cmd = "cd ".$this->getLuceneDir()."; "; 185 $cmd = "cd ".$this->getLuceneDir()."; ";
186 $cmd .= "nohup java -jar ".$this->getLuceneSource()." > ".SYS_LOG_DIR."lucene.log 2>&1 & echo $!"; 186 $cmd .= "nohup java -jar ".$this->getLuceneSource()." > ".SYS_LOG_DIR."lucene.log 2>&1 & echo $!";
  187 + if(DEBUG) {
  188 + echo "$cmd<br/>";
  189 + return ;
  190 + }
187 $response = $this->util->pexec($cmd); 191 $response = $this->util->pexec($cmd);
188 192
189 return $response; 193 return $response;
setup/wizard/lib/services/unixOpenOffice.php
@@ -156,6 +156,10 @@ class unixOpenOffice extends unixService { @@ -156,6 +156,10 @@ class unixOpenOffice extends unixService {
156 $state = $this->status(); 156 $state = $this->status();
157 if($state != 'STARTED') { 157 if($state != 'STARTED') {
158 $cmd = "nohup {$this->getBin()} ".$this->getOption()." > ".SYS_LOG_DIR."{$this->getLog()} 2>&1 & echo $!"; 158 $cmd = "nohup {$this->getBin()} ".$this->getOption()." > ".SYS_LOG_DIR."{$this->getLog()} 2>&1 & echo $!";
  159 + if(DEBUG) {
  160 + echo "$cmd<br/>";
  161 + return ;
  162 + }
159 $response = $this->util->pexec($cmd); 163 $response = $this->util->pexec($cmd);
160 164
161 return $response; 165 return $response;
setup/wizard/lib/services/unixScheduler.php
@@ -56,7 +56,7 @@ class unixScheduler extends unixService { @@ -56,7 +56,7 @@ class unixScheduler extends unixService {
56 56
57 public function load() { 57 public function load() {
58 $this->setSystemDir(SYSTEM_ROOT."bin".DS); 58 $this->setSystemDir(SYSTEM_ROOT."bin".DS);
59 - $this->setSchedulerDir(SYSTEM_DIR."bin".DS); 59 + $this->setSchedulerDir(VAR_BIN_DIR);
60 $this->setSchedulerSourceLoc('schedulerTask.sh'); 60 $this->setSchedulerSourceLoc('schedulerTask.sh');
61 } 61 }
62 62
@@ -156,16 +156,17 @@ class unixScheduler extends unixService { @@ -156,16 +156,17 @@ class unixScheduler extends unixService {
156 $this->writeSchedulerTask(); 156 $this->writeSchedulerTask();
157 if($source) { // Source 157 if($source) { // Source
158 $cmd = "nohup ".$source." > ".SYS_LOG_DIR."scheduler.log 2>&1 & echo $!"; 158 $cmd = "nohup ".$source." > ".SYS_LOG_DIR."scheduler.log 2>&1 & echo $!";
159 - $response = $this->util->pexec($cmd);  
160 - return $response;  
161 } else { // Could be Stack 159 } else { // Could be Stack
162 $source = SYS_BIN_DIR.$this->schedulerSource; 160 $source = SYS_BIN_DIR.$this->schedulerSource;
163 $cmd = "nohup ".$source." > ".SYS_LOG_DIR."scheduler.log 2>&1 & echo $!"; 161 $cmd = "nohup ".$source." > ".SYS_LOG_DIR."scheduler.log 2>&1 & echo $!";
164 - $response = $this->util->pexec($cmd);  
165 - return $response;  
166 } 162 }
167 -  
168 - return false; 163 + if(DEBUG) {
  164 + echo "$cmd<br/>";
  165 + return ;
  166 + }
  167 + $response = $this->util->pexec($cmd);
  168 +
  169 + return $response;
169 } 170 }
170 171
171 172
setup/wizard/lib/services/windowsLucene.php
@@ -434,7 +434,8 @@ class windowsLucene extends windowsService { @@ -434,7 +434,8 @@ class windowsLucene extends windowsService {
434 $content .= "server.paranoid=false\n"; 434 $content .= "server.paranoid=false\n";
435 $content .= "server.accept=127.0.0.1\n"; 435 $content .= "server.accept=127.0.0.1\n";
436 $content .= "server.deny=\n"; 436 $content .= "server.deny=\n";
437 - $content .= "indexer.directory=../../var/indexes\n"; 437 + $content .= "indexer.directory=".SYS_VAR_DIR."indexes\n";
  438 + //$content .= "indexer.directory=../../var/indexes\n";
438 $content .= "indexer.analyzer=org.apache.lucene.analysis.standard.StandardAnalyzer\n"; 439 $content .= "indexer.analyzer=org.apache.lucene.analysis.standard.StandardAnalyzer\n";
439 fwrite($fp, $content); 440 fwrite($fp, $content);
440 fclose($fp); 441 fclose($fp);
setup/wizard/output/dummy.txt deleted
setup/wizard/path.php
@@ -74,11 +74,13 @@ @@ -74,11 +74,13 @@
74 define('STEP_DIR', WIZARD_DIR."steps".DS); 74 define('STEP_DIR', WIZARD_DIR."steps".DS);
75 define('TEMP_DIR', WIZARD_DIR."templates".DS); 75 define('TEMP_DIR', WIZARD_DIR."templates".DS);
76 define('SHELL_DIR', WIZARD_DIR."shells".DS); 76 define('SHELL_DIR', WIZARD_DIR."shells".DS);
77 - define('OUTPUT_DIR', WIZARD_DIR."output".DS);  
78 // Define paths to system webroot 77 // Define paths to system webroot
79 define('SYSTEM_DIR', $sys); 78 define('SYSTEM_DIR', $sys);
  79 + define('SYS_VAR_DIR', SYSTEM_DIR."var".DS);
80 define('SYS_BIN_DIR', SYSTEM_DIR."bin".DS); 80 define('SYS_BIN_DIR', SYSTEM_DIR."bin".DS);
81 - define('SYS_LOG_DIR', SYSTEM_DIR."var".DS."log".DS); 81 + define('SYS_LOG_DIR', SYS_VAR_DIR."log".DS);
  82 + define('SYS_OUT_DIR', SYS_VAR_DIR);
  83 + define('VAR_BIN_DIR', SYS_VAR_DIR."bin".DS);
82 // Define paths to system 84 // Define paths to system
83 array_pop($xdir); 85 array_pop($xdir);
84 $asys = ''; 86 $asys = '';
setup/wizard/steps/configuration.php
@@ -450,8 +450,9 @@ class configuration extends Step @@ -450,8 +450,9 @@ class configuration extends Step
450 if(isset($this->temp_variables['paths'])) { 450 if(isset($this->temp_variables['paths'])) {
451 $dirs = $this->temp_variables['paths']; // Pull from temp 451 $dirs = $this->temp_variables['paths']; // Pull from temp
452 } else { 452 } else {
453 -// $dirs = $this->getDirectories();  
454 - $this->readConfigPath(); 453 + if(!$this->readConfigPath()) { // Read the configuration
  454 +
  455 + }
455 $dirs = $this->getFromConfigPath(); 456 $dirs = $this->getFromConfigPath();
456 } 457 }
457 $varDirectory = $fileSystemRoot . DS . 'var'; 458 $varDirectory = $fileSystemRoot . DS . 'var';
@@ -497,7 +498,7 @@ class configuration extends Step @@ -497,7 +498,7 @@ class configuration extends Step
497 array('name' => 'Log Directory', 'setting' => 'logDirectory', 'path' => '${varDirectory}/log', 'create' => true), 498 array('name' => 'Log Directory', 'setting' => 'logDirectory', 'path' => '${varDirectory}/log', 'create' => true),
498 array('name' => 'Temporary Directory', 'setting' => 'tmpDirectory', 'path' => '${varDirectory}/tmp', 'create' => true), 499 array('name' => 'Temporary Directory', 'setting' => 'tmpDirectory', 'path' => '${varDirectory}/tmp', 'create' => true),
499 array('name' => 'Uploads Directory', 'setting' => 'uploadDirectory', 'path' => '${varDirectory}/uploads', 'create' => true), 500 array('name' => 'Uploads Directory', 'setting' => 'uploadDirectory', 'path' => '${varDirectory}/uploads', 'create' => true),
500 - array('name' => 'Executables Directory', 'setting' => 'binDirectory', 'path' => '${fileSystemRoot}/bin', 'create' => false), 501 + array('name' => 'Executables Directory', 'setting' => 'binDirectory', 'path' => '${varDirectory}/bin', 'create' => false),
501 array('name' => 'Configuration File', 'setting' => 'configFile', 'path' => '${fileSystemRoot}/config/config.ini', 'create' => false), 502 array('name' => 'Configuration File', 'setting' => 'configFile', 'path' => '${fileSystemRoot}/config/config.ini', 'create' => false),
502 ); 503 );
503 } 504 }
@@ -505,6 +506,10 @@ class configuration extends Step @@ -505,6 +506,10 @@ class configuration extends Step
505 /** 506 /**
506 * Store contents of edited settings 507 * Store contents of edited settings
507 * 508 *
  509 + * @author KnowledgeTree Team
  510 + * @access private
  511 + * @param none
  512 + * @return array The path information
508 */ 513 */
509 private function setFromPost() { 514 private function setFromPost() {
510 $this->paths = array( 515 $this->paths = array(
@@ -513,7 +518,7 @@ class configuration extends Step @@ -513,7 +518,7 @@ class configuration extends Step
513 array('name' => 'Log Directory', 'setting' => 'logDirectory', 'path' => $_POST['logDirectory'], 'create' => true), 518 array('name' => 'Log Directory', 'setting' => 'logDirectory', 'path' => $_POST['logDirectory'], 'create' => true),
514 array('name' => 'Temporary Directory', 'setting' => 'tmpDirectory', 'path' => $_POST['tmpDirectory'], 'create' => true), 519 array('name' => 'Temporary Directory', 'setting' => 'tmpDirectory', 'path' => $_POST['tmpDirectory'], 'create' => true),
515 array('name' => 'Uploads Directory', 'setting' => 'uploadDirectory', 'path' => $_POST['uploadDirectory'], 'create' => true), 520 array('name' => 'Uploads Directory', 'setting' => 'uploadDirectory', 'path' => $_POST['uploadDirectory'], 'create' => true),
516 - array('name' => 'Executables Directory', 'setting' => 'binDirectory', 'path' => $_POST['binDirectory'], 'create' => false), 521 + array('name' => 'Executables Directory', 'setting' => 'binDirectory', 'path' => $_POST['uploadDirectory'], 'create' => true),
517 array('name' => 'Configuration File', 'setting' => 'configFile', 'path' => $_POST['configFile'], 'create' => false), 522 array('name' => 'Configuration File', 'setting' => 'configFile', 'path' => $_POST['configFile'], 'create' => false),
518 ); 523 );
519 } 524 }
@@ -521,20 +526,36 @@ class configuration extends Step @@ -521,20 +526,36 @@ class configuration extends Step
521 /** 526 /**
522 * Store contents of edited settings 527 * Store contents of edited settings
523 * 528 *
  529 + * @author KnowledgeTree Team
  530 + * @access private
  531 + * @param none
  532 + * @return array The path information
524 */ 533 */
525 private function getFromConfigPath() { 534 private function getFromConfigPath() {
526 - return array(  
527 - array('name' => 'Configuration File', 'setting' => 'configFile', 'path' => $this->confpaths['configIni'], 'create' => false),  
528 - array('name' => 'Document Directory', 'setting' => 'documentRoot', 'path' => $this->confpaths['Documents'], 'create' => true),  
529 - array('name' => 'Cache Directory', 'setting' => 'cacheDirectory', 'path' => $this->confpaths['cache'], 'create' => true),  
530 - array('name' => 'Index Directory', 'setting' => 'indexDirectory', 'path' => $this->confpaths['indexes'], 'create' => true),  
531 - array('name' => 'Log Directory', 'setting' => 'logDirectory', 'path' => $this->confpaths['log'], 'create' => true),  
532 - array('name' => 'Proxy Directory', 'setting' => 'proxiesDirectory', 'path' => $this->confpaths['proxies'], 'create' => true),  
533 - array('name' => 'Temporary Directory', 'setting' => 'tmpDirectory', 'path' => $this->confpaths['tmp'], 'create' => true),  
534 - array('name' => 'Uploads Directory', 'setting' => 'uploadDirectory', 'path' => $this->confpaths['uploads'], 'create' => true),  
535 - ); 535 + if(isset($this->confpaths['Documents'])) { // Simple check to see if any paths were written
  536 + return array (
  537 + array('name' => 'Configuration File', 'setting' => 'configFile', 'path' => $this->confpaths['configIni'], 'create' => false),
  538 + array('name' => 'Document Directory', 'setting' => 'documentRoot', 'path' => $this->confpaths['Documents'], 'create' => true),
  539 + array('name' => 'Cache Directory', 'setting' => 'cacheDirectory', 'path' => $this->confpaths['cache'], 'create' => true),
  540 + array('name' => 'Index Directory', 'setting' => 'indexDirectory', 'path' => $this->confpaths['indexes'], 'create' => true),
  541 + array('name' => 'Log Directory', 'setting' => 'logDirectory', 'path' => $this->confpaths['log'], 'create' => true),
  542 + array('name' => 'Proxy Directory', 'setting' => 'proxiesDirectory', 'path' => $this->confpaths['proxies'], 'create' => true),
  543 + array('name' => 'Temporary Directory', 'setting' => 'tmpDirectory', 'path' => $this->confpaths['tmp'], 'create' => true),
  544 + array('name' => 'Uploads Directory', 'setting' => 'uploadDirectory', 'path' => $this->confpaths['uploads'], 'create' => true),
  545 + );
  546 + } else {
  547 + return $this->getDirectories();
  548 + }
536 } 549 }
537 550
  551 + /**
  552 + * Path information
  553 + *
  554 + * @author KnowledgeTree Team
  555 + * @access public
  556 + * @param string $fileSystemRoot The file system root of the installation
  557 + * @return array The path information
  558 + */
538 public function getFromPost() { 559 public function getFromPost() {
539 return $this->paths; 560 return $this->paths;
540 } 561 }
@@ -542,14 +563,16 @@ class configuration extends Step @@ -542,14 +563,16 @@ class configuration extends Step
542 /** 563 /**
543 * Read contents of config path file 564 * Read contents of config path file
544 * 565 *
  566 + * @author KnowledgeTree Team
  567 + * @access private
  568 + * @param none
  569 + * @return array The path information
545 */ 570 */
546 private function readConfigPath() { 571 private function readConfigPath() {
547 - $configPath = realpath('../../../config/config-path');  
548 - if($configPath == '')  
549 - $configPath = realpath('../../config/config-path'); 572 + $configPath = $this->getContentPath();
  573 + if(!$configPath) return false;
550 $ini = new Ini($configPath); 574 $ini = new Ini($configPath);
551 - $data = $ini->read($configPath);  
552 - $data = $data['']; 575 + $data = $ini->getFileByLine();
553 foreach ($data as $k=>$v) { 576 foreach ($data as $k=>$v) {
554 if(preg_match('/config.ini/', $k)) { 577 if(preg_match('/config.ini/', $k)) {
555 $this->confpaths['configIni'] = $k; 578 $this->confpaths['configIni'] = $k;
@@ -570,20 +593,22 @@ class configuration extends Step @@ -570,20 +593,22 @@ class configuration extends Step
570 } 593 }
571 } 594 }
572 595
573 - return false; 596 + return true;
574 } 597 }
575 598
576 /** 599 /**
577 * Read contents of config path file 600 * Read contents of config path file
578 * 601 *
  602 + * @author KnowledgeTree Team
  603 + * @access private
  604 + * @param none
  605 + * @return boolean
579 */ 606 */
580 private function writeConfigPath() { 607 private function writeConfigPath() {
581 - $configPath = realpath('../../../config/config-path');  
582 - if($configPath == '')  
583 - $configPath = realpath('../../config/config-path'); 608 + $configPath = $this->getContentPath();
  609 + if(!$configPath) return false;
584 $ini = new Ini($configPath); 610 $ini = new Ini($configPath);
585 - $data = $ini->read($configPath);  
586 - $data = $data['']; 611 + $data = $ini->getFileByLine();
587 $configContent = ''; 612 $configContent = '';
588 foreach ($data as $k=>$v) { 613 foreach ($data as $k=>$v) {
589 if(preg_match('/config.ini/', $k)) { 614 if(preg_match('/config.ini/', $k)) {
@@ -597,13 +622,24 @@ class configuration extends Step @@ -597,13 +622,24 @@ class configuration extends Step
597 return true; 622 return true;
598 } 623 }
599 624
  625 + /**
  626 + * Attempt to locate config-path file in system
  627 + *
  628 + * @author KnowledgeTree Team
  629 + * @access private
  630 + * @param none
  631 + * @return mixed
  632 + */
  633 + public function getContentPath() {
  634 + $configPath = realpath('../../../config/config-path');
  635 + if($configPath == '')
  636 + $configPath = realpath('../../config/config-path');
  637 + if(!$configPath) return false;
  638 + return $configPath;
  639 + }
  640 +
600 public function doReadConfig() { 641 public function doReadConfig() {
601 - $this->readConfigPath();  
602 -// $this->writeConfigPath();  
603 - $configPaths = $this->getFromConfigPath();  
604 -// echo '<pre>';  
605 -// print_r($configPaths);  
606 -// echo '</pre>'; 642 +
607 } 643 }
608 } 644 }
609 645
setup/wizard/steps/services.php
@@ -660,10 +660,10 @@ class services extends Step @@ -660,10 +660,10 @@ class services extends Step
660 } 660 }
661 $javaExecutable = $this->java; 661 $javaExecutable = $this->java;
662 } 662 }
663 - $cmd = "\"$javaExecutable\" -version > output/outJV 2>&1 echo $!"; 663 + $cmd = "\"$javaExecutable\" -version > ".SYS_OUT_DIR."/outJV 2>&1 echo $!";
664 $response = $this->util->pexec($cmd); 664 $response = $this->util->pexec($cmd);
665 - if(file_exists(OUTPUT_DIR.'outJV')) {  
666 - $tmp = file_get_contents(OUTPUT_DIR.'outJV'); 665 + if(file_exists(SYS_OUT_DIR.'outJV')) {
  666 + $tmp = file_get_contents(SYS_OUT_DIR.'outJV');
667 preg_match('/"(.*)"/',$tmp, $matches); 667 preg_match('/"(.*)"/',$tmp, $matches);
668 if($matches) { 668 if($matches) {
669 if($matches[1] < $this->javaVersion) { // Check Version of java 669 if($matches[1] < $this->javaVersion) { // Check Version of java
@@ -704,10 +704,10 @@ class services extends Step @@ -704,10 +704,10 @@ class services extends Step
704 // TODO: Better php handling 704 // TODO: Better php handling
705 return true; 705 return true;
706 $phpExecutable = $this->util->phpSpecified();// Retrieve java bin 706 $phpExecutable = $this->util->phpSpecified();// Retrieve java bin
707 - $cmd = "$phpExecutable -version > output/outPHP 2>&1 echo $!"; 707 + $cmd = "$phpExecutable -version > ".SYS_OUT_DIR."/outPHP 2>&1 echo $!";
708 $response = $this->util->pexec($cmd); 708 $response = $this->util->pexec($cmd);
709 - if(file_exists(OUTPUT_DIR.'outPHP')) {  
710 - $tmp = file_get_contents(OUTPUT_DIR.'outPHP'); 709 + if(file_exists(SYS_OUT_DIR.'outPHP')) {
  710 + $tmp = file_get_contents(SYS_OUT_DIR.'outPHP');
711 preg_match('/PHP/',$tmp, $matches); 711 preg_match('/PHP/',$tmp, $matches);
712 if($matches) { 712 if($matches) {
713 $this->phpCheck = 'tick'; 713 $this->phpCheck = 'tick';
var/bin/schedulerTask.sh 0 → 100644
  1 +// DO NOT DELETE