Skip to content

Commit

Permalink
[BUGFIX] Fix expect script also for rsync task
Browse files Browse the repository at this point in the history
  • Loading branch information
helhum committed Jun 8, 2016
1 parent a2fd41e commit b903a69
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/Task/Transfer/RsyncTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* *
* */

use TYPO3\Flow\Utility\Files;
use TYPO3\Surf\Domain\Model\Application;
use TYPO3\Surf\Domain\Model\Deployment;
use TYPO3\Surf\Domain\Model\Node;
Expand Down Expand Up @@ -33,7 +34,7 @@ public function execute(Node $node, Application $application, Deployment $deploy
$localPackagePath = $deployment->getWorkspacePath($application);
$releasePath = $deployment->getApplicationReleasePath($application);

$remotePath = $application->getDeploymentPath() . '/cache/transfer';
$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);
Expand All @@ -55,15 +56,23 @@ public function execute(Node $node, Application $application, Deployment $deploy
$command = "rsync {$quietFlag} --compress {$rshFlag} {$rsyncFlags} " . escapeshellarg($localPackagePath . '/.') . ' ' . escapeshellarg($destinationArgument);

if ($node->hasOption('password')) {
$resourcesPath = realpath(__DIR__ . '/../../../Resources');
$passwordSshLoginScriptPathAndFilename = $resourcesPath . '/Private/Scripts/PasswordSshLogin.expect';
$passwordSshLoginScriptPathAndFilename = Files::concatenatePaths(array(dirname(dirname(dirname(__DIR__))), 'Resources', 'Private/Scripts/PasswordSshLogin.expect'));
if (\Phar::running() !== '') {
$passwordSshLoginScriptContents = file_get_contents($passwordSshLoginScriptPathAndFilename);
$passwordSshLoginScriptPathAndFilename = Files::concatenatePaths(array($deployment->getTemporaryPath(), 'PasswordSshLogin.expect'));
file_put_contents($passwordSshLoginScriptPathAndFilename, $passwordSshLoginScriptContents);
}
$command = sprintf('expect %s %s %s', escapeshellarg($passwordSshLoginScriptPathAndFilename), escapeshellarg($node->getOption('password')), $command);
}

$localhost = new Node('localhost');
$localhost->setHostname('localhost');
$this->shell->executeOrSimulate($command, $localhost, $deployment);

if (isset($passwordSshLoginScriptPathAndFilename) && \Phar::running() !== '') {
unlink($passwordSshLoginScriptPathAndFilename);
}

$command = strtr("cp -RPp $remotePath/. $releasePath", "\t\n", ' ');
// TODO Copy revision file (if it exists) for application to deployment path with release identifier

Expand Down

0 comments on commit b903a69

Please sign in to comment.