Commit 71e2f37b3d86898868d804d8ca67269cebada4eb

Authored by Jarrett Jordaan
1 parent 4daef597

Updated source only install 'Configuration Step'. Removed redundant 'Install Typ…

…e Step'. Updated ini class. Updated utilities class. Updated Open Office Service install

Committed by: Jarrett Jordaan

Reviewed by: Megan Watson
dmsctl.sh
... ... @@ -32,7 +32,7 @@ SOFFICE_PIDFILE=$INSTALL_PATH/var/log/soffice.bin.pid
32 32 SOFFICE_PID=""
33 33 SOFFICE_PORT="8100"
34 34 SOFFICEBIN=/usr/bin/soffice
35   -SOFFICE="$SOFFICEBIN -nofirststartwizard -nologo -headless -accept=socket,host=127.0.0.1,port=$SOFFICE_PORT;urp;StarOffice.ServiceManager"
  35 +SOFFICE="$SOFFICEBIN -nofirststartwizard -nologo -headless -\"accept=socket,host=127.0.0.1,port=$SOFFICE_PORT;urp;StarOffice.ServiceManager\""
36 36 SOFFICE_STATUS=""
37 37  
38 38 # Lucene
... ...
setup/wizard/config/config.xml
... ... @@ -11,7 +11,7 @@
11 11 <steps>
12 12 <step name="Welcome">welcome</step>
13 13 <step name="License Agreement">license</step>
14   - <step name="Install Type">installtype</step>
  14 +<!-- <step name="Install Type">installtype</step>-->
