Commit 958823030db869c1e6c18f442953ea5e696002a8

Authored by Kevin G Fourie
2 parents ae1003f9 f2dc35c6

Merge branch 'edge'

lib/api/ktcmis/services/CMISObjectService.inc.php
... ... @@ -109,7 +109,7 @@ class CMISObjectService {
109 109 }
110 110  
111 111 // if content stream is required and no content stream is supplied, throw a ConstraintViolationException
112   - if (($typeDefinition['attributes']['contentStreamAllowed'] == 'required') && empty($contentStream))
  112 + if (($typeDefinition['attributes']['contentStreamAllowed'] == 'required') && is_null($contentStream))
113 113 {
114 114 throw new ConstraintViolationException('This repository requires a content stream for document creation. '
115 115 . 'Refusing to create an empty document');
... ... @@ -152,7 +152,7 @@ class CMISObjectService {
152 152 // create the content stream from the supplied data
153 153 // NOTE since the repository is set to require a content stream and we don't currently have another way to get the document data
154 154 // this check isn't strictly necessary; however it is needed for a repository which does not support content streams
155   - if (!empty($contentStream))
  155 + if (!is_null($contentStream))
156 156 {
157 157 // TODO consider checking whether content is encoded (currently we expect encoded)
158 158 // TODO choose between this and the alternative decode function (see CMISUtil class)
... ... @@ -283,7 +283,7 @@ class CMISObjectService {
283 283 // then we may have something else to do here;
284 284 // for now we just throw a general RuntimeException, since we should not
285 285 // actually reach this code unless something is wrong; this may be removed or replaced later
286   - throw new RuntimeException('Cannot create empty document');
  286 + throw new RuntimeException('Cannot create document without a content stream');
287 287 }
288 288  
289 289 return $objectId;
... ...
setup/wizard/batches/lucene_install.bat 0 → 100644
  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
0 2 \ No newline at end of file
... ...
setup/wizard/batches/lucene_start.bat 0 → 100644
  1 +sc start KTLuceneTest
0 2 \ No newline at end of file
... ...
setup/wizard/batches/lucene_uninstall.bat 0 → 100644
  1 +sc delete KTLuceneTest
0 2 \ No newline at end of file
... ...
setup/wizard/batches/scheduler_install.bat 0 → 100644
setup/wizard/batches/scheduler_start.bat 0 → 100644
  1 +sc start KTSchedulerTest
0 2 \ No newline at end of file
... ...
setup/wizard/batches/scheduler_uninstall.bat 0 → 100644
  1 +sc delete KTSchedulerTest
0 2 \ No newline at end of file
... ...
setup/wizard/config/config.xml
... ... @@ -10,10 +10,10 @@
10 10 <install version="3.3">
11 11 <steps>
12 12 <step name="Welcome">welcome</step>
  13 + <step name="License Agreement">license</step>
13 14 <step name="PHP Dependencies">dependencies</step>
14 15 <step name="Service Dependencies" order="3">services</step>
15 16 <step name="System Configuration" order="1">configuration</step>
16   - <step name="License Agreement">license</step>
17 17 <step name="Database Configuration" order="2">database</step>
18 18 <step name="Install">install</step>
19 19 <step name="Complete">complete</step>
... ...
setup/wizard/install 0 → 100644
setup/wizard/installUtil.php
... ... @@ -77,21 +77,21 @@ class InstallUtil {
77 77 if(!$this->_checkPermission(WIZARD_DIR)) {
78 78 return 'wizard';
79 79 }
80   - if(!$this->_checkPermission(CONF_DIR)) {
81   - return 'wizard';
82   - }
83   - if(!$this->_checkPermission(SQL_DIR)) {
84   - return 'wizard';
85   - }
86   - if(!$this->_checkPermission(RES_DIR)) {
87   - return 'wizard';
88   - }
89   - if(!$this->_checkPermission(STEP_DIR)) {
90   - return 'wizard';
91   - }
92   - if(!$this->_checkPermission(TEMP_DIR)) {
93   - return 'wizard';
94   - }
  80 +// if(!$this->_checkPermission(CONF_DIR)) {
  81 +// return 'wizard';
  82 +// }
  83 +// if(!$this->_checkPermission(SQL_DIR)) {
  84 +// return 'wizard';
  85 +// }
  86 +// if(!$this->_checkPermission(RES_DIR)) {
  87 +// return 'wizard';
  88 +// }
  89 +// if(!$this->_checkPermission(STEP_DIR)) {
  90 +// return 'wizard';
  91 +// }
  92 +// if(!$this->_checkPermission(TEMP_DIR)) {
  93 +// return 'wizard';
  94 +// }
95 95  
96 96 return true;
97 97 }
... ... @@ -339,6 +339,7 @@ class InstallUtil {
339 339 if(WINDOWS_OS) {
340 340 $sCmd = 'call '.$sCmd;
341 341 }
  342 +// echo "===".$sCmd."===<br/>";
342 343 exec($sCmd, $aOutput, $iRet);
343 344 $aRet['ret'] = $iRet;
344 345 $aRet['out'] = $aOutput;
... ...
setup/wizard/installWizard.php
... ... @@ -44,9 +44,9 @@ include(&quot;path.php&quot;); // Paths
44 44 function __autoload($class) { // Attempt and autoload classes
45 45 $class = strtolower(substr($class,0,1)).substr($class,1); // Linux Systems.
46 46 if(file_exists(WIZARD_DIR."$class.php")) {
47   - require(WIZARD_DIR."$class.php");
  47 + require_once(WIZARD_DIR."$class.php");
48 48 } elseif (file_exists(STEP_DIR."$class.php")) {
49   - require(STEP_DIR."$class.php");
  49 + require_once(STEP_DIR."$class.php");
50 50 } else {
51 51 return false;
52 52 }
... ... @@ -209,7 +209,7 @@ class InstallWizard {
209 209 if($res === true) return $res;
210 210 switch ($res) {
211 211 case "wizard":
212   - return 'Installer directory is not writable<br/>';
  212 + return 'Installer directory is not writable (Installation/setup/wizard/)<br/>';
213 213 break;
214 214 case "/":
215 215 return 'System root is not writable<br/>';
... ...
setup/wizard/path.php
... ... @@ -43,26 +43,49 @@
43 43 if (substr(php_uname(), 0, 7) == "Windows"){
44 44 define('WINDOWS_OS', true);
45 45 define('UNIX_OS', false);
  46 + define('OS', 'windows');
46 47 } else {
47 48 define('WINDOWS_OS', false);
48 49 define('UNIX_OS', true);
  50 + define('OS', 'unix');
49 51 }
50 52 if(WINDOWS_OS) {
51 53 define('DS', '\\');
52 54 } else {
53 55 define('DS', '/');
54 56 }
55   - define('WIZARD_DIR', dirname(__FILE__).DS);
56   - define('SYSTEM_DIR', WIZARD_DIR."..".DS."..".DS);
57   - define('SYS_BIN_DIR', WIZARD_DIR."..".DS."..".DS."bin".DS);
58   - define('SYS_LOG_DIR', WIZARD_DIR."..".DS."..".DS."var".DS."log".DS);
  57 + $wizard_dir = realpath(dirname(__FILE__));
  58 + $xdir = explode(DS, $wizard_dir);
  59 + array_pop($xdir);
  60 + array_pop($xdir);
  61 + $sys = '';
  62 + foreach ($xdir as $k=>$v) {
  63 + $sys .= $v.DS;
  64 + }
  65 +
  66 + define('WIZARD_DIR', $wizard_dir.DS);
  67 + define('SYSTEM_DIR', $sys);
  68 + define('SYS_BIN_DIR', $sys."bin".DS);
  69 + define('SYS_LOG_DIR', $sys."var".DS."log".DS);
59 70 define('SQL_DIR', WIZARD_DIR.DS."sql".DS);
60 71 define('SQL_UPGRADE_DIR', SQL_DIR.DS."upgrades".DS);
61 72 define('CONF_DIR', WIZARD_DIR.DS."config".DS);
62 73 define('RES_DIR', WIZARD_DIR.DS."resources".DS);
63 74 define('STEP_DIR', WIZARD_DIR.DS."steps".DS);
64 75 define('TEMP_DIR', WIZARD_DIR.DS."templates".DS);
65   -
66   -
67   -
  76 + preg_match('/Zend/', $sys, $matches);// Install Type
  77 + if($matches) {
  78 + $sysdir = explode(DS, $sys);
  79 + array_pop($sysdir);
  80 + array_pop($sysdir);
  81 + array_pop($sysdir);
  82 + array_pop($sysdir);
  83 + $zendsys = '';
  84 + foreach ($sysdir as $k=>$v) {
  85 + $zendsys .= $v.DS;
  86 + }
  87 + define('INSTALL_TYPE', 'Zend');
  88 + define('PHP_DIR', $zendsys."ZendServer".DS."bin".DS);
  89 + }
  90 + date_default_timezone_set('Africa/Johannesburg');
68 91 ?>
... ...
setup/wizard/service.php
... ... @@ -41,29 +41,29 @@
41 41 */
42 42  
43 43 class Service {
44   - private static $on = 1;
45   - private static $off = 0;
46   - public $pid;
47 44 public $status;
  45 + public $name;
  46 +
  47 + public function getName() {
  48 + return $this->name;
  49 + }
  50 +
  51 + public function load() {
  52 +
  53 + }
48 54  
49 55 public function start() {
50 56  
51   -// $this->status = $this->on;
52 57 }
53 58  
54 59 public function stop() {
55   -
56   -// $this->status = $this->off;
57 60 }
58 61  
59 62 public function install() {
60   -
61 63 }
62 64  
63 65 public function restart() {
64   -// $this->status = $this->off;
65   -
66   -// $this->status = $this->on;
  66 +
67 67 }
68 68  
69 69 public function uninstall() {
... ... @@ -71,7 +71,16 @@ class Service {
71 71 }
72 72  
73 73 public function status() {
74   -// return $this->status;
  74 +// [SC] DeleteService SUCCESS
  75 +//The KTLuceneTest automatic service was successfully installed
  76 + }
  77 +
  78 + public function pause() {
  79 +
  80 + }
  81 +
  82 + public function cont() {
  83 +
75 84 }
76 85 }
77 86 ?>
78 87 \ No newline at end of file
... ...
setup/wizard/steps/configuration.php
... ... @@ -42,6 +42,14 @@
42 42  
43 43 class configuration extends Step
44 44 {
  45 + /**
  46 + * Database object
  47 + *
  48 + * @author KnowledgeTree Team
  49 + * @access private
  50 + * @var array
  51 + */
  52 + private $_dbhandler = null;
45 53 private $host;
46 54 private $port;
47 55 private $root_url;
... ... @@ -74,6 +82,7 @@ class configuration extends Step
74 82 */
75 83 public function __construct()
76 84 {
  85 + $this->_dbhandler = new dbUtil();
77 86 $this->done = true;
78 87 }
79 88  
... ... @@ -184,13 +193,12 @@ class configuration extends Step
184 193 }
185 194  
186 195 // initialise the db connection
187   - $db = new dbUtil();
188 196  
189 197 // retrieve database information from session
190 198 $dbconf = $this->getDataFromSession("database");
191 199  
192 200 // make db connection
193   - $db->dbUtil($dbconf['dhost'], $dbconf['duname'], $dbconf['dpassword'], $dbconf['dname']);
  201 + $this->_dbhandler->dbUtil($dbconf['dhost'], $dbconf['duname'], $dbconf['dpassword'], $dbconf['dname']);
194 202  
195 203 // add db config to server variables
196 204 $server = $this->registerDBConfig($server, $dbconf);
... ... @@ -218,7 +226,7 @@ class configuration extends Step
218 226 $setting = mysql_real_escape_string($item['setting']);
219 227  
220 228 $sql = "UPDATE {$table} SET value = '{$value}' WHERE item = '{$setting}'";
221   - $db->query($sql);
  229 + $this->_dbhandler->query($sql);
222 230 break;
223 231 }
224 232 }
... ... @@ -233,7 +241,7 @@ class configuration extends Step
233 241 $setting = mysql_real_escape_string($item['setting']);
234 242  
235 243 $sql = "UPDATE {$table} SET value = '{$value}' WHERE item = '{$setting}'";
236   - $db->query($sql);
  244 + $this->_dbhandler->query($sql);
237 245 }
238 246  
239 247 // write out the config.ini file
... ... @@ -242,7 +250,7 @@ class configuration extends Step
242 250 }
243 251  
244 252 // close the database connection
245   - $db->close();
  253 + $this->_dbhandler->close();
246 254 }
247 255  
248 256 /**
... ...
setup/wizard/steps/database.php
... ... @@ -43,7 +43,7 @@
43 43 class database extends Step
44 44 {
45 45 /**
46   - * Database type
  46 + * Database object
47 47 *
48 48 * @author KnowledgeTree Team
49 49 * @access private
... ...
setup/wizard/steps/dependencies.php
... ... @@ -300,18 +300,33 @@ class dependencies extends Step
300 300 */
301 301 private function getRequiredExtensions()
302 302 {
303   - return array(
304   - array('extension' => 'fileinfo', 'required' => 'no', 'name' => 'Fileinfo', 'details' => 'Provides better file identification support - not necessary if you use file extensions.'),
305   - array('extension' => 'iconv', 'required' => 'no', 'name' => 'IconV', 'details' => 'Used for conversion between character sets.'),
306   - array('extension' => 'mysql', 'required' => 'yes', 'name' => 'MySQL', 'details' => 'Used for accessing a MySQL database.'),
307   - array('extension' => 'curl', 'required' => 'yes', 'name' => 'cURL', 'details' => 'Allows the connection and communication between different servers types using various protocols.'),
308   - array('extension' => 'xmlrpc', 'required' => 'yes', 'name' => 'XMLRPC', 'details' => 'Used with XML-RPC servers and clients.'),
309   - array('extension' => 'win32', 'required' => 'no', 'name' => 'Win32', 'details' => 'Allows control of Microsoft Windows services.'),
310   - array('extension' => 'mbstring', 'required' => 'no', 'name' => 'Multi Byte Strings', 'details' => 'Used in the manipulation of multi-byte strings.'),
311   - array('extension' => 'ldap', 'required' => 'no', 'name' => 'LDAP', 'details' => 'Used to access LDAP directory servers.'),
312   - array('extension' => 'json', 'required' => 'yes', 'name' => 'JSON', 'details' => 'Implements the javascript object notation (json) data-interchange format.'),
313   - array('extension' => 'openssl', 'required' => 'no', 'name' => 'Open SSL', 'details' => 'Used for the generation and verification of signatures and the encrypting and decrypting of data'),
314   - );
  303 + // TODO: Better
  304 + if(WINDOWS_OS) {
  305 + return array(
  306 + array('extension' => 'fileinfo', 'required' => 'no', 'name' => 'Fileinfo', 'details' => 'Provides better file identification support - not necessary if you use file extensions.'),
  307 + array('extension' => 'iconv', 'required' => 'no', 'name' => 'IconV', 'details' => 'Used for conversion between character sets.'),
  308 + array('extension' => 'mysql', 'required' => 'yes', 'name' => 'MySQL', 'details' => 'Used for accessing a MySQL database.'),
  309 + array('extension' => 'curl', 'required' => 'yes', 'name' => 'cURL', 'details' => 'Allows the connection and communication between different servers types using various protocols.'),
  310 + array('extension' => 'xmlrpc', 'required' => 'yes', 'name' => 'XMLRPC', 'details' => 'Used with XML-RPC servers and clients.'),
  311 + array('extension' => 'win32', 'required' => 'no', 'name' => 'Win32', 'details' => 'Allows control of Microsoft Windows services.'),
  312 + array('extension' => 'mbstring', 'required' => 'no', 'name' => 'Multi Byte Strings', 'details' => 'Used in the manipulation of multi-byte strings.'),
  313 + array('extension' => 'ldap', 'required' => 'no', 'name' => 'LDAP', 'details' => 'Used to access LDAP directory servers.'),
  314 + array('extension' => 'json', 'required' => 'yes', 'name' => 'JSON', 'details' => 'Implements the javascript object notation (json) data-interchange format.'),
  315 + array('extension' => 'openssl', 'required' => 'no', 'name' => 'Open SSL', 'details' => 'Used for the generation and verification of signatures and the encrypting and decrypting of data'),
  316 + );
  317 + } else {
  318 + return array(
  319 + array('extension' => 'fileinfo', 'required' => 'no', 'name' => 'Fileinfo', 'details' => 'Provides better file identification support - not necessary if you use file extensions.'),
  320 + array('extension' => 'iconv', 'required' => 'no', 'name' => 'IconV', 'details' => 'Used for conversion between character sets.'),
  321 + array('extension' => 'mysql', 'required' => 'yes', 'name' => 'MySQL', 'details' => 'Used for accessing a MySQL database.'),
  322 + array('extension' => 'curl', 'required' => 'yes', 'name' => 'cURL', 'details' => 'Allows the connection and communication between different servers types using various protocols.'),
  323 + array('extension' => 'xmlrpc', 'required' => 'yes', 'name' => 'XMLRPC', 'details' => 'Used with XML-RPC servers and clients.'),
  324 + array('extension' => 'mbstring', 'required' => 'no', 'name' => 'Multi Byte Strings', 'details' => 'Used in the manipulation of multi-byte strings.'),
  325 + array('extension' => 'ldap', 'required' => 'no', 'name' => 'LDAP', 'details' => 'Used to access LDAP directory servers.'),
  326 + array('extension' => 'json', 'required' => 'yes', 'name' => 'JSON', 'details' => 'Implements the javascript object notation (json) data-interchange format.'),
  327 + array('extension' => 'openssl', 'required' => 'no', 'name' => 'Open SSL', 'details' => 'Used for the generation and verification of signatures and the encrypting and decrypting of data'),
  328 + );
  329 + }
315 330 }
316 331  
317 332 /**
... ...
setup/wizard/steps/services.php
... ... @@ -40,9 +40,6 @@
40 40 * @version Version 0.1
41 41 */
42 42  
43   -
44   -//require_once('../../thirdparty/xmlrpc-2.2/xmlrpc.inc');
45   -
46 43 class services extends Step
47 44 {
48 45 /**
... ... @@ -63,7 +60,11 @@ class services extends Step
63 60 */
64 61 protected $runInstall = true;
65 62  
  63 + protected $services = array('Lucene', 'Scheduler');
  64 +
  65 + protected $java;
66 66  
  67 + protected $util;
67 68 /**
68 69 * Constructs database object
69 70 *
... ... @@ -72,7 +73,51 @@ class services extends Step
72 73 * @param none
73 74 */
74 75 public function __construct() {
75   -
  76 + $this->util = new InstallUtil();
  77 + $this->setJava();
  78 + }
  79 +
  80 + function tryJava1() {
  81 + $response = $this->util->pexec("java"); // Java Runtime Check
  82 + if(empty($response['out'])) {
  83 + return false;
  84 + }
  85 + $this->java = 'java';
  86 + return true;
  87 + }
  88 +
  89 + function tryJava2() {
  90 + $response = $this->util->pexec("java -version"); // Java Runtime Check
  91 + if(empty($response['out'])) {
  92 + return false;
  93 + }
  94 + $this->java = 'java';
  95 + return true;
  96 + }
  97 +
  98 + function tryJava3() {
  99 + $response = $this->util->pexec("whereis java"); // Java Runtime Check
  100 + if(empty($response['out'])) {
  101 + return false;
  102 + }
  103 + $broke = explode(' ', $response['out'][0]);
  104 + foreach ($broke as $r) {
  105 + $match = preg_match('/bin/', $r);
  106 + if($match) {
  107 + $this->java = preg_replace('/java:/', '', $r);
  108 + return true;
  109 + }
  110 + }
  111 + }
  112 +
  113 + function setJava() {
  114 + $response = $this->tryJava1();
  115 + if(!$response) {
  116 + $response = $this->tryJava2();
  117 + if(!$response) {
  118 + $response = $this->tryJava3();
  119 + }
  120 + }
76 121 }
77 122  
78 123 /**
... ... @@ -101,14 +146,12 @@ class services extends Step
101 146 }
102 147  
103 148 private function doRun() {
104   - $util = new InstallUtil();
105   -// $response = $util->pexec("java"); // Java Runtime Check
106   - $response = $util->pexec("java -version"); // Java Runtime Check
107   - if(empty($response['out'])) {
108   - $this->error[] = "Java runtime environment required";
109   -// return false;
  149 + if($this->java == '') {
  150 + $this->error[] = "Java runtime environment required";
  151 + return false;
110 152 }
111   - $this->installStep();
  153 +
  154 + $this->installService();
112 155 return true;
113 156 }
114 157  
... ... @@ -121,23 +164,61 @@ class services extends Step
121 164 * @access public
122 165 * @return void
123 166 */
124   - public function installStep() {
125   - $util = new InstallUtil();
126   - if(WINDOWS_OS) { // Add service to tasks list if needed
127   - $lucene = new windowsLucene();
128   - // Start service
129   - } else { // Unix based systems
130   - $lucene = new unixLucene();
131   - $lucene->load();
  167 + public function installService() {
  168 + foreach ($this->services as $serviceName) {
  169 + $className = OS.$serviceName;
  170 + $service = new $className();
  171 + $status = $this->serviceHelper($service);
132 172 }
133   -
134   -
135   -
136 173  
  174 + return true;
137 175 }
138 176  
139 177  
  178 + public function serviceHelper($service) {
  179 + $service->load(); // Load Defaults
  180 + $response = $service->uninstall(); // Uninstall service if it exists
  181 + $response = $service->install(); // Install service
  182 + $statusCheck = OS."Status";
  183 + return $this->$statusCheck($service);
140 184  
  185 + }
  186 +
  187 + function serviceStart($service) {
  188 + if(OS == 'windows') {
  189 + $service->load(); // Load Defaults
  190 + $service->start(); // Start Service
  191 + $this->windowsStatus($service); // Get service status
  192 + }
  193 + }
  194 +
  195 + function windowsStatus($service) {
  196 + $status = $service->status(); // Check if service has been installed
  197 + if($status != 'STOPPED') { // Check service status
  198 + $this->error[] = $service->getName()." Could not be added as a Service";
  199 + return false;
  200 + }
  201 + return true;
  202 + }
  203 +
  204 + function unixStatus($service) {
  205 + $status = $service->status(); // Check if service has been installed
  206 + if($status != 'STARTED') { // Check service status
  207 + $this->error[] = $service->getName()." Could not be added as a Service";
  208 + return false;
  209 + }
  210 + return true;
  211 + }
  212 +
  213 + function installStep() {
  214 + foreach ($this->services as $serviceName) {
  215 + $className = OS.$serviceName;
  216 + $service = new $className();
  217 + $status = $this->serviceStart($service);
  218 + }
  219 +
  220 + return true;
  221 + }
141 222 /**
142 223 * Returns database errors
143 224 *
... ...
setup/wizard/template.php
... ... @@ -75,7 +75,10 @@ class Template
75 75 */
76 76 public function set($name, $value)
77 77 {
78   - if(is_a($value, 'Template')) {
  78 + //if(is_a($value, 'Template')) {
  79 + $class = 'Template';
  80 + $isA = $value instanceof $class;
  81 + if($isA) {
79 82 $value = $value->fetch();
80 83 }
81 84 $this->template_vars[$name] = $value;
... ...
setup/wizard/unixAgent.php 0 → 100644
  1 +<?php
  2 +/**
  3 +* Lucene Service Controller.
  4 +*
  5 +* KnowledgeTree Community Edition
  6 +* Document Management Made Simple
  7 +* Copyright(C) 2008,2009 KnowledgeTree Inc.
  8 +* Portions copyright The Jam Warehouse Software(Pty) Limited
  9 +*
  10 +* This program is free software; you can redistribute it and/or modify it under
  11 +* the terms of the GNU General Public License version 3 as published by the
  12 +* Free Software Foundation.
  13 +*
  14 +* This program is distributed in the hope that it will be useful, but WITHOUT
  15 +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  16 +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  17 +* details.
  18 +*
  19 +* You should have received a copy of the GNU General Public License
  20 +* along with this program. If not, see <http://www.gnu.org/licenses/>.
  21 +*
  22 +* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
  23 +* California 94120-7775, or email info@knowledgetree.com.
  24 +*
  25 +* The interactive user interfaces in modified source and object code versions
  26 +* of this program must display Appropriate Legal Notices, as required under
  27 +* Section 5 of the GNU General Public License version 3.
  28 +*
  29 +* In accordance with Section 7(b) of the GNU General Public License version 3,
  30 +* these Appropriate Legal Notices must retain the display of the "Powered by
  31 +* KnowledgeTree" logo and retain the original copyright notice. If the display of the
  32 +* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
  33 +* must display the words "Powered by KnowledgeTree" and retain the original
  34 +* copyright notice.
  35 +*
  36 +* @copyright 2008-2009, KnowledgeTree Inc.
  37 +* @license GNU General Public License version 3
  38 +* @author KnowledgeTree Team
  39 +* @package Installer
  40 +* @version Version 0.1
  41 +*/
  42 +
  43 +class unixLucene extends Service {
  44 +
  45 +
  46 + public function __construct() {
  47 + }
  48 +
  49 + function load() {
  50 +
  51 + }
  52 +
  53 + public function stop() {
  54 +
  55 + }
  56 +
  57 + public function install() {
  58 +
  59 + }
  60 +
  61 + public function start() {
  62 +
  63 + }
  64 +
  65 +}
  66 +?>
0 67 \ No newline at end of file
... ...
setup/wizard/unixLucene.php
... ... @@ -40,18 +40,17 @@
40 40 * @version Version 0.1
41 41 */
42 42  
43   -define('LUCENE_SOURCE_DIR', SYSTEM_DIR."bin".DS."luceneserver".DS);
44   -define('LUCENE_SOURCE_FILE', SYSTEM_DIR."bin".DS."luceneserver".DS."ktlucene.jar");
45   -require_once("service.php");
46   -
47 43 class unixLucene extends Service {
48   - private $name;
49   -// private $javaBin;
50   -// private $javaSystem;
51   -// protected $lucene_pid_file="";
52   -// protected $lucene_dir="";
53   -// protected $lucene_message="";
54   - protected $lucene_options = " -Xms512M -Xmx512M -jar ";
  44 + public $name;
  45 + public $phpDir;
  46 + private $shutdownScript;
  47 + protected $indexerDir;
  48 + protected $lucenePidFile;
  49 + protected $luceneDir;
  50 + protected $luceneSource;
  51 + protected $luceneSourceLoc;
  52 + protected $javaXms;
  53 + protected $javaXmx;
55 54 private $util = null;
56 55  
57 56 public function __construct() {
... ... @@ -60,168 +59,166 @@ class unixLucene extends Service {
60 59 function load() {
61 60 $this->name = "KTLuceneTest";
62 61 $this->util = new InstallUtil();
63   -// $this->javaSystem = new Java('java.lang.System');
64   -// $this->setJavaBin($this->javaSystem->getProperty('java.home').DS."bin");
  62 + $this->setLuceneDir(SYSTEM_DIR."bin".DS."luceneserver".DS);
  63 + $this->setIndexerDir(SYSTEM_DIR."search2".DS."indexing".DS."bin".DS);
  64 + $this->setLucenePidFile("lucene_test.pid");
  65 + $this->setJavaXms(512);
  66 + $this->setJavaXmx(512);
  67 + $this->setLuceneSource("ktlucene.jar");
  68 + $this->setLuceneSourceLoc("ktlucene.jar");
  69 + $this->setPhpDir();
  70 + $this->setShutdownScript("shutdown.php");
  71 + }
  72 +
  73 + public function setIndexerDir($indexerDir) {
  74 + $this->indexerDir = $indexerDir;
  75 + }
  76 +
  77 + private function getIndexerDir() {
  78 + return $this->indexerDir;
  79 + }
  80 +
  81 + private function setShutdownScript($shutdownScript) {
  82 + $this->shutdownScript = $shutdownScript;
  83 + }
  84 +
  85 + public function getShutdownScript() {
  86 + return $this->shutdownScript;
  87 + }
  88 +
  89 + private function setPhpDir($phpdir = '') {
  90 + if($phpdir == '') {
  91 + $cmd = "whereis php";
  92 + $response = $this->util->pexec($cmd);
  93 + if(is_array($response['out'])) {
  94 + $broke = explode(' ', $response['out'][0]);
  95 + foreach ($broke as $r) {
  96 + $match = preg_match('/bin/', $r);
  97 + if($match) {
  98 + $this->phpDir = preg_replace('/php:/', '', $r);
  99 + }
  100 + }
  101 + }
  102 +// echo $this->phpDir;
  103 +// die;
  104 + return ;
  105 + } else {
  106 + $this->phpDir = $phpdir;
  107 + }
  108 + }
  109 +
  110 + public function getPhpDir() {
  111 + return $this->phpDir;
  112 + }
  113 +
  114 + private function setLucenePidFile($lucenePidFile) {
  115 + $this->lucenePidFile = $lucenePidFile;
  116 + }
  117 +
  118 + private function getLucenePidFile() {
  119 + return $this->lucenePidFile;
  120 + }
  121 +
  122 + private function setLuceneDir($luceneDir) {
  123 + $this->luceneDir = $luceneDir;
  124 + }
  125 +
  126 + public function getLuceneDir() {
  127 + return $this->luceneDir;
  128 + }
  129 +
  130 + private function setJavaXms($javaXms) {
  131 + $this->javaXms = "-Xms$javaXms";
  132 + }
  133 +
  134 + public function getJavaXms() {
  135 + return $this->javaXms;
  136 + }
  137 +
  138 + private function setJavaXmx($javaXmx) {
  139 + $this->javaXmx = "-Xmx$javaXmx";
  140 + }
  141 +
  142 + public function getJavaXmx() {
  143 + return $this->javaXmx;
  144 + }
  145 +
  146 + private function setLuceneSource($luceneSource) {
  147 + $this->luceneSource = $luceneSource;
  148 + }
  149 +
  150 + public function getLuceneSource() {
  151 + return $this->luceneSource;
65 152 }
66 153  
67   - private function setJavaBin($javaBin) {
68   - $this->javaBin = $javaBin;
  154 + private function setLuceneSourceLoc($luceneSourceLoc) {
  155 + $this->luceneSourceLoc = $this->getLuceneDir().$luceneSourceLoc;
69 156 }
70 157  
71   - public function getJavaBin() {
72   - return $this->javaBin;
  158 + public function getLuceneSourceLoc() {
  159 + return $this->luceneSourceLoc;
73 160 }
74 161  
75   - // Load default settings
76   -// public function load() {
77   -// $this->util = new InstallUtil();
78   -// $this->lucene_dir = SYSTEM_DIR."bin".DS."luceneserver".DS;
79   -// $this->lucene_pid_file = SYSTEM_DIR."bin".DS."luceneserver".DS."lucene.pid";
80   -// $this->lucene_pid = '';
81   -// }
  162 + public function getJavaOptions() {
  163 + return " {$this->getJavaXmx()} {$this->getJavaXmx()} -jar ";
  164 + }
82 165  
83   - // Stop lucene
84 166 public function stop() {
85   - // TODO:Still need to figure out xmlrpc shutdown()
86   - $cmd = "pkill -f lucene<br/>";
87   - $response = $util->pexec($cmd);
88   - echo 'Stop lucene';
  167 + // TODO: Breaks things
  168 + if($this->getPhpDir() != "") {
  169 +// $cmd = $this->getPhpDir()." ".$this->getIndexerDir().$this->getShutdownScript()." positive &> ".SYS_LOG_DIR."dmsctl.log";
  170 + } else {
  171 + $cmd = "pkill -f ".$this->getLuceneSource();
  172 + }
  173 + $state = $this->status();
  174 + if($state == 'STARTED') {
  175 + $cmd = "pkill -f ".$this->getLuceneSource();
  176 + $response = $this->util->pexec($cmd);
  177 + return $response;
  178 + }
  179 +
89 180 }
90 181  
91 182 public function install() {
92   -
  183 + $state = $this->status();
  184 +// die;
  185 + if($state != 'STARTED') {
  186 + $cmd = "cd ".$this->getLuceneDir()."; ";
  187 + $cmd .= "nohup java -jar ".$this->getLuceneSource()." &> ".SYS_LOG_DIR."lucene.log &";
  188 + $response = $this->util->pexec($cmd);
  189 + return $response;
  190 + } elseif ($state == 'STOPPED') {
  191 + // start her up
  192 +
  193 + }
93 194 }
94 195  
95   - // Start lucene
96   - public function start() {
97   - // TODO:A shot in the dark here
98   - $this->util = new InstallUtil();
99   - $cmd = "nohup java".$this->lucene_options.LUCENE_SOURCE_FILE." &> ".SYS_LOG_DIR."lucene.log";
  196 + public function status() {
  197 + $cmd = "ps ax | grep ".$this->getLuceneSource()." | awk {'print $1'}";
  198 +// echo $cmd;
100 199 $response = $this->util->pexec($cmd);
101   - $this->status = $this->on;
102   - echo 'Start lucene';
  200 +// var_dump($response);
  201 + if(is_array($response['out'])) {
  202 + if(count($response['out']) > 1) {
  203 +// var_dump($response['out']);
  204 + return 'STARTED';
  205 + } else {
  206 + return 'STOPPED';
  207 + }
  208 + }
  209 +
  210 + return 'STOPPED';
103 211 }
104 212  
  213 + public function uninstall() {
  214 + $this->stop();
  215 + }
105 216  
106   - public function _start_lucene() {
107   - if($this->is_lucene_running()) { // Is service running
108   - echo 'Already Running<br/>';
109   - } else {
110   - // Get to
111   - //echo 'Install service';
112   - $this->is_lucene_running();
113   - //nohup $LUCENE &> $INSTALL_PATH/var/log/dmsctl.log &
114   -
115   - }
116   -
117   -/*
118   - is_lucene_running
119   - RUNNING=$?
120   -
121   - if [ $RUNNING -eq 1 ]; then
122   - echo "$0 $ARG: lucene (pid $LUCENE_PID) already running"
123   - else
124   - cd $INSTALL_PATH/knowledgeTree/bin/luceneserver
125   - nohup $LUCENE &> $INSTALL_PATH/var/log/dmsctl.log &
126   - if [ $? -eq 0 ]; then
127   - echo "$0 $ARG: lucene started"
128   - ps ax | grep ktlucene.jar | awk {'print $1'} > $LUCENE_PIDFILE
129   - sleep 2
130   - else
131   - echo "$0 $ARG: lucene could not be started"
132   - ERROR=3
133   - fi
134   - cd $INSTALL_PATH
135   -fi
136   -*/
137   - }
138   -
139   - public function is_lucene_running() {
140   -
141   - $pid = $this->get_lucene_pid();
142   - if($this->is_service_running($pid)) {
143   - echo 'Service is running';
144   - } else {
145   -
146   - }
147   -
148   -/* is_lucene_running() {
149   - get_lucene_pid
150   - is_service_running $LUCENE_PID
151   - RUNNING=$?
152   - if [ $RUNNING -eq 0 ]; then
153   - LUCENE_STATUS="lucene not running"
154   - else
155   - LUCENE_STATUS="lucene already running"
156   - fi
157   - return $RUNNING*/
158   - }
159   -
160   - public function is_service_running($pid) {
161   - $cmd = "kill -0 $pid 2>/dev/null";
162   - $response = $this->util->pexec($cmd);
163   -
164   - /*
165   -is_service_running() {
166   - PID=$1
167   - if [ "x$PID" != "x" ] && kill -0 $PID 2>/dev/null ; then
168   - RUNNING=1
169   - else
170   - RUNNING=0
171   - fi
172   - return $RUNNING
173   -}
174   -*/
175   - }
176   -
177   - public function get_lucene_pid() {
178   - // TODO: PID FILE
179   -/*get_lucene_pid() {
180   - get_pid $LUCENE_PIDFILE
181   - if [ ! $PID ]; then
182   - return
183   - fi
184   - if [ $PID -gt 0 ]; then
185   - LUCENE_PID=$PID
186   - fi
187   -}*/
188   - }
189   -
190   - public function get_pid() {
191   -
192   -/*get_pid() {
193   - PID=""
194   - PIDFILE=$1
195   - # check for pidfile
196   - if [ -f $PIDFILE ] ; then
197   - exec 6<&0
198   - exec < $PIDFILE
199   - read pid
200   - PID=$pid
201   - exec 0<&6 6<&-
202   - fi
203   -}*/
204   - }
205   -
206   - function shutdown()
207   - {
  217 + // Start lucene
  218 + public function start() {
208 219  
209   - $function=new xmlrpcmsg('control.shutdown',array(
210   - php_xmlrpc_encode((string) $this->ktid),
211   - php_xmlrpc_encode((string) $this->authToken)));
212   -
213   - $result=&$this->client->send($function);
214   - if($result->faultCode())
215   - {
216   - $this->error($result, 'shutdown');
217   - return false;
218   - }
219   - return true;
220   - }
  220 + }
  221 +
  222 +
221 223 }
222   -
223   -//$luc = new Lucene();
224   -//$luc->load();
225   -//$luc->start();
226   -//$luc->stop();
227 224 ?>
228 225 \ No newline at end of file
... ...
setup/wizard/unixScheduler.php 0 → 100644
  1 +<?php
  2 +/**
  3 +* Lucene Service Controller.
  4 +*
  5 +* KnowledgeTree Community Edition
  6 +* Document Management Made Simple
  7 +* Copyright(C) 2008,2009 KnowledgeTree Inc.
  8 +* Portions copyright The Jam Warehouse Software(Pty) Limited
  9 +*
  10 +* This program is free software; you can redistribute it and/or modify it under
  11 +* the terms of the GNU General Public License version 3 as published by the
  12 +* Free Software Foundation.
  13 +*
  14 +* This program is distributed in the hope that it will be useful, but WITHOUT
  15 +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  16 +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  17 +* details.
  18 +*
  19 +* You should have received a copy of the GNU General Public License
  20 +* along with this program. If not, see <http://www.gnu.org/licenses/>.
  21 +*
  22 +* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
  23 +* California 94120-7775, or email info@knowledgetree.com.
  24 +*
  25 +* The interactive user interfaces in modified source and object code versions
  26 +* of this program must display Appropriate Legal Notices, as required under
  27 +* Section 5 of the GNU General Public License version 3.
  28 +*
  29 +* In accordance with Section 7(b) of the GNU General Public License version 3,
  30 +* these Appropriate Legal Notices must retain the display of the "Powered by
  31 +* KnowledgeTree" logo and retain the original copyright notice. If the display of the
  32 +* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
  33 +* must display the words "Powered by KnowledgeTree" and retain the original
  34 +* copyright notice.
  35 +*
  36 +* @copyright 2008-2009, KnowledgeTree Inc.
  37 +* @license GNU General Public License version 3
  38 +* @author KnowledgeTree Team
  39 +* @package Installer
  40 +* @version Version 0.1
  41 +*/
  42 +
  43 +class unixScheduler extends Service {
  44 + public $name;
  45 + public $phpDir;
  46 + protected $schedulerPidFile;
  47 + protected $schedulerDir;
  48 + protected $schedulerSource;
  49 + protected $schedulerSourceLoc;
  50 + private $util = null;
  51 +
  52 + public function __construct() {
  53 + }
  54 +
  55 + function load() {
  56 + $this->name = "KTSchedulerTest";
  57 + $this->util = new InstallUtil();
  58 + $this->setSchedulerDir(SYSTEM_DIR."bin".DS);
  59 + $this->setSchedulerSource('schedulerTask.sh');
  60 + $this->setSchedulerSourceLoc('schedulerTask.sh');
  61 + $this->setSchedulerPidFile("scheduler_test.pid");
  62 + }
  63 +
  64 + private function setSchedulerPidFile($schedulerPidFile) {
  65 + $this->schedulerPidFile = $schedulerPidFile;
  66 + }
  67 +
  68 + private function getSchedulerPidFile() {
  69 + return $this->schedulerPidFile;
  70 + }
  71 +
  72 + function setSchedulerDir($schedulerDir) {
  73 + $this->schedulerDir = $schedulerDir;
  74 + }
  75 +
  76 + function getSchedulerDir() {
  77 + return $this->schedulerDir;
  78 + }
  79 +
  80 + function setSchedulerSource($schedulerSource) {
  81 + $this->schedulerSource = $schedulerSource;
  82 + }
  83 +
  84 + function getSchedulerSource() {
  85 + return $this->schedulerSource;
  86 + }
  87 +
  88 + function setSchedulerSourceLoc($schedulerSourceLoc) {
  89 + $this->schedulerSourceLoc = $this->getSchedulerDir().$schedulerSourceLoc;
  90 + }
  91 +
  92 + function getSchedulerSourceLoc() {
  93 + if(file_exists($this->schedulerSourceLoc)) {
  94 + return $this->schedulerSourceLoc;
  95 + }
  96 +// die('File Expected Error');
  97 + return false;
  98 + }
  99 +
  100 + function install() {
  101 + $source = $this->getSchedulerSourceLoc();
  102 + if($source) {
  103 + $cmd = "nohup ".$source." &> ".SYS_LOG_DIR."dmsctl.log";
  104 + $response = $this->util->pexec($cmd);
  105 + return $response;
  106 + }
  107 +
  108 + return false;
  109 + }
  110 +
  111 + function uninstall() {
  112 + $this->stop();
  113 + }
  114 +
  115 + function stop() {
  116 + $cmd = "pkill -f ".$this->name;
  117 + $response = $this->util->pexec($cmd);
  118 + return $response;
  119 + }
  120 +
  121 + function status() {
  122 + $cmd = "ps ax | grep ".$this->getSchedulerSource()." | awk {'print $1'}";
  123 + $response = $this->util->pexec($cmd);
  124 + if(is_array($response['out'])) {
  125 + if(count($response['out']) > 1) {
  126 + return 'STARTED';
  127 + } else {
  128 + return 'STOPPED';
  129 + }
  130 + }
  131 +
  132 + return 'STOPPED';
  133 + }
  134 +}
  135 +?>
0 136 \ No newline at end of file
... ...
setup/wizard/windowsAgent.php 0 → 100644
  1 +<?php
  2 +/**
  3 +* Windows Scheduler Service Controller.
  4 +*
  5 +* KnowledgeTree Community Edition
  6 +* Document Management Made Simple
  7 +* Copyright (C) 2008,2009 KnowledgeTree Inc.
  8 +* Portions copyright The Jam Warehouse Software (Pty) Limited
  9 +*
  10 +* This program is free software; you can redistribute it and/or modify it under
  11 +* the terms of the GNU General Public License version 3 as published by the
  12 +* Free Software Foundation.
  13 +*
  14 +* This program is distributed in the hope that it will be useful, but WITHOUT
  15 +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  16 +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  17 +* details.
  18 +*
  19 +* You should have received a copy of the GNU General Public License
  20 +* along with this program. If not, see <http://www.gnu.org/licenses/>.
  21 +*
  22 +* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
  23 +* California 94120-7775, or email info@knowledgetree.com.
  24 +*
  25 +* The interactive user interfaces in modified source and object code versions
  26 +* of this program must display Appropriate Legal Notices, as required under
  27 +* Section 5 of the GNU General Public License version 3.
  28 +*
  29 +* In accordance with Section 7(b) of the GNU General Public License version 3,
  30 +* these Appropriate Legal Notices must retain the display of the "Powered by
  31 +* KnowledgeTree" logo and retain the original copyright notice. If the display of the
  32 +* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
  33 +* must display the words "Powered by KnowledgeTree" and retain the original
  34 +* copyright notice.
  35 +*
  36 +* @copyright 2008-2009, KnowledgeTree Inc.
  37 +* @license GNU General Public License version 3
  38 +* @author KnowledgeTree Team
  39 +* @package Installer
  40 +* @version Version 0.1
  41 +*/
  42 +class windowsAgent {
  43 +// private $javaBin;
  44 +// private $javaJVM;
  45 +// private $javaSystem;
  46 + private $name;
  47 + private $schedulerScriptPath;
  48 + private $schedulerSource;
  49 +// private $luceneServer;
  50 + private $schedulerOut;
  51 + private $schedulerError;
  52 + private $schedulerDir;
  53 + private $util = null;
  54 +
  55 + public function __construct() {
  56 + }
  57 +
  58 + function load() {
  59 + $this->name = "KTSchedulerTest";
  60 + $this->util = new InstallUtil();
  61 +// $this->javaSystem = new Java('java.lang.System');
  62 +// $this->setJavaBin($this->javaSystem->getProperty('java.home').DS."bin");
  63 + $this->setSchedulerDIR(SYSTEM_DIR."bin".DS."win32");
  64 + $this->setSchedulerScriptPath("taskrunner.bat");
  65 +// $this->setJavaJVM();
  66 +// $this->setLuceneSource("ktlucene.jar");
  67 +// $this->setLuceneServer("com.knowledgetree.lucene.KTLuceneServer");
  68 + $this->setSchedulerOut("scheduler-out.txt");
  69 + $this->setSchedulerError("scheduler-err.txt");
  70 +
  71 + }
  72 +
  73 + private function setSchedulerScriptPath($schedulerScriptPath) {
  74 + $this->schedulerScriptPath = $schedulerScriptPath;
  75 + }
  76 +
  77 + public function getSchedulerScriptPath() {
  78 + return $this->schedulerScriptPath;
  79 + }
  80 +
  81 + private function setSchedulerDIR($luceneDir) {
  82 + $this->schedulerDir = $luceneDir;
  83 + }
  84 +
  85 + public function getSchedulerDir() {
  86 + return $this->schedulerDir;
  87 + }
  88 +
  89 +// private function setLuceneExe($luceneExe) {
  90 +// $this->luceneExe = $this->getluceneDir().DS.$luceneExe;
  91 +// }
  92 +
  93 +// public function getLuceneExe() {
  94 +// return $this->luceneExe;
  95 +// }
  96 +
  97 +// private function setLuceneSource($luceneSource) {
  98 +// $this->luceneSource = $this->getluceneDir().DS.$luceneSource;
  99 +// }
  100 +
  101 +// public function getLuceneSource() {
  102 +// return $this->luceneSource;
  103 +// }
  104 +
  105 +// private function setLuceneServer($luceneServer) {
  106 +// $this->luceneServer = $luceneServer;
  107 +// }
  108 +
  109 +// public function getLuceneServer() {
  110 +// return $this->luceneServer;
  111 +// }
  112 +
  113 + private function setSchedulerOut($luceneOut) {
  114 + $this->schedulerOut = SYS_LOG_DIR.$luceneOut;
  115 + }
  116 +
  117 + public function getSchedulerOut() {
  118 + return $this->schedulerOut;
  119 + }
  120 +
  121 + private function setSchedulerError($luceneError) {
  122 + $this->schedulerError = SYS_LOG_DIR.$luceneError;
  123 + }
  124 +
  125 + public function getSchedulerError() {
  126 + return $this->schedulerError;
  127 + }
  128 +
  129 +// private function setJavaJVM() {
  130 +// if(file_exists($this->getJavaBin().DS."client".DS."jvm.dll")) {
  131 +// $this->javaJVM = $this->getJavaBin().DS."client".DS."jvm.dll";
  132 +// } elseif (file_exists($this->getJavaBin().DS."server".DS."jvm.dll")) {
  133 +// $this->javaJVM = $this->getJavaBin().DS."server".DS."jvm.dll";
  134 +// }
  135 +// }
  136 +
  137 +// public function getJavaJVM() {
  138 +// return $this->javaJVM;
  139 +// }
  140 +
  141 + function start() {
  142 + $cmd = "sc start {$this->name}";
  143 + $response = $this->util->pexec($cmd);
  144 +
  145 + return $response;
  146 + }
  147 +
  148 + function stop() {
  149 + $cmd = "sc stop {$this->name}";
  150 + $response = $this->util->pexec($cmd);
  151 +
  152 + return $response;
  153 + }
  154 +
  155 + function install() {
  156 + echo $this->getSchedulerDir();
  157 +// die;
  158 + win32_create_service(array(
  159 + 'service' => 'KTScheduler',
  160 + 'display' => 'KTScheduler',
  161 + 'path' => $scriptPath
  162 + ));
  163 + die;
  164 +// $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";
  165 + $response = $this->util->pexec($cmd);
  166 +
  167 + return $response;
  168 + }
  169 +
  170 + function uninstall() {
  171 + $cmd = "sc delete {$this->name}";
  172 + $response = $this->util->pexec($cmd);
  173 +
  174 + return $response;
  175 + }
  176 +
  177 + function status() {
  178 + $cmd = "sc query {$this->name}";
  179 + $response = $this->util->pexec($cmd);
  180 + if($response['out']) {
  181 +//preg_match('/^STATE *\: *(\d) *(\w+)/', trim($response['out'][3]), $matches);
  182 + $state = preg_replace('/^STATE *\: *\d */', '', trim($response['out'][3])); // Status store in third key
  183 + return $state;
  184 + }
  185 + }
  186 +}
  187 +?>
0 188 \ No newline at end of file
... ...
setup/wizard/windowsLucene.php
1 1 <?php
2   -require_once("service.php");
3   -
4   -class Lucene {
  2 +/**
  3 +* Windows Lucene Service Controller.
  4 +*
  5 +* KnowledgeTree Community Edition
  6 +* Document Management Made Simple
  7 +* Copyright (C) 2008,2009 KnowledgeTree Inc.
  8 +* Portions copyright The Jam Warehouse Software (Pty) Limited
  9 +*
  10 +* This program is free software; you can redistribute it and/or modify it under
  11 +* the terms of the GNU General Public License version 3 as published by the
  12 +* Free Software Foundation.
  13 +*
  14 +* This program is distributed in the hope that it will be useful, but WITHOUT
  15 +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  16 +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  17 +* details.
  18 +*
  19 +* You should have received a copy of the GNU General Public License
  20 +* along with this program. If not, see <http://www.gnu.org/licenses/>.
  21 +*
  22 +* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
  23 +* California 94120-7775, or email info@knowledgetree.com.
  24 +*
  25 +* The interactive user interfaces in modified source and object code versions
  26 +* of this program must display Appropriate Legal Notices, as required under
  27 +* Section 5 of the GNU General Public License version 3.
  28 +*
  29 +* In accordance with Section 7(b) of the GNU General Public License version 3,
  30 +* these Appropriate Legal Notices must retain the display of the "Powered by
  31 +* KnowledgeTree" logo and retain the original copyright notice. If the display of the
  32 +* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
  33 +* must display the words "Powered by KnowledgeTree" and retain the original
  34 +* copyright notice.
  35 +*
  36 +* @copyright 2008-2009, KnowledgeTree Inc.
  37 +* @license GNU General Public License version 3
  38 +* @author KnowledgeTree Team
  39 +* @package Installer
  40 +* @version Version 0.1
  41 +*/
  42 +class windowsLucene extends Service {
5 43 private $javaBin;
6 44 private $javaJVM;
7 45 private $javaSystem;
8   - private $name;
  46 +// private $name;
9 47 private $luceneExe;
10 48 private $luceneSource;
11 49 private $luceneServer;
... ... @@ -19,9 +57,10 @@ class Lucene {
19 57  
20 58 function load() {
21 59 $this->name = "KTLuceneTest";
  60 + $this->util = new InstallUtil();
22 61 $this->javaSystem = new Java('java.lang.System');
23 62 $this->setJavaBin($this->javaSystem->getProperty('java.home').DS."bin");
24   - $this->setLuceneDIR(SYS_DIR.DS."bin".DS."luceneserver");
  63 + $this->setLuceneDIR(SYSTEM_DIR."bin".DS."luceneserver");
25 64 $this->setLuceneExe("KTLuceneService.exe");
26 65 $this->setJavaJVM();
27 66 $this->setLuceneSource("ktlucene.jar");
... ... @@ -72,7 +111,7 @@ class Lucene {
72 111 }
73 112  
74 113 private function setLuceneOut($luceneOut) {
75   - $this->luceneOut = SYS_LOG_DIR.DS.$luceneOut;
  114 + $this->luceneOut = SYS_LOG_DIR.$luceneOut;
76 115 }
77 116  
78 117 public function getLuceneOut() {
... ... @@ -80,7 +119,7 @@ class Lucene {
80 119 }
81 120  
82 121 private function setLuceneError($luceneError) {
83   - $this->luceneError = SYS_LOG_DIR.DS.$luceneError;
  122 + $this->luceneError = SYS_LOG_DIR.$luceneError;
84 123 }
85 124  
86 125 public function getLuceneError() {
... ... @@ -100,36 +139,43 @@ class Lucene {
100 139 }
101 140  
102 141 function start() {
103   - // windows
104 142 $cmd = "sc start {$this->name}";
105   -// echo "start\n$cmd<br/>";
106   - $response = exec($cmd);
107   - // linux
108   - // zend
  143 + $response = $this->util->pexec($cmd);
  144 +
  145 + return $response;
109 146 }
110 147  
111 148 function stop() {
112 149 $cmd = "sc stop {$this->name}";
113   - echo "stop\n$cmd<br/>";
114   - $response = exec($cmd);
  150 + $response = $this->util->pexec($cmd);
  151 +
  152 + return $response;
115 153 }
116 154  
117 155 function install() {
118   - $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";
119   -// echo "install\n$cmd<br/>";
120   - $response = exec($cmd);
  156 + $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";
  157 + $response = $this->util->pexec($cmd);
  158 +
  159 + return $response;
121 160 }
122 161  
123 162 function uninstall() {
124 163 $cmd = "sc delete {$this->name}";
125   -// echo "uninstall\n$cmd<br/>";
126   - $response = exec($cmd);
  164 + $response = $this->util->pexec($cmd);
  165 +
  166 + return $response;
127 167 }
  168 +
  169 + function status() {
  170 + $cmd = "sc query {$this->name}";
  171 + $response = $this->util->pexec($cmd);
  172 + if($response['out']) {
  173 +//preg_match('/^STATE *\: *(\d) *(\w+)/', trim($response['out'][3]), $matches);
  174 + $state = preg_replace('/^STATE *\: *\d */', '', trim($response['out'][3])); // Status store in third key
  175 + return $state;
  176 + }
  177 + }
  178 +
  179 +
128 180 }
129   -$lucene = new Lucene();
130   -$lucene->load();
131   -$lucene->install();
132   -$lucene->start();
133   -$lucene->stop();
134   -$lucene->uninstall();
135 181 ?>
136 182 \ No newline at end of file
... ...
setup/wizard/windowsScheduler.php 0 → 100644
  1 +<?php
  2 +/**
  3 +* Windows Scheduler Service Controller.
  4 +*
  5 +* KnowledgeTree Community Edition
  6 +* Document Management Made Simple
  7 +* Copyright (C) 2008,2009 KnowledgeTree Inc.
  8 +* Portions copyright The Jam Warehouse Software (Pty) Limited
  9 +*
  10 +* This program is free software; you can redistribute it and/or modify it under
  11 +* the terms of the GNU General Public License version 3 as published by the
  12 +* Free Software Foundation.
  13 +*
  14 +* This program is distributed in the hope that it will be useful, but WITHOUT
  15 +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  16 +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  17 +* details.
  18 +*
  19 +* You should have received a copy of the GNU General Public License
  20 +* along with this program. If not, see <http://www.gnu.org/licenses/>.
  21 +*
  22 +* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
  23 +* California 94120-7775, or email info@knowledgetree.com.
  24 +*
  25 +* The interactive user interfaces in modified source and object code versions
  26 +* of this program must display Appropriate Legal Notices, as required under
  27 +* Section 5 of the GNU General Public License version 3.
  28 +*
  29 +* In accordance with Section 7(b) of the GNU General Public License version 3,
  30 +* these Appropriate Legal Notices must retain the display of the "Powered by
  31 +* KnowledgeTree" logo and retain the original copyright notice. If the display of the
  32 +* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
  33 +* must display the words "Powered by KnowledgeTree" and retain the original
  34 +* copyright notice.
  35 +*
  36 +* @copyright 2008-2009, KnowledgeTree Inc.
  37 +* @license GNU General Public License version 3
  38 +* @author KnowledgeTree Team
  39 +* @package Installer
  40 +* @version Version 0.1
  41 +*/
  42 +class windowsScheduler extends Service {
  43 + //private $name;
  44 + private $schedulerScriptPath;
  45 + private $schedulerSource;
  46 + private $schedulerOut;
  47 + private $schedulerError;
  48 + private $schedulerDir;
  49 + private $util = null;
  50 +
  51 + public function __construct() {
  52 + }
  53 +
  54 + function load() {
  55 + $this->name = "KTSchedulerTest";
  56 + $this->util = new InstallUtil();
  57 + $this->setSchedulerDIR(SYSTEM_DIR."bin".DS."win32");
  58 + $this->setSchedulerScriptPath("taskrunner_test.bat");
  59 + $this->setSchedulerSource("schedulerService.php");
  60 + }
  61 +
  62 + private function setSchedulerScriptPath($schedulerScriptPath) {
  63 + $this->schedulerScriptPath = "{$this->getSchedulerDir()}".DS."$schedulerScriptPath";
  64 + }
  65 +
  66 + public function getSchedulerScriptPath() {
  67 + return $this->schedulerScriptPath;
  68 + }
  69 +
  70 + private function setSchedulerDIR($luceneDir) {
  71 + $this->schedulerDir = $luceneDir;
  72 + }
  73 +
  74 + public function getSchedulerDir() {
  75 + return $this->schedulerDir;
  76 + }
  77 +
  78 + private function setSchedulerSource($schedulerSource) {
  79 + $this->schedulerSource = $this->getSchedulerDir().DS.$schedulerSource;
  80 + }
  81 +
  82 + public function getSchedulerSource() {
  83 + return $this->schedulerSource;
  84 + }
  85 +
  86 + public function start() {
  87 + $cmd = "sc start {$this->name}";
  88 + $response = $this->util->pexec($cmd);
  89 +
  90 + return $response;
  91 + }
  92 +
  93 + public function stop() {
  94 + $cmd = "sc stop {$this->name}";
  95 + $response = $this->util->pexec($cmd);
  96 +
  97 + return $response;
  98 + }
  99 +
  100 + public function install() {
  101 + $pathToSCode = $this->getSchedulerSource();
  102 + $fp = fopen($this->schedulerScriptPath, "w+");
  103 + $content = "@echo off\n";
  104 + $content .= "\"".PHP_DIR."php.exe\" "."\"{$this->schedulerSource}\"";
  105 + fwrite($fp, $content);
  106 + fclose($fp);
  107 + $response = win32_create_service(array(
  108 + 'service' => $this->name,
  109 + 'display' => $this->name,
  110 + 'path' => $this->schedulerScriptPath
  111 + ));
  112 +
  113 + return $response;
  114 + }
  115 +
  116 + public function uninstall() {
  117 + $cmd = "sc delete {$this->name}";
  118 + $response = $this->util->pexec($cmd);
  119 +
  120 + return $response;
  121 + }
  122 +
  123 + public function status() {
  124 + $cmd = "sc query {$this->name}";
  125 + $response = $this->util->pexec($cmd);
  126 + if($response['out']) {
  127 +//preg_match('/^STATE *\: *(\d) *(\w+)/', trim($response['out'][3]), $matches);
  128 + $state = preg_replace('/^STATE *\: *\d */', '', trim($response['out'][3])); // Status store in third key
  129 + return $state;
  130 + }
  131 + }
  132 +}
  133 +?>
0 134 \ No newline at end of file
... ...