/**
  * Executes this task
  *
  * @param \TYPO3\Deploy\Domain\Model\Node $node
  * @param \TYPO3\Deploy\Domain\Model\Application $application
  * @param \TYPO3\Deploy\Domain\Model\Deployment $deployment
  * @param array $options
  * @return void
  */
 public function execute(Node $node, Application $application, Deployment $deployment, array $options = array())
 {
     $targetReleasePath = $deployment->getApplicationReleasePath($application);
     $username = $node->getOption('username');
     $hostname = $node->getHostname();
     $configurationPath = $this->getDeploymentConfigurationPath() . '/Configuration/' . $deployment->getName() . '/';
     $encryptedConfiguration = \TYPO3\FLOW3\Utility\Files::readDirectoryRecursively($configurationPath, 'yaml.encrypted');
     if (count($encryptedConfiguration) > 0) {
         throw new \Exception('You have sealed configuration files, please open the configuration for "' . $deployment->getName() . '"', 1317229449);
     }
     $configurations = \TYPO3\FLOW3\Utility\Files::readDirectoryRecursively($configurationPath, 'yaml');
     $commands = array();
     foreach ($configurations as $configuration) {
         $targetConfigurationPath = dirname(str_replace($configurationPath, '', $configuration));
         $commands[] = "scp {$configuration} {$username}@{$hostname}:{$targetReleasePath}/Configuration/{$targetConfigurationPath}/";
     }
     $localhost = new Node('localhost');
     $localhost->setHostname('localhost');
     $this->shell->executeOrSimulate($commands, $localhost, $deployment);
 }
 /**
  * Execute a shell command via SSH
  *
  * @param mixed $command
  * @param \TYPO3\Deploy\Domain\Model\Node $node
  * @param \TYPO3\Deploy\Domain\Model\Deployment $deployment
  * @return array
  */
 protected function executeRemoteCommand($command, Node $node, Deployment $deployment)
 {
     $command = $this->prepareCommand($command);
     $deployment->getLogger()->log('    $' . $node->getName() . ': "' . $command . '"', LOG_DEBUG);
     $username = $node->getOption('username');
     $hostname = $node->getHostname();
     $returnedOutput = '';
     // TODO Get SSH options from node or deployment
     $fp = popen('ssh -A ' . $username . '@' . $hostname . ' ' . escapeshellarg($command) . ' 2>&1', 'r');
     while (($line = fgets($fp)) !== FALSE) {
         $deployment->getLogger()->log('    > ' . rtrim($line));
         $returnedOutput .= $line;
     }
     $exitCode = pclose($fp);
     return array($exitCode, $returnedOutput);
 }
Example #3
0
 /**
  * Execute a stage for a node and application
  *
  * @param string $stage
  * @param \TYPO3\Deploy\Domain\Model\Node $node
  * @param \TYPO3\Deploy\Domain\Model\Application $application
  * @param \TYPO3\Deploy\Domain\Model\Deployment $deployment
  * @return void
  */
 protected function executeStage($stage, Node $node, Application $application, Deployment $deployment)
 {
     foreach (array('_', $application->getName()) as $applicationName) {
         $label = $applicationName === '_' ? 'for all' : 'for application ' . $applicationName;
         if (isset($this->tasks['stage'][$applicationName][$stage])) {
             $deployment->getLogger()->log('Executing stage "' . $stage . '" on "' . $node->getName() . '" ' . $label, LOG_DEBUG);
             foreach ($this->tasks['stage'][$applicationName][$stage] as $task) {
                 $this->executeTask($task, $node, $application, $deployment);
             }
         }
     }
 }
Example #4
0
 /**
  * Add a node
  *
  * @param \TYPO3\Deploy\Domain\Model\Node $node
  * @return void
  */
 public function addNode(Node $node)
 {
     $this->nodes[$node->getName()] = $node;
 }