@@ 414-439 (lines=26) @@ | ||
411 | * @param string $destination |
|
412 | * @param array $config |
|
413 | */ |
|
414 | function upload($source, $destination, array $config = []) |
|
415 | { |
|
416 | $rsync = Deployer::get()->rsync; |
|
417 | $host = currentHost(); |
|
418 | $source = parse($source); |
|
419 | $destination = parse($destination); |
|
420 | ||
421 | if ($host instanceof Localhost) { |
|
422 | $rsync->call($host, $source, $destination, $config); |
|
423 | } else { |
|
424 | if (!isset($config['options']) || !is_array($config['options'])) { |
|
425 | $config['options'] = []; |
|
426 | } |
|
427 | ||
428 | $sshArguments = $host->getSshArguments()->getCliArguments(); |
|
429 | if (empty($sshArguments) === false) { |
|
430 | $config['options'][] = "-e 'ssh $sshArguments'"; |
|
431 | } |
|
432 | ||
433 | if ($host->has("become")) { |
|
434 | $config['options'][] = "--rsync-path='sudo -H -u " . $host->get('become') . " rsync'"; |
|
435 | } |
|
436 | ||
437 | $rsync->call($host, $source, "{$host->hostname()}:$destination", $config); |
|
438 | } |
|
439 | } |
|
440 | ||
441 | /** |
|
442 | * Download file or directory from host |
|
@@ 448-473 (lines=26) @@ | ||
445 | * @param string $source |
|
446 | * @param array $config |
|
447 | */ |
|
448 | function download($source, $destination, array $config = []) |
|
449 | { |
|
450 | $rsync = Deployer::get()->rsync; |
|
451 | $host = currentHost(); |
|
452 | $source = parse($source); |
|
453 | $destination = parse($destination); |
|
454 | ||
455 | if ($host instanceof Localhost) { |
|
456 | $rsync->call($host, $source, $destination, $config); |
|
457 | } else { |
|
458 | if (!isset($config['options']) || !is_array($config['options'])) { |
|
459 | $config['options'] = []; |
|
460 | } |
|
461 | ||
462 | $sshArguments = $host->getSshArguments()->getCliArguments(); |
|
463 | if (empty($sshArguments) === false) { |
|
464 | $config['options'][] = "-e 'ssh $sshArguments'"; |
|
465 | } |
|
466 | ||
467 | if ($host->has("become")) { |
|
468 | $config['options'][] = "--rsync-path='sudo -H -u " . $host->get('become') . " rsync'"; |
|
469 | } |
|
470 | ||
471 | $rsync->call($host, "{$host->hostname()}:$source", $destination, $config); |
|
472 | } |
|
473 | } |
|
474 | ||
475 | /** |
|
476 | * Writes an info message. |