Commit d681daa9d558d7581ad57ff869ac546e58ab71fb

Authored by jarrett
1 parent 13455c43

Story Id: 778902 Daily Commit

Committed by: Jarrett Jordaan

Reviewed by: Megan Watson
setup/wizard/installUtil.php
@@ -312,6 +312,59 @@ class InstallUtil { @@ -312,6 +312,59 @@ class InstallUtil {
312 return true; 312 return true;
313 } 313 }
314 314
  315 + public function javaBridge() {
  316 + try {
  317 + $javaSystem = new Java('java.lang.System');
  318 + } catch (JavaException $e) {
  319 + return false;
  320 + }
  321 + return true;
  322 + }
  323 +
  324 + function tryJava1() {
  325 + $response = $this->pexec("java -version"); // Java Runtime Check
  326 + if(empty($response['out'])) {
  327 + return false;
  328 + }
  329 +
  330 + return array('response'=>$response, 'java'=>'java');
  331 + }
  332 +
  333 + function tryJava2() {
  334 + $response = $this->pexec("java"); // Java Runtime Check
  335 + if(empty($response['out'])) {
  336 + return false;
  337 + }
  338 +
  339 + return array('response'=>$response, 'java'=>'java');
  340 + }
  341 +
  342 + function tryJava3() {
  343 + $response = $this->pexec("whereis java"); // Java Runtime Check
  344 + if(empty($response['out'])) {
  345 + return false;
  346 + }
  347 + $broke = explode(' ', $response['out'][0]);
  348 + foreach ($broke as $r) {
  349 + $match = preg_match('/bin/', $r);
  350 + if($match) {
  351 + return array('response'=>$response, 'java'=>preg_replace('/java:/', '', $r));
  352 + }
  353 + }
  354 + }
  355 +
  356 + function getJava() {
  357 + $response = $this->tryJava1();
  358 + if(!is_array($response)) {
  359 + $response = $this->tryJava2();
  360 + if(!is_array($response)) {
  361 + $response = $this->tryJava3();
  362 + }
  363 + }
  364 +
  365 + return $response;
  366 + }
  367 +
315 /** 368 /**
316 * Portably execute a command on any of the supported platforms. 369 * Portably execute a command on any of the supported platforms.
317 * 370 *
setup/wizard/lib/services/unixLucene.php
@@ -202,8 +202,7 @@ class unixLucene extends unixService { @@ -202,8 +202,7 @@ class unixLucene extends unixService {
202 $state = $this->status(); 202 $state = $this->status();
203 if($state != 'STARTED') { 203 if($state != 'STARTED') {
204 $cmd = "cd ".$this->getLuceneDir()."; "; 204 $cmd = "cd ".$this->getLuceneDir()."; ";
205 - $cmd .= "nohup java -jar ".$this->getLuceneSource()." &> ".SYS_LOG_DIR."lucene.log &";  
206 - echo $cmd;die; 205 + $cmd .= "nohup java -jar ".$this->getLuceneSource()." > ".SYS_LOG_DIR."lucene.log 2>&1 & echo $!";
207 $response = $this->util->pexec($cmd); 206 $response = $this->util->pexec($cmd);
208 207
209 return $response; 208 return $response;
setup/wizard/step.php
@@ -349,6 +349,18 @@ class Step @@ -349,6 +349,18 @@ class Step
349 return ''; 349 return '';
350 } 350 }
351 351
  352 + /**
  353 + * Return whether or not to a step has to be in silent mode
  354 + *
  355 + * @author KnowledgeTree Team
  356 + * @param none
  357 + * @access public
  358 + * @return boolean
  359 + */
  360 + public function silentMode() {
  361 + return $this->silent;
  362 + }
  363 +
