Esempio n. 1
0
 /**
  * Undeploys a Module in the Module server.
  *
  * @param string $location Module name.
  * @return boolean
  * @since 5.1
  */
 public function undeploy($location)
 {
     // Checks if the specified Module exists.
     $context = \Innomatic\Module\Server\ModuleServerContext::instance('\\Innomatic\\Module\\Server\\ModuleServerContext');
     if (!is_dir($context->getHome() . 'core/modules' . DIRECTORY_SEPARATOR . $location)) {
         throw new \Innomatic\Module\ModuleException('No such Module');
     }
     // Executes Module undeploy hooked actions.
     $auth = \Innomatic\Module\Server\ModuleServerAuthenticator::instance('ModuleServerAuthenticator');
     $module = \Innomatic\Module\ModuleFactory::getModule(new ModuleLocator('module://*****:*****@/' . $location));
     $module->undeploy();
     // Removes Module.
     \Innomatic\Io\Filesystem\DirectoryUtils::unlinkTree($context->getHome() . 'core/modules' . DIRECTORY_SEPARATOR . $location);
     // Logs undeployment.
     if ($context->getConfig()->getKey('log_deployer_events') == 1 or $context->getConfig()->useDefaults()) {
         $logger = new \Innomatic\Module\Server\ModuleServerLogger($context->getHome() . 'core/log/module-deployer.log');
         $logger->logEvent($location . ' undeployed');
     }
     return true;
 }
 /**
  * Parses Module registry configuration from an XML file downloaded from a remote server;
  * then stores it in a structured array.
  *
  * @param string $host the host from which the registry has to be loaded
  * @param string $port the port on the remote host
  * @since 5.1
  * @return void
  */
 private function downloadRemoteRegistry($address, $port)
 {
     print "downloadRemoteRegistry: inizio\r\n";
     $result = '';
     try {
         $auth = \Innomatic\Module\Server\ModuleServerAuthenticator::instance('ModuleServerAuthenticator');
         $socket = new \Innomatic\Net\Socket\Socket();
         $socket->connect($address, $port);
         $request = 'GET_REGISTRY Module/1.1' . "\r\n";
         $request .= 'User: admin' . "\r\n";
         $request .= 'Password: '******'admin') . "\r\n";
         print "Request content:\r\n" . $request . "\n";
         $socket->write($request);
         $result = trim($socket->readAll());
         print "Result content:\r\n" . $result . "\n";
         $socket->disconnect();
     } catch (\Innomatic\Net\Socket\SocketException $e) {
         $result = "Module: services-extension cannot download up-to-date registry from {$address}:{$port}";
     }
     $context = \Innomatic\Module\Server\ModuleServerContext::instance('\\Innomatic\\Module\\Server\\ModuleServerContext');
     $file_registry = fopen($context->getHome() . 'core/conf/modules-netregistry-remote.xml', 'x');
     if ($file_registry == false) {
         unlink($context->getHome() . 'core/conf/modules-netregistry-remote.xml');
         $file_registry = fopen($context->getHome() . 'core/conf/modules-netregistry-remote.xml', 'x');
     }
     fwrite($file_registry, $result);
     fclose($file_registry);
 }