Example #1
0
 public function process()
 {
     parent::process();
     try {
         $this->profile = Teleport::loadProfile($this->profile);
         if (empty($this->passwordnotifymethod)) {
             $this->passwordnotifymethod = 's';
         }
         if (!empty($this->password)) {
             $this->passwordgenmethod = '';
             $this->newpassword = $this->password;
             $this->specifiedpassword = $this->password;
             $this->confirmpassword = $this->password;
         }
         $this->getMODX($this->profile);
         $this->modx->getService('error', 'error.modError');
         $this->modx->error->message = '';
         $this->modx->setOption(\xPDO::OPT_SETUP, true);
         /** @var \modProcessorResponse $response */
         $response = $this->modx->runProcessor('security/user/create', $this->request->args());
         if ($response->isError()) {
             throw new ActionException($this, implode("\n", $response->getAllErrors()) . "\n0");
         } else {
             $this->request->log("Created user for {$this->profile->name} with username {$this->username}: {$response->getMessage()}");
         }
         $this->request->log('1', false);
     } catch (\Exception $e) {
         throw new ActionException($this, "Error creating MODX user: {$e->getMessage()}", $e);
     }
 }
Example #2
0
 public function process()
 {
     parent::process();
     try {
         $this->profile = Teleport::loadProfile($this->profile);
         $this->getMODX($this->profile);
         $this->modx->getService('error', 'error.modError');
         $this->modx->error->message = '';
         $this->modx->setOption(\xPDO::OPT_SETUP, true);
         $this->modx->loadClass('transport.xPDOTransport', XPDO_CORE_PATH, true, true);
         $this->modx->loadClass('transport.modTransportPackage');
         $latestPackages = $this->modx->call('modTransportPackage', 'listPackages', array(&$this->modx, 1));
         /** @var \modTransportPackage $latestPackage */
         foreach ($latestPackages['collection'] as $latestPackage) {
             $versions = $this->modx->call('modTransportPackage', 'listPackageVersions', array(&$this->modx, array('package_name:LIKE' => $latestPackage->package_name, 'signature:!=' => $latestPackage->signature)));
             if (isset($versions['collection']) && $versions['total'] > 0) {
                 $this->request->log("Removing {$versions['total']} outdated package versions for {$latestPackage->package_name}");
                 /** @var \modTransportPackage $version */
                 foreach ($versions['collection'] as $version) {
                     $this->request->log("Removing outdated package version {$version->signature} from {$this->profile->name}");
                     $version->removePackage(true, false);
                     $this->removePackageFiles($version->signature);
                 }
             }
         }
         $this->request->log("Completed Removing outdated packages for {$this->profile->name}");
     } catch (\Exception $e) {
         throw new ActionException($this, "Error removing outdated packages: {$e->getMessage()}", $e);
     }
 }
Example #3
0
 public function process()
 {
     parent::process();
     try {
         $this->deleteTree(TELEPORT_BASE_PATH . 'workspace');
         $this->request->log("Completed cleaning up the Teleport workspace");
     } catch (\Exception $e) {
         throw new ActionException($this, "Error cleaning up the Teleport workspace: {$e->getMessage()}", $e);
     }
 }