352 /** 364 /**
353 * Set step errors 365 * Set step errors
354 * 366 *
setup/wizard/steps/services.php
@@ -49,7 +49,7 @@ class services extends Step @@ -49,7 +49,7 @@ class services extends Step
49 * @access public 49 * @access public
50 * @var array 50 * @var array
51 */ 51 */
52 - public $error = array(); 52 + protected $error = array();
53 53
54 /** 54 /**
55 * Flag if step needs to be installed 55 * Flag if step needs to be installed
@@ -60,13 +60,13 @@ class services extends Step @@ -60,13 +60,13 @@ class services extends Step
60 */ 60 */
61 protected $runInstall = true; 61 protected $runInstall = true;
62 62
63 - protected $services = array('Lucene', 'Scheduler'); 63 + private $services = array('Lucene', 'Scheduler');
64 64
65 protected $java; 65 protected $java;
66 66
67 protected $util; 67 protected $util;
68 68
69 - protected $response; 69 + private $response;
70 70
71 private $javaVersion = '1.5'; 71 private $javaVersion = '1.5';
72 72
@@ -79,7 +79,7 @@ class services extends Step @@ -79,7 +79,7 @@ class services extends Step
79 */ 79 */
80 protected $storeInSession = false; 80 protected $storeInSession = false;
81 81
82 - public $temp_variables; 82 + protected $temp_variables;
83 83
84 /** 84 /**
85 * Constructs services object 85 * Constructs services object
@@ -91,54 +91,9 @@ class services extends Step @@ -91,54 +91,9 @@ class services extends Step
91 public function __construct() { 91 public function __construct() {
92 $this->temp_variables = array("step_name"=>"services"); 92 $this->temp_variables = array("step_name"=>"services");
93 $this->util = new InstallUtil(); 93 $this->util = new InstallUtil();
94 - $this->setJava();  
95 } 94 }
96 95
97 - function tryJava1() {  
98 - $response = $this->util->pexec("java -version"); // Java Runtime Check  
99 - if(empty($response['out'])) {  
100 - return false;  
101 - }  
102 - $this->java = 'java';  
103 - $this->response = $response;  
104 - return true;  
105 - }  
106 -  
107 - function tryJava2() {  
108 - $response = $this->util->pexec("java"); // Java Runtime Check  
109 - if(empty($response['out'])) {  
110 - return false;  
111 - }  
112 - $this->java = 'java';  
113 - $this->response = $response;  
114 - return true;  
115 - }  
116 -  
117 - function tryJava3() {  
118 - $response = $this->util->pexec("whereis java"); // Java Runtime Check  
119 - if(empty($response['out'])) {  
120 - return false;  
121 - }  
122 - $broke = explode(' ', $response['out'][0]);  
123 - foreach ($broke as $r) {  
124 - $match = preg_match('/bin/', $r);  
125 - if($match) {  
126 - $this->java = preg_replace('/java:/', '', $r);  
127 - $this->response = $response;  
128 - return true;  
129 - }  
130 - }  
131 - }  
132 -  
133 - function setJava() {  
134 - $response = $this->tryJava1();  
135 - if(!$response) {  
136 - $response = $this->tryJava2();  
137 - if(!$response) {  
138 - $response = $this->tryJava3();  
139 - }  
140 - }  
141 - } 96 +
142 97
143 function getJavaResponse() { 98 function getJavaResponse() {
144 return $this->response; 99 return $this->response;
@@ -180,8 +135,15 @@ class services extends Step @@ -180,8 +135,15 @@ class services extends Step
180 * @return boolean 135 * @return boolean
181 */ 136 */
182 private function doRun() { 137 private function doRun() {
  138 + $javaSettings = $this->util->getJava();
  139 + $this->response = $javaSettings['response'];
  140 + $this->java = $javaSettings['java'];
183 if($this->javaChecks()) { 141 if($this->javaChecks()) {
184 $this->installService(); 142 $this->installService();
  143 + } else { // Services not installed
  144 + foreach ($this->services as $serviceName) {
  145 + $this->temp_variables['services'][] = array('class'=>'cross', 'msg'=>$serviceName." Could not be added as a Service");
  146 + }
185 } 147 }
186 $errors = $this->getErrors(); 148 $errors = $this->getErrors();
187 if(!empty($errors)) 149 if(!empty($errors))
@@ -192,10 +154,12 @@ class services extends Step @@ -192,10 +154,12 @@ class services extends Step
192 public function javaChecks() { 154 public function javaChecks() {
193 $java = false; 155 $java = false;
194 $mods = get_loaded_extensions(); 156 $mods = get_loaded_extensions();
  157 + $mods = array_reverse($mods);
195 foreach ($mods as $k=>$v) { 158 foreach ($mods as $k=>$v) {
196 if($v == 'Zend Java Bridge') { 159 if($v == 'Zend Java Bridge') {
197 $java = true; 160 $java = true;
198 } 161 }
  162 + if($java) break;
199 } 163 }
200 if($java) { 164 if($java) {
201 $this->temp_variables['extensions']['class'] = 'tick'; 165 $this->temp_variables['extensions']['class'] = 'tick';
@@ -203,31 +167,35 @@ class services extends Step @@ -203,31 +167,35 @@ class services extends Step
203 } else { 167 } else {
204 $this->temp_variables['extensions']['class'] = 'cross'; 168 $this->temp_variables['extensions']['class'] = 'cross';
205 $this->temp_variables['extensions']['found'] = "Zend Java Bridge Required"; 169 $this->temp_variables['extensions']['found'] = "Zend Java Bridge Required";
  170 + $this->error[] = "Zend Java Bridge Required";
206 } 171 }
207 if($this->java == '') { 172 if($this->java == '') {
208 $this->temp_variables['version']['class'] = 'cross'; 173 $this->temp_variables['version']['class'] = 'cross';
209 $this->temp_variables['version']['found'] = "Java runtime environment required"; 174 $this->temp_variables['version']['found'] = "Java runtime environment required";
  175 + $this->error[] = "Java runtime environment required";
210 } else { 176 } else {
211 $this->temp_variables['java']['class'] = 'tick'; 177 $this->temp_variables['java']['class'] = 'tick';
212 $this->temp_variables['java']['found'] = "Java Runtime Installed"; 178 $this->temp_variables['java']['found'] = "Java Runtime Installed";
213 } 179 }
214 - if($java) {  
215 - $javaSystem = new Java('java.lang.System'); 180 + if($this->util->javaBridge()) { // Check if java bridge is functional
  181 + $javaSystem = new Java('java.lang.System');
216 $version = $javaSystem->getProperty('java.version'); 182 $version = $javaSystem->getProperty('java.version');
217 $ver = substr($version, 0, 3); 183 $ver = substr($version, 0, 3);
218 if($ver < $this->javaVersion) { 184 if($ver < $this->javaVersion) {
219 $this->temp_variables['version']['class'] = 'cross'; 185 $this->temp_variables['version']['class'] = 'cross';
220 $this->temp_variables['version']['found'] = "Requires Java 1.5+ to be installed"; 186 $this->temp_variables['version']['found'] = "Requires Java 1.5+ to be installed";
  187 + $this->error[] = "Requires Java 1.5+ to be installed";
221 } else { 188 } else {
222 $this->temp_variables['version']['class'] = 'tick'; 189 $this->temp_variables['version']['class'] = 'tick';
223 $this->temp_variables['version']['found'] = "Java Version 1.5+ Installed"; 190 $this->temp_variables['version']['found'] = "Java Version 1.5+ Installed";
224 } 191 }
225 } else { 192 } else {
226 - $this->temp_variables['version']['class'] = 'cross'; 193 + $this->temp_variables['version']['class'] = 'cross';
227 $this->temp_variables['version']['found'] = "Cannot detect Java system settings"; 194 $this->temp_variables['version']['found'] = "Cannot detect Java system settings";
  195 + $this->error[] = "Cannot detect Java system settings";
228 return false; 196 return false;
229 } 197 }
230 - 198 +
231 return true; 199 return true;
232 } 200 }
233 /** 201 /**