diff --git a/setup/wizard/ini.php b/setup/wizard/ini.php index c5e491f..ce12911 100644 --- a/setup/wizard/ini.php +++ b/setup/wizard/ini.php @@ -205,6 +205,10 @@ class Ini { unset($this->cleanArray[$delSection]); return true; } - + + public function getFileByLine() { + $data = $this->read($this->iniFile); + return $data['']; + } } ?> diff --git a/setup/wizard/lib/helpers/config-path-mock b/setup/wizard/lib/helpers/config-path-mock new file mode 100644 index 0000000..3f0bb4d --- /dev/null +++ b/setup/wizard/lib/helpers/config-path-mock @@ -0,0 +1,9 @@ +/var/www/installers/knowledgetree/config/config.ini +/var/www/installers/knowledgetree/var_test/cache +/var/www/installers/knowledgetree/var_test/Documents +/var/www/installers/knowledgetree/var_test/indexes +/var/www/installers/knowledgetree/var_test/log +/var/www/installers/knowledgetree/var_test/Pdf +/var/www/installers/knowledgetree/var_test/proxies +/var/www/installers/knowledgetree/var_test/tmp +/var/www/installers/knowledgetree/var_test/uploads \ No newline at end of file diff --git a/setup/wizard/lib/helpers/demo.sh b/setup/wizard/lib/helpers/demo.sh index e005f68..7f6fc6f 100755 --- a/setup/wizard/lib/helpers/demo.sh +++ b/setup/wizard/lib/helpers/demo.sh @@ -5,3 +5,7 @@ rm ../../../../var/log/scheduler.log; rm ../../../../var/log/openoffice.log; rm ../../../../bin/luceneserver/KnowledgeTreeIndexer.properties; rm ../../../../setup/wizard/output/outJV; +pkill -f lucene; +pkill -f scheduler; +pkill -f openoffice; + diff --git a/setup/wizard/lib/services/unixLucene.php b/setup/wizard/lib/services/unixLucene.php index 02993c8..5e6c51c 100644 --- a/setup/wizard/lib/services/unixLucene.php +++ b/setup/wizard/lib/services/unixLucene.php @@ -181,9 +181,13 @@ class unixLucene extends unixService { public function start() { $state = $this->status(); if($state != 'STARTED') { - $this->writeLuceneProperties(); + //$this->writeLuceneProperties(); $cmd = "cd ".$this->getLuceneDir()."; "; $cmd .= "nohup java -jar ".$this->getLuceneSource()." > ".SYS_LOG_DIR."lucene.log 2>&1 & echo $!"; + if(DEBUG) { + echo "$cmd
"; + return ; + } $response = $this->util->pexec($cmd); return $response; diff --git a/setup/wizard/lib/services/unixOpenOffice.php b/setup/wizard/lib/services/unixOpenOffice.php index 7f59555..79aaa50 100644 --- a/setup/wizard/lib/services/unixOpenOffice.php +++ b/setup/wizard/lib/services/unixOpenOffice.php @@ -156,6 +156,10 @@ class unixOpenOffice extends unixService { $state = $this->status(); if($state != 'STARTED') { $cmd = "nohup {$this->getBin()} ".$this->getOption()." > ".SYS_LOG_DIR."{$this->getLog()} 2>&1 & echo $!"; + if(DEBUG) { + echo "$cmd
"; + return ; + } $response = $this->util->pexec($cmd); return $response; diff --git a/setup/wizard/lib/services/unixScheduler.php b/setup/wizard/lib/services/unixScheduler.php index ad71868..8042aed 100644 --- a/setup/wizard/lib/services/unixScheduler.php +++ b/setup/wizard/lib/services/unixScheduler.php @@ -56,7 +56,7 @@ class unixScheduler extends unixService { public function load() { $this->setSystemDir(SYSTEM_ROOT."bin".DS); - $this->setSchedulerDir(SYSTEM_DIR."bin".DS); + $this->setSchedulerDir(VAR_BIN_DIR); $this->setSchedulerSourceLoc('schedulerTask.sh'); } @@ -156,16 +156,17 @@ class unixScheduler extends unixService { $this->writeSchedulerTask(); if($source) { // Source $cmd = "nohup ".$source." > ".SYS_LOG_DIR."scheduler.log 2>&1 & echo $!"; - $response = $this->util->pexec($cmd); - return $response; } else { // Could be Stack $source = SYS_BIN_DIR.$this->schedulerSource; $cmd = "nohup ".$source." > ".SYS_LOG_DIR."scheduler.log 2>&1 & echo $!"; - $response = $this->util->pexec($cmd); - return $response; } - - return false; + if(DEBUG) { + echo "$cmd
"; + return ; + } + $response = $this->util->pexec($cmd); + + return $response; } diff --git a/setup/wizard/lib/services/windowsLucene.php b/setup/wizard/lib/services/windowsLucene.php index 157a34b..c081971 100644 --- a/setup/wizard/lib/services/windowsLucene.php +++ b/setup/wizard/lib/services/windowsLucene.php @@ -434,7 +434,8 @@ class windowsLucene extends windowsService { $content .= "server.paranoid=false\n"; $content .= "server.accept=127.0.0.1\n"; $content .= "server.deny=\n"; - $content .= "indexer.directory=../../var/indexes\n"; + $content .= "indexer.directory=".SYS_VAR_DIR."indexes\n"; + //$content .= "indexer.directory=../../var/indexes\n"; $content .= "indexer.analyzer=org.apache.lucene.analysis.standard.StandardAnalyzer\n"; fwrite($fp, $content); fclose($fp); diff --git a/setup/wizard/output/dummy.txt b/setup/wizard/output/dummy.txt deleted file mode 100644 index e69de29..0000000 --- a/setup/wizard/output/dummy.txt +++ /dev/null diff --git a/setup/wizard/path.php b/setup/wizard/path.php index 75bb6e6..a6d03fa 100644 --- a/setup/wizard/path.php +++ b/setup/wizard/path.php @@ -74,11 +74,13 @@ define('STEP_DIR', WIZARD_DIR."steps".DS); define('TEMP_DIR', WIZARD_DIR."templates".DS); define('SHELL_DIR', WIZARD_DIR."shells".DS); - define('OUTPUT_DIR', WIZARD_DIR."output".DS); // Define paths to system webroot define('SYSTEM_DIR', $sys); + define('SYS_VAR_DIR', SYSTEM_DIR."var".DS); define('SYS_BIN_DIR', SYSTEM_DIR."bin".DS); - define('SYS_LOG_DIR', SYSTEM_DIR."var".DS."log".DS); + define('SYS_LOG_DIR', SYS_VAR_DIR."log".DS); + define('SYS_OUT_DIR', SYS_VAR_DIR); + define('VAR_BIN_DIR', SYS_VAR_DIR."bin".DS); // Define paths to system array_pop($xdir); $asys = ''; diff --git a/setup/wizard/steps/configuration.php b/setup/wizard/steps/configuration.php index af209b9..70fd679 100644 --- a/setup/wizard/steps/configuration.php +++ b/setup/wizard/steps/configuration.php @@ -450,8 +450,9 @@ class configuration extends Step if(isset($this->temp_variables['paths'])) { $dirs = $this->temp_variables['paths']; // Pull from temp } else { -// $dirs = $this->getDirectories(); - $this->readConfigPath(); + if(!$this->readConfigPath()) { // Read the configuration + + } $dirs = $this->getFromConfigPath(); } $varDirectory = $fileSystemRoot . DS . 'var'; @@ -497,7 +498,7 @@ class configuration extends Step array('name' => 'Log Directory', 'setting' => 'logDirectory', 'path' => '${varDirectory}/log', 'create' => true), array('name' => 'Temporary Directory', 'setting' => 'tmpDirectory', 'path' => '${varDirectory}/tmp', 'create' => true), array('name' => 'Uploads Directory', 'setting' => 'uploadDirectory', 'path' => '${varDirectory}/uploads', 'create' => true), - array('name' => 'Executables Directory', 'setting' => 'binDirectory', 'path' => '${fileSystemRoot}/bin', 'create' => false), + array('name' => 'Executables Directory', 'setting' => 'binDirectory', 'path' => '${varDirectory}/bin', 'create' => false), array('name' => 'Configuration File', 'setting' => 'configFile', 'path' => '${fileSystemRoot}/config/config.ini', 'create' => false), ); } @@ -505,6 +506,10 @@ class configuration extends Step /** * Store contents of edited settings * + * @author KnowledgeTree Team + * @access private + * @param none + * @return array The path information */ private function setFromPost() { $this->paths = array( @@ -513,7 +518,7 @@ class configuration extends Step array('name' => 'Log Directory', 'setting' => 'logDirectory', 'path' => $_POST['logDirectory'], 'create' => true), array('name' => 'Temporary Directory', 'setting' => 'tmpDirectory', 'path' => $_POST['tmpDirectory'], 'create' => true), array('name' => 'Uploads Directory', 'setting' => 'uploadDirectory', 'path' => $_POST['uploadDirectory'], 'create' => true), - array('name' => 'Executables Directory', 'setting' => 'binDirectory', 'path' => $_POST['binDirectory'], 'create' => false), + array('name' => 'Executables Directory', 'setting' => 'binDirectory', 'path' => $_POST['uploadDirectory'], 'create' => true), array('name' => 'Configuration File', 'setting' => 'configFile', 'path' => $_POST['configFile'], 'create' => false), ); } @@ -521,20 +526,36 @@ class configuration extends Step /** * Store contents of edited settings * + * @author KnowledgeTree Team + * @access private + * @param none + * @return array The path information */ private function getFromConfigPath() { - return array( - array('name' => 'Configuration File', 'setting' => 'configFile', 'path' => $this->confpaths['configIni'], 'create' => false), - array('name' => 'Document Directory', 'setting' => 'documentRoot', 'path' => $this->confpaths['Documents'], 'create' => true), - array('name' => 'Cache Directory', 'setting' => 'cacheDirectory', 'path' => $this->confpaths['cache'], 'create' => true), - array('name' => 'Index Directory', 'setting' => 'indexDirectory', 'path' => $this->confpaths['indexes'], 'create' => true), - array('name' => 'Log Directory', 'setting' => 'logDirectory', 'path' => $this->confpaths['log'], 'create' => true), - array('name' => 'Proxy Directory', 'setting' => 'proxiesDirectory', 'path' => $this->confpaths['proxies'], 'create' => true), - array('name' => 'Temporary Directory', 'setting' => 'tmpDirectory', 'path' => $this->confpaths['tmp'], 'create' => true), - array('name' => 'Uploads Directory', 'setting' => 'uploadDirectory', 'path' => $this->confpaths['uploads'], 'create' => true), - ); + if(isset($this->confpaths['Documents'])) { // Simple check to see if any paths were written + return array ( + array('name' => 'Configuration File', 'setting' => 'configFile', 'path' => $this->confpaths['configIni'], 'create' => false), + array('name' => 'Document Directory', 'setting' => 'documentRoot', 'path' => $this->confpaths['Documents'], 'create' => true), + array('name' => 'Cache Directory', 'setting' => 'cacheDirectory', 'path' => $this->confpaths['cache'], 'create' => true), + array('name' => 'Index Directory', 'setting' => 'indexDirectory', 'path' => $this->confpaths['indexes'], 'create' => true), + array('name' => 'Log Directory', 'setting' => 'logDirectory', 'path' => $this->confpaths['log'], 'create' => true), + array('name' => 'Proxy Directory', 'setting' => 'proxiesDirectory', 'path' => $this->confpaths['proxies'], 'create' => true), + array('name' => 'Temporary Directory', 'setting' => 'tmpDirectory', 'path' => $this->confpaths['tmp'], 'create' => true), + array('name' => 'Uploads Directory', 'setting' => 'uploadDirectory', 'path' => $this->confpaths['uploads'], 'create' => true), + ); + } else { + return $this->getDirectories(); + } } + /** + * Path information + * + * @author KnowledgeTree Team + * @access public + * @param string $fileSystemRoot The file system root of the installation + * @return array The path information + */ public function getFromPost() { return $this->paths; } @@ -542,14 +563,16 @@ class configuration extends Step /** * Read contents of config path file * + * @author KnowledgeTree Team + * @access private + * @param none + * @return array The path information */ private function readConfigPath() { - $configPath = realpath('../../../config/config-path'); - if($configPath == '') - $configPath = realpath('../../config/config-path'); + $configPath = $this->getContentPath(); + if(!$configPath) return false; $ini = new Ini($configPath); - $data = $ini->read($configPath); - $data = $data['']; + $data = $ini->getFileByLine(); foreach ($data as $k=>$v) { if(preg_match('/config.ini/', $k)) { $this->confpaths['configIni'] = $k; @@ -570,20 +593,22 @@ class configuration extends Step } } - return false; + return true; } /** * Read contents of config path file * + * @author KnowledgeTree Team + * @access private + * @param none + * @return boolean */ private function writeConfigPath() { - $configPath = realpath('../../../config/config-path'); - if($configPath == '') - $configPath = realpath('../../config/config-path'); + $configPath = $this->getContentPath(); + if(!$configPath) return false; $ini = new Ini($configPath); - $data = $ini->read($configPath); - $data = $data['']; + $data = $ini->getFileByLine(); $configContent = ''; foreach ($data as $k=>$v) { if(preg_match('/config.ini/', $k)) { @@ -597,13 +622,24 @@ class configuration extends Step return true; } + /** + * Attempt to locate config-path file in system + * + * @author KnowledgeTree Team + * @access private + * @param none + * @return mixed + */ + public function getContentPath() { + $configPath = realpath('../../../config/config-path'); + if($configPath == '') + $configPath = realpath('../../config/config-path'); + if(!$configPath) return false; + return $configPath; + } + public function doReadConfig() { - $this->readConfigPath(); -// $this->writeConfigPath(); - $configPaths = $this->getFromConfigPath(); -// echo '
';
-//    	print_r($configPaths);
-//    	echo '
'; + } } diff --git a/setup/wizard/steps/services.php b/setup/wizard/steps/services.php index 4446a61..f88f90c 100644 --- a/setup/wizard/steps/services.php +++ b/setup/wizard/steps/services.php @@ -660,10 +660,10 @@ class services extends Step } $javaExecutable = $this->java; } - $cmd = "\"$javaExecutable\" -version > output/outJV 2>&1 echo $!"; + $cmd = "\"$javaExecutable\" -version > ".SYS_OUT_DIR."/outJV 2>&1 echo $!"; $response = $this->util->pexec($cmd); - if(file_exists(OUTPUT_DIR.'outJV')) { - $tmp = file_get_contents(OUTPUT_DIR.'outJV'); + if(file_exists(SYS_OUT_DIR.'outJV')) { + $tmp = file_get_contents(SYS_OUT_DIR.'outJV'); preg_match('/"(.*)"/',$tmp, $matches); if($matches) { if($matches[1] < $this->javaVersion) { // Check Version of java @@ -704,10 +704,10 @@ class services extends Step // TODO: Better php handling return true; $phpExecutable = $this->util->phpSpecified();// Retrieve java bin - $cmd = "$phpExecutable -version > output/outPHP 2>&1 echo $!"; + $cmd = "$phpExecutable -version > ".SYS_OUT_DIR."/outPHP 2>&1 echo $!"; $response = $this->util->pexec($cmd); - if(file_exists(OUTPUT_DIR.'outPHP')) { - $tmp = file_get_contents(OUTPUT_DIR.'outPHP'); + if(file_exists(SYS_OUT_DIR.'outPHP')) { + $tmp = file_get_contents(SYS_OUT_DIR.'outPHP'); preg_match('/PHP/',$tmp, $matches); if($matches) { $this->phpCheck = 'tick'; diff --git a/var/bin/schedulerTask.sh b/var/bin/schedulerTask.sh new file mode 100644 index 0000000..e3919de --- /dev/null +++ b/var/bin/schedulerTask.sh @@ -0,0 +1 @@ +// DO NOT DELETE