Example #4
0
 /**
  * Process the Extract action.
  *
  * @throws ActionException If an error is encountered during processing.
  */
 public function process()
 {
     parent::process();
     try {
         $this->profile = Teleport::loadProfile($this->profile);
         $this->getMODX($this->profile);
         $this->tpl = $this->loadTpl($this->tpl);
         $this->package = $this->createPackage($this->getName(), $this->getVersion(), $this->getSequence());
         if (isset($this->tpl['attributes'])) {
             foreach ($this->tpl['attributes'] as $attribute => $attributeValue) {
                 if (is_array($attributeValue) && isset($attributeValue['sourceType']) && isset($attributeValue['source'])) {
                     switch ($attributeValue['sourceType']) {
                         case 'fileContent':
                             $attributeValue = file_get_contents($attributeValue['source']);
                             break;
                     }
                 }
                 $this->package->setAttribute($attribute, $attributeValue);
             }
         }
         foreach ($this->tpl['vehicles'] as $vehicle) {
             $this->createVehicles($vehicle);
         }
         if (!$this->package->pack()) {
             throw new ActionException($this, "Error packing {$this->package->signature}.transport.zip");
         }
         $this->request->log("Successfully extracted {$this->package->signature}.transport.zip from instance {$this->profile->code}");
         if ($this->target && $this->push) {
             if (!$this->push($this->package->path . $this->package->signature . '.transport.zip', $this->target . $this->package->signature . '.transport.zip')) {
                 throw new ActionException($this, "Error pushing {$this->package->signature}.transport.zip to {$this->target}");
             }
             if (!$this->preserveWorkspace && $this->modx->getCacheManager()) {
                 $this->modx->cacheManager->deleteTree($this->package->path . $this->package->signature);
                 @unlink($this->package->path . $this->package->signature . '.transport.zip');
             }
             $this->request->log("Successfully pushed {$this->package->signature}.transport.zip to {$this->target}");
             $this->request->log("{$this->target}{$this->package->signature}.transport.zip", false);
         } else {
             $this->request->log("{$this->package->path}{$this->package->signature}.transport.zip", false);
         }
     } catch (\Exception $e) {
         throw new ActionException($this, "Error Extracting snapshot: " . $e->getMessage(), $e);
     }
 }
Example #5
0
 /**
  * Process the Inject action.
  *
  * @throws ActionException If an error is encountered during processing.
  */
 public function process()
 {
     parent::process();
     try {
         $this->profile = Teleport::loadProfile($this->profile);
         $this->getMODX($this->profile);
         $this->modx->setOption(\xPDO::OPT_SETUP, true);
         $this->modx->loadClass('transport.xPDOTransport', XPDO_CORE_PATH, true, true);
         $this->modx->loadClass('transport.xPDOVehicle', XPDO_CORE_PATH, true, true);
         $this->modx->loadClass('transport.xPDOObjectVehicle', XPDO_CORE_PATH, true, true);
         $this->modx->loadClass('transport.xPDOFileVehicle', XPDO_CORE_PATH, true, true);
         $transportName = basename($this->source);
         if (TELEPORT_BASE_PATH . 'workspace' . DIRECTORY_SEPARATOR . $transportName !== realpath($this->source)) {
             if (!$this->pull($this->source, TELEPORT_BASE_PATH . 'workspace' . DIRECTORY_SEPARATOR . $transportName)) {
                 throw new ActionException($this, "Error pulling {$this->source}");
             }
         } else {
             $this->preserveWorkspace = true;
         }
         $this->package = Transport::retrieve($this->modx, TELEPORT_BASE_PATH . 'workspace' . DIRECTORY_SEPARATOR . $transportName, TELEPORT_BASE_PATH . 'workspace' . DIRECTORY_SEPARATOR);
         if (!$this->package instanceof Transport) {
             throw new ActionException($this, "Error extracting {$transportName} in workspace" . DIRECTORY_SEPARATOR);
         }
         $this->package->preInstall();
         if (!$this->package->install(array(\xPDOTransport::PREEXISTING_MODE => \xPDOTransport::REMOVE_PREEXISTING))) {
             throw new ActionException($this, "Error installing {$transportName}");
         }
         $this->package->postInstall();
         if ($this->modx->getCacheManager()) {
             $this->modx->cacheManager->refresh();
         }
         if (!$this->preserveWorkspace && $this->modx->getCacheManager()) {
             $this->modx->cacheManager->deleteTree($this->package->path . $transportName);
             @unlink($this->package->path . $transportName . '.transport.zip');
         }
         $this->request->log("Successfully injected {$transportName} into instance {$this->profile->code}");
     } catch (\Exception $e) {
         throw new ActionException($this, 'Error injecting snapshot: ' . $e->getMessage(), $e);
     }
 }