|
@@ 435-460 (lines=26) @@
|
| 432 |
|
* @param string $destination |
| 433 |
|
* @param array $config |
| 434 |
|
*/ |
| 435 |
|
function upload($source, $destination, array $config = []) |
| 436 |
|
{ |
| 437 |
|
$rsync = Deployer::get()->rsync; |
| 438 |
|
$host = currentHost(); |
| 439 |
|
$source = parse($source); |
| 440 |
|
$destination = parse($destination); |
| 441 |
|
|
| 442 |
|
if ($host instanceof Localhost) { |
| 443 |
|
$rsync->call($host, $source, $destination, $config); |
| 444 |
|
} else { |
| 445 |
|
if (!isset($config['options']) || !is_array($config['options'])) { |
| 446 |
|
$config['options'] = []; |
| 447 |
|
} |
| 448 |
|
|
| 449 |
|
$sshArguments = $host->getSshArguments()->getCliArguments(); |
| 450 |
|
if (empty($sshArguments) === false) { |
| 451 |
|
$config['options'][] = "-e 'ssh $sshArguments'"; |
| 452 |
|
} |
| 453 |
|
|
| 454 |
|
if ($host->has("become")) { |
| 455 |
|
$config['options'][] = "--rsync-path='sudo -H -u " . $host->get('become') . " rsync'"; |
| 456 |
|
} |
| 457 |
|
|
| 458 |
|
$rsync->call($host, $source, "{$host->hostname()}:$destination", $config); |
| 459 |
|
} |
| 460 |
|
} |
| 461 |
|
|
| 462 |
|
/** |
| 463 |
|
* Download file or directory from host |
|
@@ 469-494 (lines=26) @@
|
| 466 |
|
* @param string $source |
| 467 |
|
* @param array $config |
| 468 |
|
*/ |
| 469 |
|
function download($source, $destination, array $config = []) |
| 470 |
|
{ |
| 471 |
|
$rsync = Deployer::get()->rsync; |
| 472 |
|
$host = currentHost(); |
| 473 |
|
$source = parse($source); |
| 474 |
|
$destination = parse($destination); |
| 475 |
|
|
| 476 |
|
if ($host instanceof Localhost) { |
| 477 |
|
$rsync->call($host, $source, $destination, $config); |
| 478 |
|
} else { |
| 479 |
|
if (!isset($config['options']) || !is_array($config['options'])) { |
| 480 |
|
$config['options'] = []; |
| 481 |
|
} |
| 482 |
|
|
| 483 |
|
$sshArguments = $host->getSshArguments()->getCliArguments(); |
| 484 |
|
if (empty($sshArguments) === false) { |
| 485 |
|
$config['options'][] = "-e 'ssh $sshArguments'"; |
| 486 |
|
} |
| 487 |
|
|
| 488 |
|
if ($host->has("become")) { |
| 489 |
|
$config['options'][] = "--rsync-path='sudo -H -u " . $host->get('become') . " rsync'"; |
| 490 |
|
} |
| 491 |
|
|
| 492 |
|
$rsync->call($host, "{$host->hostname()}:$source", $destination, $config); |
| 493 |
|
} |
| 494 |
|
} |
| 495 |
|
|
| 496 |
|
/** |
| 497 |
|
* Writes an info message. |