15 15 <step name="PHP Dependencies" mode="silent">dependencies</step>
16 16 <step name="System Configuration" order="2">configuration</step>
17 17 <step name="Service Dependency" order="3" mode="silent">services</step>
... ...
setup/wizard/iniUtilities.php
... ... @@ -43,21 +43,15 @@ class iniUtilities {
43 43 private $lineNum = 0;
44 44 private $exists = '';
45 45  
46   -
47 46 function load($iniFile) {
48   -// if($this->iniFile != $iniFile) {
49   - $this->cleanArray = array();
50   - $this->lineNum = 0;
51   - $this->exists = '';
52   -// }
  47 + $this->cleanArray = array();
53 48 $this->iniFile = $iniFile;
  49 + $this->lineNum = 0;
  50 + $this->exists = '';
54 51 $this->backupIni($iniFile);
55 52 $this->read($iniFile);
56 53 }
57 54  
58   -// function __construct() {
59   -// }
60   -
61 55 /**
62 56 * Create a backup with the date as an extension in the same location as the original config.ini
63 57 *
... ... @@ -125,25 +119,23 @@ class iniUtilities {
125 119 }
126 120  
127 121 function write($iniFile = "") {
128   -
129 122 if(empty($iniFile)) {
130 123 $iniFile = $this->iniFile;
131 124 }
132 125 if (!is_writeable($iniFile)) {
133 126 return;
134 127 }
135   -
136 128 $fileHandle = fopen($iniFile, 'wb');
137 129 foreach ($this->cleanArray as $section => $items) {
138 130 if (substr($section, 0, strlen('_blankline_')) === '_blankline_' ) {
139   - @fwrite ($fileHandle, "\r\n");
  131 + fwrite ($fileHandle, "\r\n");
140 132 continue;
141 133 }
142 134 if (substr($section, 0, strlen('_comment_')) === '_comment_' ) {
143   - @fwrite ($fileHandle, "$items\r\n");
  135 + fwrite ($fileHandle, "$items\r\n");
144 136 continue;
145 137 }
146   - @fwrite ($fileHandle, "[".$section."]\r\n");
  138 + fwrite ($fileHandle, "[".$section."]\r\n");
147 139 foreach ($items as $key => $value) {
148 140 if (substr($key, 0, strlen('_blankline_')) === '_blankline_' ) {
149 141 fwrite ($fileHandle, "\r\n");
... ... @@ -155,11 +147,10 @@ class iniUtilities {
155 147 }
156 148  
157 149 $value = addcslashes($value,'');
158   - //fwrite ($fileHandle, $key.' = "'.$value."\"\r\n");
159   - @fwrite ($fileHandle, $key.' = '.$value."\r\n");
  150 + fwrite ($fileHandle, $key.' = '.$value."\r\n");
160 151 }
161 152 }
162   - @fclose($fileHandle);
  153 + fclose($fileHandle);
163 154 }
164 155  
165 156 function itemExists($checkSection, $checkItem) {
... ... @@ -195,10 +186,11 @@ class iniUtilities {
195 186 }
196 187  
197 188 function updateItem($addSection, $addItem, $value) {
198   - if(WINDOWS_OS)
  189 + if(WINDOWS_OS) {
199 190 $this->cleanArray[$addSection][$addItem] = $value;
200   - else
  191 + } else {
201 192 $this->cleanArray[$addSection][$addItem] = stripcslashes($value);
  193 + }
202 194 return true;
203 195 }
204 196  
... ...
setup/wizard/installUtil.php
... ... @@ -264,11 +264,13 @@ class InstallUtil {
264 264 */
265 265 public function checkPermission($dir, $create=false, $file = false)
266 266 {
267   - if(!$file)
  267 + if(!$file) {
268 268 $exist = 'Directory doesn\'t exist';
269   - else
  269 + } else {
270 270 $exist = 'File doesn\'t exist';
  271 + }
271 272 $write = 'Directory not writable';
  273 + $fwrite = 'File not writable';
272 274 $ret = array('class' => 'cross');
273 275  
274 276 if(!file_exists($dir)){
... ... @@ -298,7 +300,11 @@ class InstallUtil {
298 300 }
299 301  
300 302 $this->done = false;
301   - $ret['msg'] = $write;
  303 + if(!$file) {
  304 + $ret['msg'] = $write;
  305 + } else {
  306 + $ret['msg'] = $fwrite;
  307 + }
302 308 return $ret;
303 309 }
304 310  
... ... @@ -364,13 +370,13 @@ class InstallUtil {
364 370 * @return boolean
365 371 */
366 372 public function canWriteFile($filename) {
367   - $fh = @fopen($filename, "w+");
368   - $fr = @fwrite($fh, 'test');
  373 + $fh = fopen($filename, "w+");
  374 + $fr = fwrite($fh, 'test');
369 375 if($fr === false) {
370 376 return false;
371 377 }
372 378  
373   - @fclose($fh);
  379 + fclose($fh);
374 380 return true;
375 381 }
376 382  
... ... @@ -518,23 +524,23 @@ class InstallUtil {
518 524 }
519 525  
520 526 /**
521   - * Check if system needs to be migrated
  527 + * Check if system needs to be accessed
522 528 *
523 529 * @author KnowledgeTree Team
524 530 * @access public
525 531 * @param none
526 532 * @return boolean
527 533 */
528   - public function migrationSpecified() {
529   - if(isset($_POST['installtype'])) {
530   - if($_POST['installtype'] == "Upgrade Installation") {
  534 + public function finishSpecified() {
  535 + if(isset($_GET['Finish'])) {
  536 + if($_GET['Finish'] == "Finish") {
531 537 return true;
532 538 }
533 539 }
534 540  
535 541 return false;
536   - }
537   -
  542 + }
  543 +
538 544 /**
539 545 * Check if system needs to be migrated
540 546 *
... ... @@ -543,27 +549,9 @@ class InstallUtil {
543 549 * @param none
544 550 * @return boolean
545 551 */
546   - public function upgradeSpecified() {
  552 + public function migrationSpecified() {
547 553 if(isset($_POST['installtype'])) {
548   - if($_POST['installtype'] == "Upgrade Only") {
549   - return true;
550   - }
551   - }
552   -
553   - return false;
554   - }
555   -
556   - /**
557   - * Check if system needs to be migrated
558   - *
559   - * @author KnowledgeTree Team
560   - * @access public
561   - * @param none
562   - * @return boolean
563   - */
564   - public function loginSpecified() {
565   - if(isset($_GET['completeType'])) {
566   - if($_GET['completeType'] == "Login") {
  554 + if($_POST['installtype'] == "Upgrade Installation") {
567 555 return true;
568 556 }
569 557 }
... ... @@ -579,9 +567,9 @@ class InstallUtil {
579 567 * @param none
580 568 * @return boolean
581 569 */
582   - public function zendSpecified() {
583   - if(isset($_GET['completeType'])) {
584   - if($_GET['completeType'] == "Zend Server Configuration") {
  570 + public function upgradeSpecified() {
  571 + if(isset($_POST['installtype'])) {
  572 + if($_POST['installtype'] == "Upgrade Only") {
585 573 return true;
586 574 }
587 575 }
... ... @@ -607,8 +595,6 @@ class InstallUtil {
607 595 return false;
608 596 }
609 597  
610   -
611   -
612 598 /**
613 599 * Get session data from package
614 600 *
... ... @@ -808,6 +794,19 @@ class InstallUtil {
808 794 public function sqlInstallDir() {
809 795 return SYSTEM_DIR."sql".DS."mysql".DS."install".DS;
810 796 }
  797 +
  798 + public function getFileByLine($file) {
  799 + $fileLines = array();
  800 + $file_handle = fopen($file, "rb");
  801 + while (!feof($file_handle) ) {
  802 + $line_of_text = fgets($file_handle);
  803 + $parts = explode('=', $line_of_text);
  804 + $fileLines[] = $line_of_text;
  805 + }
  806 + fclose($file_handle);
  807 + return $fileLines;
  808 + }
  809 +
811 810 /**
812 811 * Portably execute a command on any of the supported platforms.
813 812 *
... ...
setup/wizard/lib/services/unixScheduler.php
... ... @@ -108,7 +108,7 @@ class unixScheduler extends unixService {
108 108  
109 109 function writeSchedulerTask() {
110 110 $fLoc = $this->getSchedulerDir().$this->getSchedulerSource();
111   - $fp = @fopen($fLoc, "w+");
  111 + $fp = fopen($fLoc, "w+");
112 112 $content = "#!/bin/sh\n";
113 113 $content .= "cd ".SYS_BIN_DIR."\n";
114 114 $content .= "while true; do\n";
... ... @@ -116,8 +116,8 @@ class unixScheduler extends unixService {
116 116 $content .= "{$this->phpCli} -Cq scheduler.php\n";
117 117 $content .= "sleep 30\n";
118 118 $content .= "done";
119   - @fwrite($fp, $content);
120   - @fclose($fp);
  119 + fwrite($fp, $content);
  120 + fclose($fp);
121 121 }
122 122  
123 123 function install() {
... ...
setup/wizard/steps/complete.php
... ... @@ -54,7 +54,6 @@ class complete extends Step {
54 54 private $database_check = 'tick';
55 55 private $migrate_check = false;
56 56 public $silent = true;
57   - private $install_environment = 'Zend';
58 57 private $servicesValidation = false;
59 58  
60 59 function doStep() {
... ... @@ -68,7 +67,6 @@ class complete extends Step {
68 67 $this->checkDb(); // check database
69 68 $this->checkServices(); // check services
70 69 $this->checkInstallType();// Set silent mode variables
71   - $this->install_environment = $this->util->installEnvironment(); // Determine installation environment
72 70 $this->storeSilent();// Set silent mode variables
73 71 }
74 72  
... ... @@ -239,7 +237,6 @@ class complete extends Step {
239 237 $this->temp_variables['privileges_check'] = $this->privileges_check;
240 238 $this->temp_variables['database_check'] = $this->database_check;
241 239 $this->temp_variables['migrate_check'] = $this->migrate_check;
242   - $this->temp_variables['install_environment'] = $this->install_environment;
243 240 $this->temp_variables['servicesValidation'] = $this->servicesValidation;
244 241 }
245 242 }
... ...
setup/wizard/steps/configuration.php
... ... @@ -252,6 +252,12 @@ class configuration extends Step
252 252 $paths = $this->getPathInfo($server['file_system_root']['value']);
253 253 if(!$edit) $this->temp_variables['paths'] = $paths;
254 254  
  255 + // Rewrite file system root
  256 + if(!$this->fpath) {
  257 + $froot = $this->temp_variables['server']['file_system_root']['value'];
  258 + $this->temp_variables['server']['file_system_root']['value'] = 'default';
  259 + }
  260 +
255 261 return $this->done;
256 262 }
257 263  
... ... @@ -295,6 +301,7 @@ class configuration extends Step
295 301 */
296 302 public function installStep()
297 303 {
  304 + $this->file_system_root = realpath(SYSTEM_DIR);
298 305 $conf = $this->getDataFromSession("configuration"); // get data from the server
299 306 $dbconf = $this->getDataFromSession("database");
300 307 $this->util->dbUtilities->load($dbconf['dhost'], $dbconf['dport'], $dbconf['dmsname'], $dbconf['dmspassword'], $dbconf['dname']);
... ... @@ -382,6 +389,7 @@ class configuration extends Step
382 389 {
383 390 $script = $_SERVER['SCRIPT_NAME'];
384 391 $file_system_root = realpath(SYSTEM_DIR);
  392 + $this->file_system_root = $file_system_root;
385 393 $host = $_SERVER['SERVER_NAME'];
386 394 $port = $_SERVER['SERVER_PORT'];
387 395 $ssl_enabled = isset($_SERVER['HTTPS']) ? (strtolower($_SERVER['HTTPS']) === 'on' ? 'yes' : 'no') : 'no';
... ... @@ -394,12 +402,7 @@ class configuration extends Step
394 402 $ssl_enabled = (isset($_POST['ssl_enabled'])) ? $_POST['ssl_enabled'] : $ssl_enabled;
395 403 $server = array();
396 404 $server['root_url'] = array('name' => 'Root Url', 'setting' => 'rootUrl', 'where' => 'db', 'value' => $root_url);
397   - if(!$this->fpath) {
398   - $system_root = 'default';
399   - } else {
400   - $system_root = $file_system_root;
401   - }
402   - $server['file_system_root'] = array('name' => 'File System Root', 'section' => 'KnowledgeTree', 'setting' => 'fileSystemRoot', 'where' => 'file', 'value' => $system_root);
  405 + $server['file_system_root'] = array('name' => 'File System Root', 'section' => 'KnowledgeTree', 'setting' => 'fileSystemRoot', 'where' => 'file', 'value' => $file_system_root);
403 406 $server['host'] = array('name' => 'Host', 'setting' => 'server_name', 'where' => 'db', 'value' => $host);
404 407 $server['port'] = array('name' => 'Port', 'setting' => 'server_port', 'where' => 'db', 'value' => $port);
405 408 $server['ssl_enabled'] = array('name' => 'SSL Enabled', 'section' => 'KnowledgeTree', 'setting' => 'sslEnabled', 'where' => 'file', 'value' => $ssl_enabled);
... ... @@ -573,10 +576,9 @@ class configuration extends Step
573 576 if(!$configPath) {
574 577 return false;
575 578 }
576   - $this->util->iniUtilities->load($configPath);
577   - $data = $this->util->iniUtilities->getFileByLine();
  579 + $data = $this->util->getFileByLine($configPath);
578 580 $firstline = true;
579   - foreach ($data as $k=>$v) {
  581 + foreach ($data as $k) {
580 582 if(preg_match('/config.ini/', $k)) { // Find config.ini
581 583 if($k == "config/config.ini") { // Source install and source upgrades
582 584 $configIniPath = realpath(SYSTEM_DIR.$k);
... ... @@ -595,10 +597,9 @@ class configuration extends Step
595 597 if(!$cachePath) {
596 598 return false;
597 599 }
598   - $this->util->iniUtilities->load($cachePath);
599   - $data = $this->util->iniUtilities->getFileByLine();
  600 + $data = $this->util->getFileByLine($cachePath);
600 601 $firstline = true;
601   - foreach ($data as $k=>$v) {
  602 + foreach ($data as $k) {
602 603 if(preg_match('/cache/', $k)) { // Find config.ini
603 604 if($k == "var/cache") { // Source install and source upgrades
604 605 $configIniPath = realpath(SYSTEM_DIR.$k);
... ... @@ -623,10 +624,9 @@ class configuration extends Step
623 624 private function readConfigPath() {
624 625 $configPath = $this->getContentPath();
625 626 if(!$configPath) return false;
626   - $this->util->iniUtilities->load($configPath);
627   - $data = $this->util->iniUtilities->getFileByLine();
  627 + $data = $this->util->getFileByLine($configPath);
628 628 $firstline = true;
629   - foreach ($data as $k=>$v) {
  629 + foreach ($data as $k) {
630 630 if($firstline) { // First line holds the var directory
631 631 $firstline = false;
632 632 if(!preg_match('/config.ini/', $k)) { // Make sure it is not the old config.ini
... ... @@ -651,7 +651,11 @@ class configuration extends Step
651 651 $this->confpaths['tmp'] = $k;
652 652 }
653 653 }
654   -
  654 + // Source Installs
  655 + if($this->confpaths['configIni'] == 'config/config.ini') {
  656 + $this->confpaths['configIni'] = $this->file_system_root .DS. $this->confpaths['configIni'];
  657 + }
  658 +
655 659 return true;
656 660 }
657 661  
... ... @@ -664,16 +668,24 @@ class configuration extends Step
664 668 * @return boolean
665 669 */
666 670 private function writeConfigPath($configPath, $configContent) {
667   - $fp = @fopen($configPath, 'w+');
668   - if(@fwrite($fp, $configContent))
669   - return true;
  671 + if($configContent == 'config/config.ini') {
  672 + $configContent = $this->file_system_root . DS . 'config/config.ini';
  673 + }
  674 + $fp = fopen($configPath, 'w+');
  675 + if($configContent != '' && $fp) {
  676 + if(fwrite($fp, $configContent))
  677 + return true;
  678 + }
670 679 return false;
671 680 }
672 681  
673 682 private function writeCachePath($cachePath, $cacheContent) {
674   - $fp = @fopen($cachePath, 'w+');
675   - if($cacheContent != '') {
676   - if(@fwrite($fp, $cacheContent))
  683 + if($cacheContent == 'var/cache') {
  684 + $cacheContent = $this->file_system_root . DS . 'var/cache';
  685 + }
  686 + $fp = fopen($cachePath, 'w+');
  687 + if($cacheContent != '' && $fp) {
  688 + if(fwrite($fp, $cacheContent))
677 689 return true;
678 690 }
679 691 return false;
... ...
setup/wizard/steps/database.php
... ... @@ -734,7 +734,7 @@ class database extends Step
734 734 }
735 735  
736 736 private function parse_mysql_dump($url) {
737   - $handle = @fopen($url, "r");
  737 + $handle = fopen($url, "r");
738 738 $query = "";
739 739 if ($handle) {
740 740 while (!feof($handle)) {
... ... @@ -744,7 +744,7 @@ class database extends Step
744 744 $query = '';
745 745 }
746 746 }
747   - @fclose($handle);
  747 + fclose($handle);
748 748 }
749 749  
750 750 return true;
... ...
setup/wizard/steps/registration.php
... ... @@ -183,7 +183,7 @@ class registration extends Step
183 183 $params['http']['header'] = $optional_headers;
184 184 }
185 185 $ctx = stream_context_create($params);
186   - $fp = @fopen($url, 'r', false, $ctx);
  186 + $fp = fopen($url, 'r', false, $ctx);
187 187 if (!$fp) {
188 188 throw new Exception("Problem with $url, $php_errormsg");
189 189 }
... ... @@ -192,7 +192,7 @@ class registration extends Step
192 192 fclose($fp);
193 193 throw new Exception("Problem reading data from $url, $php_errormsg");
194 194 }
195   - @fclose($fp);
  195 + fclose($fp);
196 196 return $response;
197 197 }
198 198  
... ...
setup/wizard/templates/complete.tpl
... ... @@ -25,7 +25,7 @@
25 25 <p class="disclaimer">
26 26 <?php if(WINDOWS_OS) { ?>
27 27 cd KnowledgeTree_Installation_Folder<br/>
28   - dmsctl.bat install
  28 + dmsctl.bat install<br/>
29 29 dmsctl.bat start
30 30 <?php } else { ?>
31 31 cd /usr/share/knowledgetree-ce<br/>
... ... @@ -162,13 +162,5 @@
162 162 <?php } else { ?>
163 163 <a href="../../login.php" class="back button_next" style="width:50px;" onclick="javascript:{w.clearSessions();}">Finish</a>
164 164 <?php } ?>
165   - <?php
166   - if ($install_environment == 'Zend') {
167   - ?>
168   -<!-- <input type="submit" name="type" value="Zend Server Configuration" class="button_previous"/>-->
169   -<!-- <a href="<?php //echo "http://".$_SERVER['HTTP_HOST'].":10081/ZendServer/Index"; ?>" class="back" target="_blank" onclick="javascript:{w.clearSessions();}">Zend Server Configuration</a>-->
170   - <?php
171   - }
172   - ?>
173 165 </form>
174 166 <?php if (AJAX) { echo $html->js('form.js'); } ?>
175 167 \ No newline at end of file
... ...