getWorkspacePath($application); $releasePath = $deployment->getApplicationReleasePath($application); $remotePath = Files::concatenatePaths(array($application->getDeploymentPath(), 'cache', 'transfer')); // make sure there is a remote .cache folder $command = 'mkdir -p ' . $remotePath; $this->shell->executeOrSimulate($command, $node, $deployment); $username = $node->hasOption('username') ? $node->getOption('username') . '@' : ''; $hostname = $node->getHostname(); $destinationArgument = ($node->isLocalhost() ? $remotePath : "{$username}{$hostname}:{$remotePath}"); // escape whitespaces $localPackagePath = preg_replace('/\s+/', '\ ', $localPackagePath); $destinationArgument = preg_replace('/\s+/', '\ ', $destinationArgument); $localhost = new Node('localhost'); $localhost->setHostname('localhost'); $this->createTarballForTransfer($localPackagePath, $localhost, $deployment); // copy tarball to target server $command = "scp " . $localPackagePath . "/transfer.tar.gz " . $destinationArgument; $this->shell->executeOrSimulate($command, $localhost, $deployment); $command = strtr("cp -RPp $remotePath/. $releasePath", "\t\n", " "); // TODO Copy revision file (if it exists) for application to deployment path with release identifier $this->shell->executeOrSimulate($command, $node, $deployment); // extract tarball on server $command = "ssh " . $username . $hostname . " 'cd " . $remotePath . "; tar -zxvf " . $remotePath . "/transfer.tar.gz'"; echo $command; $this->shell->executeOrSimulate($command, $localhost, $deployment); // delete tarball on server $command = 'ssh ' . $username . $hostname . ' rm -rf ' . $remotePath . '/transfer.tar.gz'; $this->shell->executeOrSimulate($command, $localhost, $deployment); $this->deleteTarballForTransfer($localPackagePath, $localhost, $deployment); } protected function createTarballForTransfer($localPackagePath, $node, $deployment) { // delete tarball if it exists to avoid errors $command = 'rm -rf ' . $localPackagePath . '/transfer.tar.gz'; $this->shell->executeOrSimulate($command, $node, $deployment); $command = "cd " . $localPackagePath . "/; tar -zcf transfer.tar.gz " . $localPackagePath . "/*"; $this->shell->executeOrSimulate($command, $node, $deployment); } protected function deleteTarballForTransfer($localPackagePath, $node, $deployment) { $command = 'rm -rf ' . $localPackagePath . '/transfer.tar.gz'; $this->shell->executeOrSimulate($command, $node, $deployment); } /** * Simulate this task * * @param Node $node * @param Application $application * @param Deployment $deployment * @param array $options * @return void */ public function simulate(Node $node, Application $application, Deployment $deployment, array $options = array()) { $this->execute($node, $application, $deployment, $options); } /** * Rollback this task * * @param \TYPO3\Surf\Domain\Model\Node $node * @param \TYPO3\Surf\Domain\Model\Application $application * @param \TYPO3\Surf\Domain\Model\Deployment $deployment * @param array $options * @return void */ public function rollback(Node $node, Application $application, Deployment $deployment, array $options = array()) { $releasePath = $deployment->getApplicationReleasePath($application); $this->shell->execute('rm -Rf ' . $releasePath, $node, $deployment, TRUE); } } ?>