protected function deployApplication($packageDir)
 {
     // Add vendor autoloads to access Innomatic Legacy Kernel bridge
     $vendorDir = $this->composer->getConfig()->get('vendor-dir');
     require $vendorDir . '/autoload.php';
     $legacyKernel = new Kernel();
     $result = $legacyKernel->runCallback(function () use($packageDir) {
         $app = new \Innomatic\Application\Application(InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getDataAccess());
         $result['status'] = true;
         $result['unmetdeps'] = '';
         if (!$app->install($packageDir)) {
             $unmetDeps = $app->getLastActionUnmetDeps();
             $unmetDepsStr = '';
             while (list(, $val) = each($unmetDeps)) {
                 $unmetDepsStr .= ' ' . $val;
             }
             $result['status'] = false;
             $result['unmetdeps'] = $unmetDepsStr;
         }
         return $result;
     });
     if (!$result['status']) {
         throw new \RuntimeException("Dependencies error:" . $result['unmetdeps']);
     }
 }
 /**
  * Bootstraps the Innomatic container.
  *
  * @param string $home Complete path of the directory containing the
  * Innomatic webapp.
  * @param string $configuration Complete path of the Innomatic
  * configuration file.
  */
 public function bootstrap($home, $configuration)
 {
     if ($this->bootstrapped) {
         return;
     }
     $this->home = $home;
     // Reads the configuration
     $this->configurationFile = $configuration;
     $this->config = new InnomaticSettings($configuration);
     // *********************************************************************
     // PHP environment
     // *********************************************************************
     // PHP
     $timelimit = $this->config->value('PHPExecutionTimeLimit');
     if (!strlen($timelimit)) {
         $timelimit = 0;
     }
     set_time_limit($timelimit);
     ignore_user_abort(true);
     // Adds global override classes folder to the include path.
     set_include_path($this->home . 'core/overrides/classes/' . PATH_SEPARATOR . get_include_path());
     // *********************************************************************
     // Innomatic state, environment, mode, interface and edition
     // *********************************************************************
     // Waits until system is in upgrade phase
     if ($this->lockOverride == false) {
         while (file_exists($this->home . 'core/temp/upgrading_system_lock')) {
             $this->state = \Innomatic\Core\InnomaticContainer::STATE_UPGRADE;
             clearstatcache();
             sleep(1);
         }
     }
     // Checks if system is in setup phase and sets the state
     if (file_exists($this->home . 'core/temp/setup_lock')) {
         $this->state = \Innomatic\Core\InnomaticContainer::STATE_SETUP;
         if (extension_loaded('APD')) {
             apd_set_session_trace(35);
         }
     } else {
         switch ($this->config->value('PlatformState')) {
             case 'debug':
                 $this->state = \Innomatic\Core\InnomaticContainer::STATE_DEBUG;
                 if (extension_loaded('APD')) {
                     apd_set_session_trace(35);
                 }
                 break;
             case 'production':
                 $this->state = \Innomatic\Core\InnomaticContainer::STATE_PRODUCTION;
                 break;
             default:
                 $this->state = \Innomatic\Core\InnomaticContainer::STATE_PRODUCTION;
         }
     }
     // Environment
     switch ($this->config->value('PlatformEnvironment')) {
         case 'development':
             $this->environment = \Innomatic\Core\InnomaticContainer::ENVIRONMENT_DEVELOPMENT;
             break;
         case 'integration':
             $this->environment = \Innomatic\Core\InnomaticContainer::ENVIRONMENT_INTEGRATION;
             break;
         case 'staging':
             $this->environment = \Innomatic\Core\InnomaticContainer::ENVIRONMENT_STAGING;
             break;
         case 'production':
             $this->environment = \Innomatic\Core\InnomaticContainer::ENVIRONMENT_PRODUCTION;
             break;
         default:
             $this->environment = \Innomatic\Core\InnomaticContainer::ENVIRONMENT_PRODUCTION;
     }
     // Interface
     //$this->interface = \Innomatic\Core\InnomaticContainer::INTERFACE_UNKNOWN;
     // Mode
     //$this->mode = \Innomatic\Core\InnomaticContainer::MODE_ROOT;
     // Edition
     if ($this->config->value('PlatformEdition') == 'enterprise' or $this->config->value('PlatformEdition') == 'singletenant') {
         $this->edition = \Innomatic\Core\InnomaticContainer::EDITION_SINGLETENANT;
     }
     // *********************************************************************
     // Pid and shutdown function
     // *********************************************************************
     if ($this->state != \Innomatic\Core\InnomaticContainer::STATE_SETUP) {
         $this->pid = md5(microtime());
         if (!file_exists($this->home . 'core/temp/pids/')) {
             @mkdir($this->home . 'core/temp/pids/');
         }
         touch($this->home . 'core/temp/pids/' . $this->pid, time());
         register_shutdown_function(array($this, 'shutdown'));
     }
     // *********************************************************************
     // Innomatic platform name
     // *********************************************************************
     $this->platformName = $this->config->value('PlatformName');
     $this->platformGroup = $this->config->value('PlatformGroup');
     // *********************************************************************
     // Innomatic error handler
     // *********************************************************************
     //set_error_handler(array($this, 'errorHandler'));
     // *********************************************************************
     // Innomatic root
     // *********************************************************************
     $this->country = $this->config->value('RootCountry');
     $this->language = $this->config->value('RootLanguage');
     if ($this->state != \Innomatic\Core\InnomaticContainer::STATE_SETUP) {
         // Innomatic central database
         //
         $dasnString = $this->config->value('RootDatabaseType') . '://' . $this->config->value('RootDatabaseUser') . ':' . $this->config->value('RootDatabasePassword') . '@' . $this->config->value('RootDatabaseHost') . ':' . $this->config->value('RootDatabasePort') . '/' . $this->config->value('RootDatabaseName') . '?' . 'logfile=' . $this->getHome() . 'core/log/innomatic_root_db.log';
         $this->rootDb = \Innomatic\Dataaccess\DataAccessFactory::getDataAccess(new \Innomatic\Dataaccess\DataAccessSourceName($dasnString));
         if (!$this->rootDb->connect()) {
             $this->abort('Database not connected');
         }
     }
     // *********************************************************************
     // Run time state and interface defined data
     // *********************************************************************
     // Debugger
     if ($this->state == \Innomatic\Core\InnomaticContainer::STATE_DEBUG) {
         $this->loadTimer = new \Innomatic\Debug\LoadTime(LoadTime::LOADTIME_MODE_CONTINUOUS);
         $this->loadTimer->Mark('start');
         $this->dbLoadTimer = new \Innomatic\Debug\LoadTime(LoadTime::LOADTIME_MODE_STARTSTOP);
     }
     // Security
     $securityReportsInterval = $this->config->value('SecurityReportsInterval');
     if ($securityReportsInterval > 0) {
         $lastSecurityReport = $this->config->value('SecurityLastReportTime');
         if (!$lastSecurityReport or $lastSecurityReport < time() - $securityReportsInterval * 3600 * 24) {
             $innomaticSecurity = new \Innomatic\Security\SecurityManager();
             $innomaticSecurity->sendReport();
             unset($innomaticSecurity);
         }
     }
     unset($securityReportsInterval);
     // Maintenance
     $maintenanceHandler = new \Innomatic\Maintenance\MaintenanceHandler();
     $maintenanceInterval = $maintenanceHandler->getMaintenanceInterval();
     if ($this->state != \Innomatic\Core\InnomaticContainer::STATE_MAINTENANCE and $maintenanceInterval > 0) {
         $lastMaintenance = $maintenanceHandler->getLastMaintenanceTime();
         if (!$lastMaintenance or $lastMaintenance < time() - $maintenanceInterval * 3600 * 24) {
             $innomaticMaintenance = new \Innomatic\Maintenance\MaintenanceHandler();
             $innomaticMaintenance->doMaintenance();
             $innomaticMaintenance->sendReport();
             unset($innomaticMaintenance);
         }
     }
     unset($maintenanceInterval);
     // *********************************************************************
     // Auto exec routines
     // *********************************************************************
     // Application reupdate check
     if (file_exists($this->home . 'core/temp/appinst/reupdate')) {
         $tmpmod = new \Innomatic\Application\Application($this->rootDb, '');
         $tmpmod->install($this->home . 'core/temp/appinst/reupdate');
         clearstatcache();
         if (file_exists($this->home . 'core/temp/appinst/reupdate')) {
             unlink($this->home . 'core/temp/appinst/reupdate');
         }
     }
     // Startup hook
     if ($this->state != \Innomatic\Core\InnomaticContainer::STATE_SETUP) {
         $hook = new \Innomatic\Process\Hook($this->rootDb, 'innomatic', 'instance');
         $null = '';
         switch ($hook->callHooks('startup', $null, '')) {
             case \Innomatic\Process\Hook::RESULT_ABORT:
                 $this->abort('Bootstrap aborted');
                 break;
         }
     }
     // Bootstrap end
     $this->bootstrapped = true;
 }
 /**
  * Retrieves an application archive from the AppCentral server and installs it.
  *
  * @param int $repId Repository id
  * @param int $applicationId Application id.
  * @param string $applicationVersion Required application version.
  * @access public
  * @return void
  */
 public function retrieveApplication($repId, $applicationId, $applicationVersion = '')
 {
     $xmlrpcMessage = new \Innomatic\Webservices\Xmlrpc\XmlRpcMsg('appcentral-server.retrieve_application', array(new \Innomatic\Webservices\Xmlrpc\XmlRpcVal($repId, 'int'), new \Innomatic\Webservices\Xmlrpc\XmlRpcVal($applicationId, 'int'), new \Innomatic\Webservices\Xmlrpc\XmlRpcVal($applicationVersion, 'string')));
     $xmlrpcResp = $this->client->send($xmlrpcMessage);
     if ($xmlrpcResp) {
         if (!$xmlrpcResp->faultCode()) {
             $xv = $xmlrpcResp->value();
             $tmpFilename = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getHome() . 'core/temp/appcentral-client/' . md5(uniqid(rand())) . '.tgz';
             $fh = fopen($tmpFilename, 'wb');
             if ($fh) {
                 fputs($fh, $xv->scalarVal());
                 fclose($fh);
                 unset($xv);
                 unset($xmlrpcResp);
                 // Install the application.
                 $tmpApplication = new \Innomatic\Application\Application($this->dataAccess, '');
                 if ($tmpApplication->install($tmpFilename)) {
                     return true;
                 }
             }
         } else {
             $this->log->logEvent(['root' => ''], 'innomatic.appcentralremoteserver.retrieveapplication', 'Error in response from server: ' . $xmlrpcResp->faultString(), \Innomatic\Logging\Logger::ERROR);
         }
     } else {
         $this->log->logEvent(['root' => ''], 'innomatic.appcentralremoteserver.retrieveapplication', 'Invalid response from server', \Innomatic\Logging\Logger::ERROR);
     }
     return false;
 }
    $argv[1] = '';
}
try {
    switch ($argv[1]) {
        case '-h':
            print 'Usage: php innomatic/core/scripts/application.php command argument' . "\n";
            print "\n";
            print 'Supported commands:' . "\n";
            print '    deploy package                  Deploys an application (from a directory of archive)' . "\n";
            print '    undeploy appname                Undeploys an application' . "\n";
            print '    update                          Updates the AppCentral applications list' . "\n";
            $script->cleanExit();
            break;
        case 'deploy':
            $app = new \Innomatic\Application\Application(InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getDataAccess());
            if ((is_dir($argv[2]) or file_exists($argv[2])) and $app->install($argv[2])) {
                print "Application {$app->appname} deployed\n";
                $script->cleanExit();
            } else {
                print "Application not deployed\n";
                $script->cleanExit(1);
            }
            break;
        case 'undeploy':
            $appid = \Innomatic\Application\Application::getAppIdFromName($argv[2]);
            $app = new \Innomatic\Application\Application(InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getDataAccess(), $appid);
            if ($app->uninstall()) {
                print "Application {$argv['2']} undeployed\n";
                $script->cleanExit();
            } else {
                print "Application {$argv['2']} not undeployed\n";
示例#5
0
if (!isset($argv[1])) {
    $argv[1] = '';
}
try {
    switch ($argv[1]) {
        case '-h':
            print 'Usage: php innomatic/core/scripts/application.php command argument' . "\n";
            print "\n";
            print 'Supported commands:' . "\n";
            print '    deploy appfile                  Deploys an application' . "\n";
            print '    undeploy appname                Undeploys an application' . "\n";
            $script->cleanExit();
            break;
        case 'deploy':
            $app = new \Innomatic\Application\Application(InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getDataAccess());
            if (file_exists($argv[2]) and $app->install($argv[2])) {
                print "Application {$app->appname} deployed\n";
                $script->cleanExit();
            } else {
                print "Application not deployed\n";
                $script->cleanExit(1);
            }
            break;
        case 'undeploy':
            $appid = \Innomatic\Application\Application::getAppIdFromName($argv[2]);
            $app = new \Innomatic\Application\Application(InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getDataAccess(), $appid);
            if ($app->uninstall()) {
                print "Application {$argv['2']} undeployed\n";
                $script->cleanExit();
            } else {
                print "Application {$argv['2']} not undeployed\n";