diff --git a/lib/api/ktcmis/services/CMISObjectService.inc.php b/lib/api/ktcmis/services/CMISObjectService.inc.php index 70ace1c..39d8d90 100644 --- a/lib/api/ktcmis/services/CMISObjectService.inc.php +++ b/lib/api/ktcmis/services/CMISObjectService.inc.php @@ -109,7 +109,7 @@ class CMISObjectService { } // if content stream is required and no content stream is supplied, throw a ConstraintViolationException - if (($typeDefinition['attributes']['contentStreamAllowed'] == 'required') && empty($contentStream)) + if (($typeDefinition['attributes']['contentStreamAllowed'] == 'required') && is_null($contentStream)) { throw new ConstraintViolationException('This repository requires a content stream for document creation. ' . 'Refusing to create an empty document'); @@ -152,7 +152,7 @@ class CMISObjectService { // create the content stream from the supplied data // NOTE since the repository is set to require a content stream and we don't currently have another way to get the document data // this check isn't strictly necessary; however it is needed for a repository which does not support content streams - if (!empty($contentStream)) + if (!is_null($contentStream)) { // TODO consider checking whether content is encoded (currently we expect encoded) // TODO choose between this and the alternative decode function (see CMISUtil class) @@ -283,7 +283,7 @@ class CMISObjectService { // then we may have something else to do here; // for now we just throw a general RuntimeException, since we should not // actually reach this code unless something is wrong; this may be removed or replaced later - throw new RuntimeException('Cannot create empty document'); + throw new RuntimeException('Cannot create document without a content stream'); } return $objectId; diff --git a/setup/wizard/batches/lucene_install.bat b/setup/wizard/batches/lucene_install.bat new file mode 100644 index 0000000..2d8216b --- /dev/null +++ b/setup/wizard/batches/lucene_install.bat @@ -0,0 +1 @@ +"C:\Program Files\Zend\Apache2\htdocs\knowledgetree\bin\luceneserver\KTLuceneService.exe" -install "KTLuceneTest" "C:\Program Files\Java\jre6\bin\client\jvm.dll" -Djava.class.path="C:\Program Files\Zend\Apache2\htdocs\knowledgetree\bin\luceneserver\ktlucene.jar" -start com.knowledgetree.lucene.KTLuceneServer -out "C:\Program Files\Zend\Apache2\htdocs\knowledgetree\var\log\lucene-out.txt" -err "C:\Program Files\Zend\Apache2\htdocs\knowledgetree\var\log\lucene-err.txt" -current "C:\Program Files\Zend\Apache2\htdocs\knowledgetree\bin\luceneserver" -auto \ No newline at end of file diff --git a/setup/wizard/batches/lucene_start.bat b/setup/wizard/batches/lucene_start.bat new file mode 100644 index 0000000..3cc5343 --- /dev/null +++ b/setup/wizard/batches/lucene_start.bat @@ -0,0 +1 @@ +sc start KTLuceneTest \ No newline at end of file diff --git a/setup/wizard/batches/lucene_uninstall.bat b/setup/wizard/batches/lucene_uninstall.bat new file mode 100644 index 0000000..028e796 --- /dev/null +++ b/setup/wizard/batches/lucene_uninstall.bat @@ -0,0 +1 @@ +sc delete KTLuceneTest \ No newline at end of file diff --git a/setup/wizard/batches/scheduler_install.bat b/setup/wizard/batches/scheduler_install.bat new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/setup/wizard/batches/scheduler_install.bat diff --git a/setup/wizard/batches/scheduler_start.bat b/setup/wizard/batches/scheduler_start.bat new file mode 100644 index 0000000..fed9906 --- /dev/null +++ b/setup/wizard/batches/scheduler_start.bat @@ -0,0 +1 @@ +sc start KTSchedulerTest \ No newline at end of file diff --git a/setup/wizard/batches/scheduler_uninstall.bat b/setup/wizard/batches/scheduler_uninstall.bat new file mode 100644 index 0000000..1058327 --- /dev/null +++ b/setup/wizard/batches/scheduler_uninstall.bat @@ -0,0 +1 @@ +sc delete KTSchedulerTest \ No newline at end of file diff --git a/setup/wizard/config/config.xml b/setup/wizard/config/config.xml index 5e3df31..498809c 100755 --- a/setup/wizard/config/config.xml +++ b/setup/wizard/config/config.xml @@ -10,10 +10,10 @@ welcome + license dependencies services configuration - license database install complete diff --git a/setup/wizard/install b/setup/wizard/install new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/setup/wizard/install diff --git a/setup/wizard/installUtil.php b/setup/wizard/installUtil.php index 1189e83..1609a55 100755 --- a/setup/wizard/installUtil.php +++ b/setup/wizard/installUtil.php @@ -77,21 +77,21 @@ class InstallUtil { if(!$this->_checkPermission(WIZARD_DIR)) { return 'wizard'; } - if(!$this->_checkPermission(CONF_DIR)) { - return 'wizard'; - } - if(!$this->_checkPermission(SQL_DIR)) { - return 'wizard'; - } - if(!$this->_checkPermission(RES_DIR)) { - return 'wizard'; - } - if(!$this->_checkPermission(STEP_DIR)) { - return 'wizard'; - } - if(!$this->_checkPermission(TEMP_DIR)) { - return 'wizard'; - } +// if(!$this->_checkPermission(CONF_DIR)) { +// return 'wizard'; +// } +// if(!$this->_checkPermission(SQL_DIR)) { +// return 'wizard'; +// } +// if(!$this->_checkPermission(RES_DIR)) { +// return 'wizard'; +// } +// if(!$this->_checkPermission(STEP_DIR)) { +// return 'wizard'; +// } +// if(!$this->_checkPermission(TEMP_DIR)) { +// return 'wizard'; +// } return true; } @@ -339,6 +339,7 @@ class InstallUtil { if(WINDOWS_OS) { $sCmd = 'call '.$sCmd; } +// echo "===".$sCmd."===
"; exec($sCmd, $aOutput, $iRet); $aRet['ret'] = $iRet; $aRet['out'] = $aOutput; diff --git a/setup/wizard/installWizard.php b/setup/wizard/installWizard.php index fe74219..6337462 100755 --- a/setup/wizard/installWizard.php +++ b/setup/wizard/installWizard.php @@ -44,9 +44,9 @@ include("path.php"); // Paths function __autoload($class) { // Attempt and autoload classes $class = strtolower(substr($class,0,1)).substr($class,1); // Linux Systems. if(file_exists(WIZARD_DIR."$class.php")) { - require(WIZARD_DIR."$class.php"); + require_once(WIZARD_DIR."$class.php"); } elseif (file_exists(STEP_DIR."$class.php")) { - require(STEP_DIR."$class.php"); + require_once(STEP_DIR."$class.php"); } else { return false; } @@ -209,7 +209,7 @@ class InstallWizard { if($res === true) return $res; switch ($res) { case "wizard": - return 'Installer directory is not writable
'; + return 'Installer directory is not writable (Installation/setup/wizard/)
'; break; case "/": return 'System root is not writable
'; diff --git a/setup/wizard/path.php b/setup/wizard/path.php index 8cc4723..2761099 100755 --- a/setup/wizard/path.php +++ b/setup/wizard/path.php @@ -43,26 +43,49 @@ if (substr(php_uname(), 0, 7) == "Windows"){ define('WINDOWS_OS', true); define('UNIX_OS', false); + define('OS', 'windows'); } else { define('WINDOWS_OS', false); define('UNIX_OS', true); + define('OS', 'unix'); } if(WINDOWS_OS) { define('DS', '\\'); } else { define('DS', '/'); } - define('WIZARD_DIR', dirname(__FILE__).DS); - define('SYSTEM_DIR', WIZARD_DIR."..".DS."..".DS); - define('SYS_BIN_DIR', WIZARD_DIR."..".DS."..".DS."bin".DS); - define('SYS_LOG_DIR', WIZARD_DIR."..".DS."..".DS."var".DS."log".DS); + $wizard_dir = realpath(dirname(__FILE__)); + $xdir = explode(DS, $wizard_dir); + array_pop($xdir); + array_pop($xdir); + $sys = ''; + foreach ($xdir as $k=>$v) { + $sys .= $v.DS; + } + + define('WIZARD_DIR', $wizard_dir.DS); + define('SYSTEM_DIR', $sys); + define('SYS_BIN_DIR', $sys."bin".DS); + define('SYS_LOG_DIR', $sys."var".DS."log".DS); define('SQL_DIR', WIZARD_DIR.DS."sql".DS); define('SQL_UPGRADE_DIR', SQL_DIR.DS."upgrades".DS); define('CONF_DIR', WIZARD_DIR.DS."config".DS); define('RES_DIR', WIZARD_DIR.DS."resources".DS); define('STEP_DIR', WIZARD_DIR.DS."steps".DS); define('TEMP_DIR', WIZARD_DIR.DS."templates".DS); - - - + preg_match('/Zend/', $sys, $matches);// Install Type + if($matches) { + $sysdir = explode(DS, $sys); + array_pop($sysdir); + array_pop($sysdir); + array_pop($sysdir); + array_pop($sysdir); + $zendsys = ''; + foreach ($sysdir as $k=>$v) { + $zendsys .= $v.DS; + } + define('INSTALL_TYPE', 'Zend'); + define('PHP_DIR', $zendsys."ZendServer".DS."bin".DS); + } + date_default_timezone_set('Africa/Johannesburg'); ?> diff --git a/setup/wizard/service.php b/setup/wizard/service.php index f096906..af5e578 100644 --- a/setup/wizard/service.php +++ b/setup/wizard/service.php @@ -41,29 +41,29 @@ */ class Service { - private static $on = 1; - private static $off = 0; - public $pid; public $status; + public $name; + + public function getName() { + return $this->name; + } + + public function load() { + + } public function start() { -// $this->status = $this->on; } public function stop() { - -// $this->status = $this->off; } public function install() { - } public function restart() { -// $this->status = $this->off; - -// $this->status = $this->on; + } public function uninstall() { @@ -71,7 +71,16 @@ class Service { } public function status() { -// return $this->status; +// [SC] DeleteService SUCCESS +//The KTLuceneTest automatic service was successfully installed + } + + public function pause() { + + } + + public function cont() { + } } ?> \ No newline at end of file diff --git a/setup/wizard/steps/configuration.php b/setup/wizard/steps/configuration.php index 3a48a70..371d1aa 100755 --- a/setup/wizard/steps/configuration.php +++ b/setup/wizard/steps/configuration.php @@ -42,6 +42,14 @@ class configuration extends Step { + /** + * Database object + * + * @author KnowledgeTree Team + * @access private + * @var array + */ + private $_dbhandler = null; private $host; private $port; private $root_url; @@ -74,6 +82,7 @@ class configuration extends Step */ public function __construct() { + $this->_dbhandler = new dbUtil(); $this->done = true; } @@ -184,13 +193,12 @@ class configuration extends Step } // initialise the db connection - $db = new dbUtil(); // retrieve database information from session $dbconf = $this->getDataFromSession("database"); // make db connection - $db->dbUtil($dbconf['dhost'], $dbconf['duname'], $dbconf['dpassword'], $dbconf['dname']); + $this->_dbhandler->dbUtil($dbconf['dhost'], $dbconf['duname'], $dbconf['dpassword'], $dbconf['dname']); // add db config to server variables $server = $this->registerDBConfig($server, $dbconf); @@ -218,7 +226,7 @@ class configuration extends Step $setting = mysql_real_escape_string($item['setting']); $sql = "UPDATE {$table} SET value = '{$value}' WHERE item = '{$setting}'"; - $db->query($sql); + $this->_dbhandler->query($sql); break; } } @@ -233,7 +241,7 @@ class configuration extends Step $setting = mysql_real_escape_string($item['setting']); $sql = "UPDATE {$table} SET value = '{$value}' WHERE item = '{$setting}'"; - $db->query($sql); + $this->_dbhandler->query($sql); } // write out the config.ini file @@ -242,7 +250,7 @@ class configuration extends Step } // close the database connection - $db->close(); + $this->_dbhandler->close(); } /** diff --git a/setup/wizard/steps/database.php b/setup/wizard/steps/database.php index 7e9d2f2..f97d464 100755 --- a/setup/wizard/steps/database.php +++ b/setup/wizard/steps/database.php @@ -43,7 +43,7 @@ class database extends Step { /** - * Database type + * Database object * * @author KnowledgeTree Team * @access private diff --git a/setup/wizard/steps/dependencies.php b/setup/wizard/steps/dependencies.php index 4a4d4a5..06dd298 100755 --- a/setup/wizard/steps/dependencies.php +++ b/setup/wizard/steps/dependencies.php @@ -300,18 +300,33 @@ class dependencies extends Step */ private function getRequiredExtensions() { - return array( - array('extension' => 'fileinfo', 'required' => 'no', 'name' => 'Fileinfo', 'details' => 'Provides better file identification support - not necessary if you use file extensions.'), - array('extension' => 'iconv', 'required' => 'no', 'name' => 'IconV', 'details' => 'Used for conversion between character sets.'), - array('extension' => 'mysql', 'required' => 'yes', 'name' => 'MySQL', 'details' => 'Used for accessing a MySQL database.'), - array('extension' => 'curl', 'required' => 'yes', 'name' => 'cURL', 'details' => 'Allows the connection and communication between different servers types using various protocols.'), - array('extension' => 'xmlrpc', 'required' => 'yes', 'name' => 'XMLRPC', 'details' => 'Used with XML-RPC servers and clients.'), - array('extension' => 'win32', 'required' => 'no', 'name' => 'Win32', 'details' => 'Allows control of Microsoft Windows services.'), - array('extension' => 'mbstring', 'required' => 'no', 'name' => 'Multi Byte Strings', 'details' => 'Used in the manipulation of multi-byte strings.'), - array('extension' => 'ldap', 'required' => 'no', 'name' => 'LDAP', 'details' => 'Used to access LDAP directory servers.'), - array('extension' => 'json', 'required' => 'yes', 'name' => 'JSON', 'details' => 'Implements the javascript object notation (json) data-interchange format.'), - array('extension' => 'openssl', 'required' => 'no', 'name' => 'Open SSL', 'details' => 'Used for the generation and verification of signatures and the encrypting and decrypting of data'), - ); + // TODO: Better + if(WINDOWS_OS) { + return array( + array('extension' => 'fileinfo', 'required' => 'no', 'name' => 'Fileinfo', 'details' => 'Provides better file identification support - not necessary if you use file extensions.'), + array('extension' => 'iconv', 'required' => 'no', 'name' => 'IconV', 'details' => 'Used for conversion between character sets.'), + array('extension' => 'mysql', 'required' => 'yes', 'name' => 'MySQL', 'details' => 'Used for accessing a MySQL database.'), + array('extension' => 'curl', 'required' => 'yes', 'name' => 'cURL', 'details' => 'Allows the connection and communication between different servers types using various protocols.'), + array('extension' => 'xmlrpc', 'required' => 'yes', 'name' => 'XMLRPC', 'details' => 'Used with XML-RPC servers and clients.'), + array('extension' => 'win32', 'required' => 'no', 'name' => 'Win32', 'details' => 'Allows control of Microsoft Windows services.'), + array('extension' => 'mbstring', 'required' => 'no', 'name' => 'Multi Byte Strings', 'details' => 'Used in the manipulation of multi-byte strings.'), + array('extension' => 'ldap', 'required' => 'no', 'name' => 'LDAP', 'details' => 'Used to access LDAP directory servers.'), + array('extension' => 'json', 'required' => 'yes', 'name' => 'JSON', 'details' => 'Implements the javascript object notation (json) data-interchange format.'), + array('extension' => 'openssl', 'required' => 'no', 'name' => 'Open SSL', 'details' => 'Used for the generation and verification of signatures and the encrypting and decrypting of data'), + ); + } else { + return array( + array('extension' => 'fileinfo', 'required' => 'no', 'name' => 'Fileinfo', 'details' => 'Provides better file identification support - not necessary if you use file extensions.'), + array('extension' => 'iconv', 'required' => 'no', 'name' => 'IconV', 'details' => 'Used for conversion between character sets.'), + array('extension' => 'mysql', 'required' => 'yes', 'name' => 'MySQL', 'details' => 'Used for accessing a MySQL database.'), + array('extension' => 'curl', 'required' => 'yes', 'name' => 'cURL', 'details' => 'Allows the connection and communication between different servers types using various protocols.'), + array('extension' => 'xmlrpc', 'required' => 'yes', 'name' => 'XMLRPC', 'details' => 'Used with XML-RPC servers and clients.'), + array('extension' => 'mbstring', 'required' => 'no', 'name' => 'Multi Byte Strings', 'details' => 'Used in the manipulation of multi-byte strings.'), + array('extension' => 'ldap', 'required' => 'no', 'name' => 'LDAP', 'details' => 'Used to access LDAP directory servers.'), + array('extension' => 'json', 'required' => 'yes', 'name' => 'JSON', 'details' => 'Implements the javascript object notation (json) data-interchange format.'), + array('extension' => 'openssl', 'required' => 'no', 'name' => 'Open SSL', 'details' => 'Used for the generation and verification of signatures and the encrypting and decrypting of data'), + ); + } } /** diff --git a/setup/wizard/steps/services.php b/setup/wizard/steps/services.php index 85bc961..c1d6fa3 100755 --- a/setup/wizard/steps/services.php +++ b/setup/wizard/steps/services.php @@ -40,9 +40,6 @@ * @version Version 0.1 */ - -//require_once('../../thirdparty/xmlrpc-2.2/xmlrpc.inc'); - class services extends Step { /** @@ -63,7 +60,11 @@ class services extends Step */ protected $runInstall = true; + protected $services = array('Lucene', 'Scheduler'); + + protected $java; + protected $util; /** * Constructs database object * @@ -72,7 +73,51 @@ class services extends Step * @param none */ public function __construct() { - + $this->util = new InstallUtil(); + $this->setJava(); + } + + function tryJava1() { + $response = $this->util->pexec("java"); // Java Runtime Check + if(empty($response['out'])) { + return false; + } + $this->java = 'java'; + return true; + } + + function tryJava2() { + $response = $this->util->pexec("java -version"); // Java Runtime Check + if(empty($response['out'])) { + return false; + } + $this->java = 'java'; + return true; + } + + function tryJava3() { + $response = $this->util->pexec("whereis java"); // Java Runtime Check + if(empty($response['out'])) { + return false; + } + $broke = explode(' ', $response['out'][0]); + foreach ($broke as $r) { + $match = preg_match('/bin/', $r); + if($match) { + $this->java = preg_replace('/java:/', '', $r); + return true; + } + } + } + + function setJava() { + $response = $this->tryJava1(); + if(!$response) { + $response = $this->tryJava2(); + if(!$response) { + $response = $this->tryJava3(); + } + } } /** @@ -101,14 +146,12 @@ class services extends Step } private function doRun() { - $util = new InstallUtil(); -// $response = $util->pexec("java"); // Java Runtime Check - $response = $util->pexec("java -version"); // Java Runtime Check - if(empty($response['out'])) { - $this->error[] = "Java runtime environment required"; -// return false; + if($this->java == '') { + $this->error[] = "Java runtime environment required"; + return false; } - $this->installStep(); + + $this->installService(); return true; } @@ -121,23 +164,61 @@ class services extends Step * @access public * @return void */ - public function installStep() { - $util = new InstallUtil(); - if(WINDOWS_OS) { // Add service to tasks list if needed - $lucene = new windowsLucene(); - // Start service - } else { // Unix based systems - $lucene = new unixLucene(); - $lucene->load(); + public function installService() { + foreach ($this->services as $serviceName) { + $className = OS.$serviceName; + $service = new $className(); + $status = $this->serviceHelper($service); } - - - + return true; } + public function serviceHelper($service) { + $service->load(); // Load Defaults + $response = $service->uninstall(); // Uninstall service if it exists + $response = $service->install(); // Install service + $statusCheck = OS."Status"; + return $this->$statusCheck($service); + } + + function serviceStart($service) { + if(OS == 'windows') { + $service->load(); // Load Defaults + $service->start(); // Start Service + $this->windowsStatus($service); // Get service status + } + } + + function windowsStatus($service) { + $status = $service->status(); // Check if service has been installed + if($status != 'STOPPED') { // Check service status + $this->error[] = $service->getName()." Could not be added as a Service"; + return false; + } + return true; + } + + function unixStatus($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; + } + + function installStep() { + foreach ($this->services as $serviceName) { + $className = OS.$serviceName; + $service = new $className(); + $status = $this->serviceStart($service); + } + + return true; + } /** * Returns database errors * diff --git a/setup/wizard/template.php b/setup/wizard/template.php index 0d79d7a..00dc10a 100755 --- a/setup/wizard/template.php +++ b/setup/wizard/template.php @@ -75,7 +75,10 @@ class Template */ public function set($name, $value) { - if(is_a($value, 'Template')) { + //if(is_a($value, 'Template')) { + $class = 'Template'; + $isA = $value instanceof $class; + if($isA) { $value = $value->fetch(); } $this->template_vars[$name] = $value; diff --git a/setup/wizard/unixAgent.php b/setup/wizard/unixAgent.php new file mode 100644 index 0000000..88020ef --- /dev/null +++ b/setup/wizard/unixAgent.php @@ -0,0 +1,66 @@ +. +* +* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, +* California 94120-7775, or email info@knowledgetree.com. +* +* The interactive user interfaces in modified source and object code versions +* of this program must display Appropriate Legal Notices, as required under +* Section 5 of the GNU General Public License version 3. +* +* In accordance with Section 7(b) of the GNU General Public License version 3, +* these Appropriate Legal Notices must retain the display of the "Powered by +* KnowledgeTree" logo and retain the original copyright notice. If the display of the +* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices +* must display the words "Powered by KnowledgeTree" and retain the original +* copyright notice. +* +* @copyright 2008-2009, KnowledgeTree Inc. +* @license GNU General Public License version 3 +* @author KnowledgeTree Team +* @package Installer +* @version Version 0.1 +*/ + +class unixLucene extends Service { + + + public function __construct() { + } + + function load() { + + } + + public function stop() { + + } + + public function install() { + + } + + public function start() { + + } + +} +?> \ No newline at end of file diff --git a/setup/wizard/unixLucene.php b/setup/wizard/unixLucene.php index 9e7ef53..7f0adfa 100644 --- a/setup/wizard/unixLucene.php +++ b/setup/wizard/unixLucene.php @@ -40,18 +40,17 @@ * @version Version 0.1 */ -define('LUCENE_SOURCE_DIR', SYSTEM_DIR."bin".DS."luceneserver".DS); -define('LUCENE_SOURCE_FILE', SYSTEM_DIR."bin".DS."luceneserver".DS."ktlucene.jar"); -require_once("service.php"); - class unixLucene extends Service { - private $name; -// private $javaBin; -// private $javaSystem; -// protected $lucene_pid_file=""; -// protected $lucene_dir=""; -// protected $lucene_message=""; - protected $lucene_options = " -Xms512M -Xmx512M -jar "; + public $name; + public $phpDir; + private $shutdownScript; + protected $indexerDir; + protected $lucenePidFile; + protected $luceneDir; + protected $luceneSource; + protected $luceneSourceLoc; + protected $javaXms; + protected $javaXmx; private $util = null; public function __construct() { @@ -60,168 +59,166 @@ class unixLucene extends Service { function load() { $this->name = "KTLuceneTest"; $this->util = new InstallUtil(); -// $this->javaSystem = new Java('java.lang.System'); -// $this->setJavaBin($this->javaSystem->getProperty('java.home').DS."bin"); + $this->setLuceneDir(SYSTEM_DIR."bin".DS."luceneserver".DS); + $this->setIndexerDir(SYSTEM_DIR."search2".DS."indexing".DS."bin".DS); + $this->setLucenePidFile("lucene_test.pid"); + $this->setJavaXms(512); + $this->setJavaXmx(512); + $this->setLuceneSource("ktlucene.jar"); + $this->setLuceneSourceLoc("ktlucene.jar"); + $this->setPhpDir(); + $this->setShutdownScript("shutdown.php"); + } + + public function setIndexerDir($indexerDir) { + $this->indexerDir = $indexerDir; + } + + private function getIndexerDir() { + return $this->indexerDir; + } + + private function setShutdownScript($shutdownScript) { + $this->shutdownScript = $shutdownScript; + } + + public function getShutdownScript() { + return $this->shutdownScript; + } + + private function setPhpDir($phpdir = '') { + 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->phpDir = preg_replace('/php:/', '', $r); + } + } + } +// echo $this->phpDir; +// die; + return ; + } else { + $this->phpDir = $phpdir; + } + } + + public function getPhpDir() { + return $this->phpDir; + } + + private function setLucenePidFile($lucenePidFile) { + $this->lucenePidFile = $lucenePidFile; + } + + private function getLucenePidFile() { + return $this->lucenePidFile; + } + + private function setLuceneDir($luceneDir) { + $this->luceneDir = $luceneDir; + } + + public function getLuceneDir() { + return $this->luceneDir; + } + + private function setJavaXms($javaXms) { + $this->javaXms = "-Xms$javaXms"; + } + + public function getJavaXms() { + return $this->javaXms; + } + + private function setJavaXmx($javaXmx) { + $this->javaXmx = "-Xmx$javaXmx"; + } + + public function getJavaXmx() { + return $this->javaXmx; + } + + private function setLuceneSource($luceneSource) { + $this->luceneSource = $luceneSource; + } + + public function getLuceneSource() { + return $this->luceneSource; } - private function setJavaBin($javaBin) { - $this->javaBin = $javaBin; + private function setLuceneSourceLoc($luceneSourceLoc) { + $this->luceneSourceLoc = $this->getLuceneDir().$luceneSourceLoc; } - public function getJavaBin() { - return $this->javaBin; + public function getLuceneSourceLoc() { + return $this->luceneSourceLoc; } - // Load default settings -// public function load() { -// $this->util = new InstallUtil(); -// $this->lucene_dir = SYSTEM_DIR."bin".DS."luceneserver".DS; -// $this->lucene_pid_file = SYSTEM_DIR."bin".DS."luceneserver".DS."lucene.pid"; -// $this->lucene_pid = ''; -// } + public function getJavaOptions() { + return " {$this->getJavaXmx()} {$this->getJavaXmx()} -jar "; + } - // Stop lucene public function stop() { - // TODO:Still need to figure out xmlrpc shutdown() - $cmd = "pkill -f lucene
"; - $response = $util->pexec($cmd); - echo 'Stop lucene'; + // TODO: Breaks things + if($this->getPhpDir() != "") { +// $cmd = $this->getPhpDir()." ".$this->getIndexerDir().$this->getShutdownScript()." positive &> ".SYS_LOG_DIR."dmsctl.log"; + } else { + $cmd = "pkill -f ".$this->getLuceneSource(); + } + $state = $this->status(); + if($state == 'STARTED') { + $cmd = "pkill -f ".$this->getLuceneSource(); + $response = $this->util->pexec($cmd); + return $response; + } + } public function install() { - + $state = $this->status(); +// die; + if($state != 'STARTED') { + $cmd = "cd ".$this->getLuceneDir()."; "; + $cmd .= "nohup java -jar ".$this->getLuceneSource()." &> ".SYS_LOG_DIR."lucene.log &"; + $response = $this->util->pexec($cmd); + return $response; + } elseif ($state == 'STOPPED') { + // start her up + + } } - // Start lucene - public function start() { - // TODO:A shot in the dark here - $this->util = new InstallUtil(); - $cmd = "nohup java".$this->lucene_options.LUCENE_SOURCE_FILE." &> ".SYS_LOG_DIR."lucene.log"; + public function status() { + $cmd = "ps ax | grep ".$this->getLuceneSource()." | awk {'print $1'}"; +// echo $cmd; $response = $this->util->pexec($cmd); - $this->status = $this->on; - echo 'Start lucene'; +// var_dump($response); + if(is_array($response['out'])) { + if(count($response['out']) > 1) { +// var_dump($response['out']); + return 'STARTED'; + } else { + return 'STOPPED'; + } + } + + return 'STOPPED'; } + public function uninstall() { + $this->stop(); + } - public function _start_lucene() { - if($this->is_lucene_running()) { // Is service running - echo 'Already Running
'; - } else { - // Get to - //echo 'Install service'; - $this->is_lucene_running(); - //nohup $LUCENE &> $INSTALL_PATH/var/log/dmsctl.log & - - } - -/* - is_lucene_running - RUNNING=$? - - if [ $RUNNING -eq 1 ]; then - echo "$0 $ARG: lucene (pid $LUCENE_PID) already running" - else - cd $INSTALL_PATH/knowledgeTree/bin/luceneserver - nohup $LUCENE &> $INSTALL_PATH/var/log/dmsctl.log & - if [ $? -eq 0 ]; then - echo "$0 $ARG: lucene started" - ps ax | grep ktlucene.jar | awk {'print $1'} > $LUCENE_PIDFILE - sleep 2 - else - echo "$0 $ARG: lucene could not be started" - ERROR=3 - fi - cd $INSTALL_PATH -fi -*/ - } - - public function is_lucene_running() { - - $pid = $this->get_lucene_pid(); - if($this->is_service_running($pid)) { - echo 'Service is running'; - } else { - - } - -/* is_lucene_running() { - get_lucene_pid - is_service_running $LUCENE_PID - RUNNING=$? - if [ $RUNNING -eq 0 ]; then - LUCENE_STATUS="lucene not running" - else - LUCENE_STATUS="lucene already running" - fi - return $RUNNING*/ - } - - public function is_service_running($pid) { - $cmd = "kill -0 $pid 2>/dev/null"; - $response = $this->util->pexec($cmd); - - /* -is_service_running() { - PID=$1 - if [ "x$PID" != "x" ] && kill -0 $PID 2>/dev/null ; then - RUNNING=1 - else - RUNNING=0 - fi - return $RUNNING -} -*/ - } - - public function get_lucene_pid() { - // TODO: PID FILE -/*get_lucene_pid() { - get_pid $LUCENE_PIDFILE - if [ ! $PID ]; then - return - fi - if [ $PID -gt 0 ]; then - LUCENE_PID=$PID - fi -}*/ - } - - public function get_pid() { - -/*get_pid() { - PID="" - PIDFILE=$1 - # check for pidfile - if [ -f $PIDFILE ] ; then - exec 6<&0 - exec < $PIDFILE - read pid - PID=$pid - exec 0<&6 6<&- - fi -}*/ - } - - function shutdown() - { + // Start lucene + public function start() { - $function=new xmlrpcmsg('control.shutdown',array( - php_xmlrpc_encode((string) $this->ktid), - php_xmlrpc_encode((string) $this->authToken))); - - $result=&$this->client->send($function); - if($result->faultCode()) - { - $this->error($result, 'shutdown'); - return false; - } - return true; - } + } + + } - -//$luc = new Lucene(); -//$luc->load(); -//$luc->start(); -//$luc->stop(); ?> \ No newline at end of file diff --git a/setup/wizard/unixScheduler.php b/setup/wizard/unixScheduler.php new file mode 100644 index 0000000..4cb0602 --- /dev/null +++ b/setup/wizard/unixScheduler.php @@ -0,0 +1,135 @@ +. +* +* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, +* California 94120-7775, or email info@knowledgetree.com. +* +* The interactive user interfaces in modified source and object code versions +* of this program must display Appropriate Legal Notices, as required under +* Section 5 of the GNU General Public License version 3. +* +* In accordance with Section 7(b) of the GNU General Public License version 3, +* these Appropriate Legal Notices must retain the display of the "Powered by +* KnowledgeTree" logo and retain the original copyright notice. If the display of the +* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices +* must display the words "Powered by KnowledgeTree" and retain the original +* copyright notice. +* +* @copyright 2008-2009, KnowledgeTree Inc. +* @license GNU General Public License version 3 +* @author KnowledgeTree Team +* @package Installer +* @version Version 0.1 +*/ + +class unixScheduler extends Service { + public $name; + public $phpDir; + protected $schedulerPidFile; + protected $schedulerDir; + protected $schedulerSource; + protected $schedulerSourceLoc; + private $util = null; + + public function __construct() { + } + + function load() { + $this->name = "KTSchedulerTest"; + $this->util = new InstallUtil(); + $this->setSchedulerDir(SYSTEM_DIR."bin".DS); + $this->setSchedulerSource('schedulerTask.sh'); + $this->setSchedulerSourceLoc('schedulerTask.sh'); + $this->setSchedulerPidFile("scheduler_test.pid"); + } + + private function setSchedulerPidFile($schedulerPidFile) { + $this->schedulerPidFile = $schedulerPidFile; + } + + private function getSchedulerPidFile() { + return $this->schedulerPidFile; + } + + function setSchedulerDir($schedulerDir) { + $this->schedulerDir = $schedulerDir; + } + + function getSchedulerDir() { + return $this->schedulerDir; + } + + function setSchedulerSource($schedulerSource) { + $this->schedulerSource = $schedulerSource; + } + + function getSchedulerSource() { + return $this->schedulerSource; + } + + function setSchedulerSourceLoc($schedulerSourceLoc) { + $this->schedulerSourceLoc = $this->getSchedulerDir().$schedulerSourceLoc; + } + + function getSchedulerSourceLoc() { + if(file_exists($this->schedulerSourceLoc)) { + return $this->schedulerSourceLoc; + } +// die('File Expected Error'); + return false; + } + + function install() { + $source = $this->getSchedulerSourceLoc(); + if($source) { + $cmd = "nohup ".$source." &> ".SYS_LOG_DIR."dmsctl.log"; + $response = $this->util->pexec($cmd); + return $response; + } + + return false; + } + + function uninstall() { + $this->stop(); + } + + function stop() { + $cmd = "pkill -f ".$this->name; + $response = $this->util->pexec($cmd); + return $response; + } + + function status() { + $cmd = "ps ax | grep ".$this->getSchedulerSource()." | awk {'print $1'}"; + $response = $this->util->pexec($cmd); + if(is_array($response['out'])) { + if(count($response['out']) > 1) { + return 'STARTED'; + } else { + return 'STOPPED'; + } + } + + return 'STOPPED'; + } +} +?> \ No newline at end of file diff --git a/setup/wizard/windowsAgent.php b/setup/wizard/windowsAgent.php new file mode 100644 index 0000000..aa341ac --- /dev/null +++ b/setup/wizard/windowsAgent.php @@ -0,0 +1,187 @@ +. +* +* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, +* California 94120-7775, or email info@knowledgetree.com. +* +* The interactive user interfaces in modified source and object code versions +* of this program must display Appropriate Legal Notices, as required under +* Section 5 of the GNU General Public License version 3. +* +* In accordance with Section 7(b) of the GNU General Public License version 3, +* these Appropriate Legal Notices must retain the display of the "Powered by +* KnowledgeTree" logo and retain the original copyright notice. If the display of the +* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices +* must display the words "Powered by KnowledgeTree" and retain the original +* copyright notice. +* +* @copyright 2008-2009, KnowledgeTree Inc. +* @license GNU General Public License version 3 +* @author KnowledgeTree Team +* @package Installer +* @version Version 0.1 +*/ +class windowsAgent { +// private $javaBin; +// private $javaJVM; +// private $javaSystem; + private $name; + private $schedulerScriptPath; + private $schedulerSource; +// private $luceneServer; + private $schedulerOut; + private $schedulerError; + private $schedulerDir; + private $util = null; + + public function __construct() { + } + + function load() { + $this->name = "KTSchedulerTest"; + $this->util = new InstallUtil(); +// $this->javaSystem = new Java('java.lang.System'); +// $this->setJavaBin($this->javaSystem->getProperty('java.home').DS."bin"); + $this->setSchedulerDIR(SYSTEM_DIR."bin".DS."win32"); + $this->setSchedulerScriptPath("taskrunner.bat"); +// $this->setJavaJVM(); +// $this->setLuceneSource("ktlucene.jar"); +// $this->setLuceneServer("com.knowledgetree.lucene.KTLuceneServer"); + $this->setSchedulerOut("scheduler-out.txt"); + $this->setSchedulerError("scheduler-err.txt"); + + } + + private function setSchedulerScriptPath($schedulerScriptPath) { + $this->schedulerScriptPath = $schedulerScriptPath; + } + + public function getSchedulerScriptPath() { + return $this->schedulerScriptPath; + } + + private function setSchedulerDIR($luceneDir) { + $this->schedulerDir = $luceneDir; + } + + public function getSchedulerDir() { + return $this->schedulerDir; + } + +// private function setLuceneExe($luceneExe) { +// $this->luceneExe = $this->getluceneDir().DS.$luceneExe; +// } + +// public function getLuceneExe() { +// return $this->luceneExe; +// } + +// private function setLuceneSource($luceneSource) { +// $this->luceneSource = $this->getluceneDir().DS.$luceneSource; +// } + +// public function getLuceneSource() { +// return $this->luceneSource; +// } + +// private function setLuceneServer($luceneServer) { +// $this->luceneServer = $luceneServer; +// } + +// public function getLuceneServer() { +// return $this->luceneServer; +// } + + private function setSchedulerOut($luceneOut) { + $this->schedulerOut = SYS_LOG_DIR.$luceneOut; + } + + public function getSchedulerOut() { + return $this->schedulerOut; + } + + private function setSchedulerError($luceneError) { + $this->schedulerError = SYS_LOG_DIR.$luceneError; + } + + public function getSchedulerError() { + return $this->schedulerError; + } + +// private function setJavaJVM() { +// if(file_exists($this->getJavaBin().DS."client".DS."jvm.dll")) { +// $this->javaJVM = $this->getJavaBin().DS."client".DS."jvm.dll"; +// } elseif (file_exists($this->getJavaBin().DS."server".DS."jvm.dll")) { +// $this->javaJVM = $this->getJavaBin().DS."server".DS."jvm.dll"; +// } +// } + +// public function getJavaJVM() { +// return $this->javaJVM; +// } + + function start() { + $cmd = "sc start {$this->name}"; + $response = $this->util->pexec($cmd); + + return $response; + } + + function stop() { + $cmd = "sc stop {$this->name}"; + $response = $this->util->pexec($cmd); + + return $response; + } + + function install() { + echo $this->getSchedulerDir(); +// die; + win32_create_service(array( + 'service' => 'KTScheduler', + 'display' => 'KTScheduler', + 'path' => $scriptPath + )); + die; +// $cmd = "\"$this->luceneExe\""." -install \"".$this->name."\" \"".$this->javaJVM. "\" -Djava.class.path=\"". $this->luceneSource."\"". " -start ".$this->luceneServer. " -out \"".$this->luceneOut."\" -err \"".$this->luceneError."\" -current \"".$this->luceneDir."\" -auto"; + $response = $this->util->pexec($cmd); + + return $response; + } + + function uninstall() { + $cmd = "sc delete {$this->name}"; + $response = $this->util->pexec($cmd); + + return $response; + } + + function status() { + $cmd = "sc query {$this->name}"; + $response = $this->util->pexec($cmd); + if($response['out']) { +//preg_match('/^STATE *\: *(\d) *(\w+)/', trim($response['out'][3]), $matches); + $state = preg_replace('/^STATE *\: *\d */', '', trim($response['out'][3])); // Status store in third key + return $state; + } + } +} +?> \ No newline at end of file diff --git a/setup/wizard/windowsLucene.php b/setup/wizard/windowsLucene.php index 4c65245..5cf0831 100644 --- a/setup/wizard/windowsLucene.php +++ b/setup/wizard/windowsLucene.php @@ -1,11 +1,49 @@ . +* +* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, +* California 94120-7775, or email info@knowledgetree.com. +* +* The interactive user interfaces in modified source and object code versions +* of this program must display Appropriate Legal Notices, as required under +* Section 5 of the GNU General Public License version 3. +* +* In accordance with Section 7(b) of the GNU General Public License version 3, +* these Appropriate Legal Notices must retain the display of the "Powered by +* KnowledgeTree" logo and retain the original copyright notice. If the display of the +* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices +* must display the words "Powered by KnowledgeTree" and retain the original +* copyright notice. +* +* @copyright 2008-2009, KnowledgeTree Inc. +* @license GNU General Public License version 3 +* @author KnowledgeTree Team +* @package Installer +* @version Version 0.1 +*/ +class windowsLucene extends Service { private $javaBin; private $javaJVM; private $javaSystem; - private $name; +// private $name; private $luceneExe; private $luceneSource; private $luceneServer; @@ -19,9 +57,10 @@ class Lucene { function load() { $this->name = "KTLuceneTest"; + $this->util = new InstallUtil(); $this->javaSystem = new Java('java.lang.System'); $this->setJavaBin($this->javaSystem->getProperty('java.home').DS."bin"); - $this->setLuceneDIR(SYS_DIR.DS."bin".DS."luceneserver"); + $this->setLuceneDIR(SYSTEM_DIR."bin".DS."luceneserver"); $this->setLuceneExe("KTLuceneService.exe"); $this->setJavaJVM(); $this->setLuceneSource("ktlucene.jar"); @@ -72,7 +111,7 @@ class Lucene { } private function setLuceneOut($luceneOut) { - $this->luceneOut = SYS_LOG_DIR.DS.$luceneOut; + $this->luceneOut = SYS_LOG_DIR.$luceneOut; } public function getLuceneOut() { @@ -80,7 +119,7 @@ class Lucene { } private function setLuceneError($luceneError) { - $this->luceneError = SYS_LOG_DIR.DS.$luceneError; + $this->luceneError = SYS_LOG_DIR.$luceneError; } public function getLuceneError() { @@ -100,36 +139,43 @@ class Lucene { } function start() { - // windows $cmd = "sc start {$this->name}"; -// echo "start\n$cmd
"; - $response = exec($cmd); - // linux - // zend + $response = $this->util->pexec($cmd); + + return $response; } function stop() { $cmd = "sc stop {$this->name}"; - echo "stop\n$cmd
"; - $response = exec($cmd); + $response = $this->util->pexec($cmd); + + return $response; } function install() { - $cmd = $this->luceneExe." -install \"".$this->name."\" \"".$this->javaJVM. "\" -Djava.class.path=\"". $this->luceneSource."\"". " -start ".$this->luceneServer. " -out \"".$this->luceneOut."\" -err \"".$this->luceneError."\" -current \"".$this->luceneDir."\" -auto"; -// echo "install\n$cmd
"; - $response = exec($cmd); + $cmd = "\"$this->luceneExe\""." -install \"".$this->name."\" \"".$this->javaJVM. "\" -Djava.class.path=\"". $this->luceneSource."\"". " -start ".$this->luceneServer. " -out \"".$this->luceneOut."\" -err \"".$this->luceneError."\" -current \"".$this->luceneDir."\" -auto"; + $response = $this->util->pexec($cmd); + + return $response; } function uninstall() { $cmd = "sc delete {$this->name}"; -// echo "uninstall\n$cmd
"; - $response = exec($cmd); + $response = $this->util->pexec($cmd); + + return $response; } + + function status() { + $cmd = "sc query {$this->name}"; + $response = $this->util->pexec($cmd); + if($response['out']) { +//preg_match('/^STATE *\: *(\d) *(\w+)/', trim($response['out'][3]), $matches); + $state = preg_replace('/^STATE *\: *\d */', '', trim($response['out'][3])); // Status store in third key + return $state; + } + } + + } -$lucene = new Lucene(); -$lucene->load(); -$lucene->install(); -$lucene->start(); -$lucene->stop(); -$lucene->uninstall(); ?> \ No newline at end of file diff --git a/setup/wizard/windowsScheduler.php b/setup/wizard/windowsScheduler.php new file mode 100644 index 0000000..a0ad339 --- /dev/null +++ b/setup/wizard/windowsScheduler.php @@ -0,0 +1,133 @@ +. +* +* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, +* California 94120-7775, or email info@knowledgetree.com. +* +* The interactive user interfaces in modified source and object code versions +* of this program must display Appropriate Legal Notices, as required under +* Section 5 of the GNU General Public License version 3. +* +* In accordance with Section 7(b) of the GNU General Public License version 3, +* these Appropriate Legal Notices must retain the display of the "Powered by +* KnowledgeTree" logo and retain the original copyright notice. If the display of the +* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices +* must display the words "Powered by KnowledgeTree" and retain the original +* copyright notice. +* +* @copyright 2008-2009, KnowledgeTree Inc. +* @license GNU General Public License version 3 +* @author KnowledgeTree Team +* @package Installer +* @version Version 0.1 +*/ +class windowsScheduler extends Service { + //private $name; + private $schedulerScriptPath; + private $schedulerSource; + private $schedulerOut; + private $schedulerError; + private $schedulerDir; + private $util = null; + + public function __construct() { + } + + function load() { + $this->name = "KTSchedulerTest"; + $this->util = new InstallUtil(); + $this->setSchedulerDIR(SYSTEM_DIR."bin".DS."win32"); + $this->setSchedulerScriptPath("taskrunner_test.bat"); + $this->setSchedulerSource("schedulerService.php"); + } + + private function setSchedulerScriptPath($schedulerScriptPath) { + $this->schedulerScriptPath = "{$this->getSchedulerDir()}".DS."$schedulerScriptPath"; + } + + public function getSchedulerScriptPath() { + return $this->schedulerScriptPath; + } + + private function setSchedulerDIR($luceneDir) { + $this->schedulerDir = $luceneDir; + } + + public function getSchedulerDir() { + return $this->schedulerDir; + } + + private function setSchedulerSource($schedulerSource) { + $this->schedulerSource = $this->getSchedulerDir().DS.$schedulerSource; + } + + public function getSchedulerSource() { + return $this->schedulerSource; + } + + public function start() { + $cmd = "sc start {$this->name}"; + $response = $this->util->pexec($cmd); + + return $response; + } + + public function stop() { + $cmd = "sc stop {$this->name}"; + $response = $this->util->pexec($cmd); + + return $response; + } + + public function install() { + $pathToSCode = $this->getSchedulerSource(); + $fp = fopen($this->schedulerScriptPath, "w+"); + $content = "@echo off\n"; + $content .= "\"".PHP_DIR."php.exe\" "."\"{$this->schedulerSource}\""; + fwrite($fp, $content); + fclose($fp); + $response = win32_create_service(array( + 'service' => $this->name, + 'display' => $this->name, + 'path' => $this->schedulerScriptPath + )); + + return $response; + } + + public function uninstall() { + $cmd = "sc delete {$this->name}"; + $response = $this->util->pexec($cmd); + + return $response; + } + + public function status() { + $cmd = "sc query {$this->name}"; + $response = $this->util->pexec($cmd); + if($response['out']) { +//preg_match('/^STATE *\: *(\d) *(\w+)/', trim($response['out'][3]), $matches); + $state = preg_replace('/^STATE *\: *\d */', '', trim($response['out'][3])); // Status store in third key + return $state; + } + } +} +?> \ No newline at end of file