force use of sh on remote server and make directory ownership check more portable

This commit is contained in:
hrakotobe
2014-05-09 17:53:35 +02:00
parent 23b59869ec
commit 47b089cb3e
4 changed files with 40 additions and 8 deletions
+11 -4
View File
@@ -170,9 +170,10 @@ abstract class AbstractTask
* Runs a Shell Command on the Remote Host
* @param string $command
* @param string $output
* @param boolean $cdToDirectoryFirst
* @return boolean
*/
protected final function runCommandRemote($command, &$output = null)
protected final function runCommandRemote($command, &$output = null, $cdToDirectoryFirst = true)
{
if ($this->getConfig()->release('enabled', false) == true) {
if ($this instanceOf IsReleaseAware) {
@@ -194,9 +195,15 @@ abstract class AbstractTask
$localCommand = 'ssh ' . $this->getConfig()->getHostIdentityFileOption() . $needs_tty . ' -p ' . $this->getConfig()->getHostPort() . ' '
. '-q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no '
. $this->getConfig()->deployment('user') . '@' . $this->getConfig()->getHostName() . ' '
. '"cd ' . rtrim($this->getConfig()->deployment('to'), '/') . $releasesDirectory . ' && '
. str_replace('"', '\"', $command) . '"';
. $this->getConfig()->deployment('user') . '@' . $this->getConfig()->getHostName();
$remoteCommand = str_replace('"', '\"', $command);
if($cdToDirectoryFirst){
$remoteCommand = 'cd ' . rtrim($this->getConfig()->deployment('to'), '/') . $releasesDirectory . ' && ' . $remoteCommand;
}
$localCommand .= ' ' . '"sh -c \"' . $remoteCommand . '\""';
Console::log('Run remote command ' . $remoteCommand);
return $this->runCommandLocal($localCommand, $output);
}