Beispiel #1
0
 /**
  * exec rsync from local dir to remote target dir
  * @param string $from local source path
  * @param string $to   remote target path
  *
  * @return string command return status
  */
 public function rsync($from, $to)
 {
     $user = $this->sshClient->getUser();
     $host = $this->sshClient->getHost();
     $dryFlag = $this->target->get('deploy.dry_run') ? '--dry-run' : '';
     $exclude = $this->rsyncExcludeFile ? '--exclude-from=' . $this->rsyncExcludeFile : '';
     $include = $this->rsyncIncludeFile ? '--include-from=' . $this->rsyncIncludeFile : '';
     $sshCmd = "-e 'ssh";
     $sshCmd .= $this->sshClient->getPort() ? " -p " . $this->sshClient->getPort() : "";
     $sshCmd .= "'";
     return $this->idx->local("rsync -rlpDvcz --delete {$sshCmd} {$dryFlag} {$exclude} {$include} {$from} {$user}@{$host}:{$to}");
 }
Beispiel #2
0
 public function testConnect()
 {
     $sshClient = new SshClient(new FakeSsh2Proxy($this));
     $sshClient->setParameters($this->params);
     $sshClient->setHost('localhost');
     $sshClient->connect();
     $this->assertEquals('text', $sshClient->exec('text'));
     $this->assertEquals('test out text', $sshClient->getLastOutput());
     $this->assertEquals('test err text', $sshClient->getLastError());
     $this->assertEquals('test', $sshClient->getUser());
     $this->assertEquals('23', $sshClient->getPort());
     $this->assertEquals('localhost', $sshClient->getHost());
     $sshClient->setHost('host');
     $this->assertEquals('host', $sshClient->getHost());
 }