diff --git a/setup/wizard/installUtil.php b/setup/wizard/installUtil.php index a8b98ff..126ec1b 100644 --- a/setup/wizard/installUtil.php +++ b/setup/wizard/installUtil.php @@ -373,7 +373,6 @@ class InstallUtil { } return 'java'; -// return array('response'=>$response, 'java'=>'java'); } function tryJava2() { @@ -383,7 +382,6 @@ class InstallUtil { } return 'java'; -// return array('response'=>$response, 'java'=>'java'); } function tryJava3() { @@ -396,7 +394,6 @@ class InstallUtil { $match = preg_match('/bin/', $r); if($match) { return preg_replace('/java:/', '', $r); -// return array('response'=>$response, 'java'=>preg_replace('/java:/', '', $r)); } } } @@ -422,6 +419,26 @@ class InstallUtil { } /** + * Check if user entered location of PHP + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return mixed + */ + public function phpSpecified() { + if(isset($_POST['php'])) { + if($_POST['php'] != '') { + return $_POST['php']; + } else { + return false; + } + } else { + return false; + } + } + + /** * Determine the location of JAVA_HOME * * @author KnowledgeTree Team @@ -441,6 +458,30 @@ class InstallUtil { return $response; } + /** + * Determine the location of PHP + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return mixed + */ + function getPhp() { + $cmd = "whereis php"; + $response = $this->pexec($cmd); + if(is_array($response['out'])) { + $broke = explode(' ', $response['out'][0]); + foreach ($broke as $r) { + $match = preg_match('/bin/', $r); + if($match) { + return preg_replace('/php:/', '', $r); + } + } + } + + return ''; + } + /** * Portably execute a command on any of the supported platforms. * diff --git a/setup/wizard/lib/services/unixLucene.php b/setup/wizard/lib/services/unixLucene.php index f85d15e..b2fc53f 100644 --- a/setup/wizard/lib/services/unixLucene.php +++ b/setup/wizard/lib/services/unixLucene.php @@ -147,7 +147,12 @@ class unixLucene extends unixService { } public function install() { - $this->start(); + $status = $this->status(); + if($status == '') { + return $this->start(); + } else { + return $status; + } } public function status() { @@ -162,11 +167,11 @@ class unixLucene extends unixService { } } } else { - return 'STOPPED'; + return ''; } } - return 'STOPPED'; + return ''; } public function uninstall() { diff --git a/setup/wizard/lib/services/unixScheduler.php b/setup/wizard/lib/services/unixScheduler.php index 56ee981..f385ac3 100644 --- a/setup/wizard/lib/services/unixScheduler.php +++ b/setup/wizard/lib/services/unixScheduler.php @@ -108,7 +108,12 @@ class unixScheduler extends unixService { } function install() { - $this->start(); + $status = $this->status(); + if($status == '') { + return $this->start(); + } else { + return $status; + } } function uninstall() { @@ -133,7 +138,7 @@ class unixScheduler extends unixService { } } } else { - return 'STOPPED'; + return ''; } } diff --git a/setup/wizard/steps/complete.php b/setup/wizard/steps/complete.php index 2a159ea..84d0869 100644 --- a/setup/wizard/steps/complete.php +++ b/setup/wizard/steps/complete.php @@ -237,7 +237,7 @@ class complete extends Step { $className = OS.$serviceName; $service = new $className(); $service->load(); - if($service->status() == 'RUNNING') { + if($service->status() == 'RUNNING' || $service->status() == 'STARTED') { $this->temp_variables[$serviceName."Status"] = 'tick'; } else { $this->temp_variables[$serviceName."Status"] = 'cross_orange'; diff --git a/setup/wizard/steps/configuration.php b/setup/wizard/steps/configuration.php index dceb5be..d60cb3a 100644 --- a/setup/wizard/steps/configuration.php +++ b/setup/wizard/steps/configuration.php @@ -136,9 +136,15 @@ class configuration extends Step $this->setDetails(); return 'previous'; } else if($this->confirm()) { - return 'next'; + if($this->doRun()) { + return 'next'; + } + return 'error'; } else if($this->edit()) { $this->setDetails(); + if($this->doRun()) { + + } return 'landing'; } @@ -345,6 +351,7 @@ class configuration extends Step if($class['class'] != 'tick') { $this->temp_variables['paths_perms'] = $class['class']; + $this->done = false; } $dirs[$key] = array_merge($dirs[$key], $class); } diff --git a/setup/wizard/steps/services.php b/setup/wizard/steps/services.php index 9c20181..64e49e8 100644 --- a/setup/wizard/steps/services.php +++ b/setup/wizard/steps/services.php @@ -80,6 +80,24 @@ class services extends Step private $javaCheck = 'cross'; /** + * Flag if services are already Installed + * + * @author KnowledgeTree Team + * @access private + * @var mixed + */ + private $alreadyInstalled = false; + + /** + * PHP Installed + * + * @author KnowledgeTree Team + * @access private + * @var mixed + */ + private $phpCheck = 'cross_orange'; + + /** * Java Bridge Installed * * @author KnowledgeTree Team @@ -104,7 +122,7 @@ class services extends Step * @access public * @var boolean */ - protected $storeInSession = false; + protected $storeInSession = true; /** * List of variables to be loaded to template @@ -140,16 +158,16 @@ class services extends Step * @access public * @var mixed */ - private $javaExeError = false; + private $javaExeError = ''; /** - * Holds path error, if java is specified + * Holds path error, if php is specified * * @author KnowledgeTree Team * @access public * @var mixed */ - private $phpExeError = false; + private $phpExeError = ''; /** * Constructs services object * @@ -213,6 +231,7 @@ class services extends Step if($this->java != '') { // Java JRE Found $this->javaCheck = 'tick'; $this->javaInstalled(); + $this->temp_variables['java']['location'] = $this->java; } } @@ -225,24 +244,60 @@ class services extends Step * @return boolean */ private function doRun() { - $this->setPhpDir(); // Get php, if it exists - $this->java = $this->util->getJava(); // Get java, if it exists - $this->javaChecks(); // Run Pre Checks - $errors = $this->getErrors(); // Get errors - if(empty($errors)) { // Install Service if there is no errors - $this->installService(); - } else { // Services not installed - foreach ($this->getServices() as $serviceName) { - $this->temp_variables['services'][] = array('class'=>'cross_orange', 'msg'=>$serviceName." Could not be added as a Service"); + if($this->alreadyInstalled()) { + $this->alreadyInstalled = true; + $this->serviceCheck = 'tick'; + } else { + $this->php = $this->util->getPhp(); // Get java, if it exists + $this->java = $this->util->getJava(); // Get java, if it exists + $passedPhp = $this->phpChecks(); // Run Java Pre Checks + $passedJava = $this->javaChecks(); // Run Java Pre Checks + $errors = $this->getErrors(); // Get errors + if(empty($errors) && $passedJava && $passedPhp) { // Install Service if there is no errors + $this->installServices(); + } elseif ($passedPhp) { // Install Scheduler + $this->installService('Scheduler'); + } elseif ($passedJava) { // Install Lucene + $this->installService('Lucene'); + } else { // All Services not installed } - $this->serviceCheck = 'cross_orange'; - } + } + $this->checkServiceStatus(); $this->storeSilent(); // Store info needed for silent mode if(!empty($errors)) return false; return true; } + function checkServiceStatus() { + $serverDetails = $this->getServices(); + foreach ($serverDetails as $serviceName) { + $className = OS.$serviceName; + $service = new $className(); + $status = $this->serviceStatus($service); + if($status != 'STARTED') { + $this->temp_variables['services'][] = array('class'=>'cross_orange', 'msg'=>$service->getName()." Could not be added as a Service"); + $this->serviceCheck = 'cross_orange'; + } else { + $this->temp_variables['services'][] = array('class'=>'tick', 'msg'=>$service->getName()." has been added as a Service"); + } + } + } + + function alreadyInstalled() { + $installed = true; + $serverDetails = $this->getServices(); + foreach ($serverDetails as $serviceName) { + $className = OS.$serviceName; + $service = new $className(); + $status = $this->serviceStatus($service); + if($status != 'STARTED') { + return false; + } + } + return true; + } + /** * Do some basic checks to help the user overcome java problems * @@ -260,10 +315,36 @@ class services extends Step $this->disableExtension = true; // Disable the use of the php bridge extension return $this->detSettings(); // AutoDetect java settings } else { - return $this->useBridge(); // Use Bridge to get java settings + $auto = $this->useBridge(); // Use Bridge to get java settings + if($auto) { + return $auto; + } else { + $this->specifyJava(); // Ask for settings + } + return $auto; } } - + + private function specifyJava() { + $this->javaExeError = true; + } + + private function specifyPhp() { + $this->phpExeError = true; + } + + private function phpChecks() { + // TODO: Better detection + return true; + $this->setPhp(); + if($this->util->phpSpecified()) { + return $this->detPhpSettings(); + } else { + $this->specifyPhp();// Ask for settings + return false; + } + } + /** * Attempts to use user input and configure java settings * @@ -289,18 +370,41 @@ class services extends Step $this->javaVersionCorrect(); $this->javaInstalled(); $this->javaCheck = 'tick'; + return true; } } else { $this->javaVersionWarning(); $this->javaCheck = 'cross_orange'; - $this->javaExeError = "Incorrect path specified"; + $this->javaExeError = "Java : Incorrect path specified"; $this->error[] = "Requires Java 1.5+ to be installed"; return false; } } } + function detPhpSettings() { + // TODO: Better php handling + return true; + $phpExecutable = $this->util->phpSpecified();// Retrieve java bin + $cmd = "$phpExecutable -version > output/outPHP 2>&1 echo $!"; + $response = $this->util->pexec($cmd); + if(file_exists(OUTPUT_DIR.'outPHP')) { + $tmp = file_get_contents(OUTPUT_DIR.'outPHP'); + preg_match('/PHP/',$tmp, $matches); + if($matches) { + $this->phpCheck = 'tick'; + + return true; + } else { + $this->phpCheck = 'cross_orange'; + $this->phpExeError = "PHP : Incorrect path specified"; + $this->error[] = "PHP executable required"; + + return false; + } + } + } /** * Attempts to use bridge and configure java settings * @@ -329,6 +433,7 @@ class services extends Step return true; } } else { + $this->javaCheck = 'cross_orange'; $this->javaVersionWarning(); $this->zendBridgeWarning(); $this->warnings[] = "Zend Java Bridge Not Functional"; @@ -379,27 +484,36 @@ class services extends Step * * @author KnowledgeTree Team * @param none - * @access public + * @access private * @return boolean */ - public function installService() { + private function installServices() { foreach ($this->getServices() as $serviceName) { - $className = OS.$serviceName; - $service = new $className(); - $status = $this->serviceHelper($service); - if ($status) { - $this->temp_variables['services'][] = array('class'=>'tick', 'msg'=>$service->getName()." has been added as a Service"); - } else { - $this->temp_variables['services'][] = array('class'=>'cross_orange', 'msg'=>$service->getName()." Could not be added as a Service"); - $this->serviceCheck = 'cross_orange'; - } + $this->installService($serviceName); } return true; } + /** + * Installs services helper + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return boolean + */ + private function installService($serviceName) { + $className = OS.$serviceName; + $service = new $className(); + $status = $this->serviceHelper($service); + if (!$status) { + $this->serviceCheck = 'cross_orange'; + } + } + /** - * Executes services + * Installs services * * @author KnowledgeTree Team * @param object @@ -414,6 +528,20 @@ class services extends Step } /** + * Returns service status + * + * @author KnowledgeTree Team + * @param object + * @access private + * @return string + */ + private function serviceStatus($service) { + $service->load(); // Load Defaults + $statusCheck = OS."ServiceInstalled"; + return $this->$statusCheck($service); + } + + /** * Check if windows service installed * * @author KnowledgeTree Team @@ -424,7 +552,6 @@ class services extends Step public function windowsServiceInstalled($service) { $status = $service->status(); // Check if service has been installed if($status == '') { // Check service status - $this->error[] = $service->getName()." Could not be added as a Service"; return false; } return true; @@ -441,7 +568,6 @@ class services extends Step public function unixServiceInstalled($service) { $status = $service->status(); // Check if service has been installed if($status != 'STARTED') { // Check service status - $this->error[] = $service->getName()." Could not be added as a Service"; return false; } return true; @@ -460,9 +586,7 @@ class services extends Step $className = OS.$serviceName; $service = new $className(); $status = $this->serviceStart($service); - } - return true; } @@ -630,40 +754,28 @@ class services extends Step * @return void */ private function storeSilent() { - $this->temp_variables['javaExeError'] = $this->javaExeError; - $this->temp_variables['phpExeError'] = $this->phpExeError; - $this->temp_variables['javaCheck'] = $this->javaCheck; - $this->temp_variables['javaExtCheck'] = $this->javaExtCheck; - $this->temp_variables['serviceCheck'] = $this->serviceCheck; - $this->temp_variables['disableExtension'] = $this->disableExtension; + $this->temp_variables['alreadyInstalled'] = $this->alreadyInstalled; + $this->temp_variables['javaExeError'] = $this->javaExeError; + $this->temp_variables['javaCheck'] = $this->javaCheck; + $this->temp_variables['javaExtCheck'] = $this->javaExtCheck; + $this->temp_variables['phpCheck'] = 'tick';//$this->phpCheck; + $this->temp_variables['phpExeError'] = '';//$this->phpExeError; + $this->temp_variables['serviceCheck'] = $this->serviceCheck; + $this->temp_variables['disableExtension'] = $this->disableExtension; } - - private function setPhpDir($phpdir = '') { - if(PHP_DIR != '') { + + private function setPhp() { + if($this->php != '') { // PHP Found + $this->phpCheck = 'tick'; + } elseif (PHP_DIR != '') { // Use System Defined Settings $this->php = PHP_DIR; - } - if($phpdir == '') { - $cmd = "whereis php"; - $response = $this->util->pexec($cmd); - if(is_array($response['out'])) { - $broke = explode(' ', $response['out'][0]); - foreach ($broke as $r) { - $match = preg_match('/bin/', $r); - if($match) { - $this->php = preg_replace('/php:/', '', $r); - return true; - } - } - } } else { - $this->php = $phpdir; - } - if($this->php == '') { - $this->phpExeError = "Incorrect path specified"; + } - } + $this->temp_variables['php']['location'] = $this->php; + } - private function getPhpDir() { + public function getPhpDir() { return $this->php; } } diff --git a/setup/wizard/templates/services.tpl b/setup/wizard/templates/services.tpl index 20b7e96..70b8a23 100644 --- a/setup/wizard/templates/services.tpl +++ b/setup/wizard/templates/services.tpl @@ -11,20 +11,29 @@ if($errors || $warnings){ . 'Click Here for help on overcoming service issues
'; } ?> - + + Specify the location of your Java executable
- +'/>     - + + + +
Specify the location of your PHP executable
- + + '/> + + '/> - +    + + +
- - +

     "; ?>Java Check

@@ -55,6 +64,11 @@ A PHP Java Bridge is required for KnowledgeTree to perform at an optimal level. + +

+All services are already installed. +

+

     "; ?>Services Check

Show Details