From: Vincent Vanwaelscappel Date: Mon, 13 Feb 2023 17:11:35 +0000 (+0100) Subject: wip #5700 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=714ff12cfdb84730b11c28b24bbe40957fb845dc;p=cubist_util.git wip #5700 @1 --- diff --git a/src/CommandLine.php b/src/CommandLine.php index 3fa383a..7bcd850 100644 --- a/src/CommandLine.php +++ b/src/CommandLine.php @@ -315,4 +315,11 @@ class CommandLine { $this->sudo = $sudo; } + + public function ddCommand() + { + $this->_preExecute(); + $this->makeCommande(); + dd($this->getCommand()); + } } diff --git a/src/CommandLine/LFTP.php b/src/CommandLine/LFTP.php index d241ae0..d3321b6 100644 --- a/src/CommandLine/LFTP.php +++ b/src/CommandLine/LFTP.php @@ -35,27 +35,30 @@ class LFTP extends CloneUserpassProgram 'set ftp:passive-mode ' . ($this->isPassiveMode() ? '1' : '0') ]; switch ($this->getProtocol()) { - case 'ftp': - $commands += [ + case 'FTP': + $commands = array_merge($commands, [ 'set ftp:ssl-allow false', 'connect ftp://' . $this->getHost() - ]; + ]); break; - case 'ftps': - $commands += ['connect ftps://' . $this->getHost()]; + case 'FTPS': + $commands = array_merge($commands, [ + 'connect ftps://' . $this->getHost() + ]); break; - case 'ftpes': - $commands += [ + case 'FTPES': + $commands = array_merge($commands, [ 'set ftp:ssl-force true', 'connect ftp://' . $this->getHost() - ]; + ]); + break; } - $commands += [ - 'mkdir -p ' . $this->getDest(), - 'cd ' . $this->getDest(), + $commands = array_merge($commands, [ + 'mkdir -p ' . $this->getFinalDest(), + 'cd ' . $this->getFinalDest(), 'lcd ' . $this->getSrc(), - ]; + ]); $mirrorCmd = 'mirror --reverse --verbose --parallel=5'; if ($this->getMirror()) { $mirrorCmd .= ' --delete'; diff --git a/src/CommandLine/Rclone.php b/src/CommandLine/Rclone.php index 94634b5..c957d6a 100644 --- a/src/CommandLine/Rclone.php +++ b/src/CommandLine/Rclone.php @@ -6,6 +6,8 @@ use Cubist\Util\CommandLine; class Rclone extends CloneUserpassProgram { + + protected $_prog = 'rclone'; /** * @var string */ @@ -20,7 +22,7 @@ class Rclone extends CloneUserpassProgram $this->setArg('sftp-host', $this->getHost()); $this->setArg('sftp-port', $this->getPort()); $this->setArg('sftp-user', $this->getUsername()); - $this->setArg('sftp-pass', $this->getPassword()); + $this->setArg('sftp-pass', $this->getObscuredPassword()); if ($this->isDryRun()) { $this->setArg('dry-run'); } @@ -29,12 +31,20 @@ class Rclone extends CloneUserpassProgram } switch ($this->getProtocol()) { case 'local': - $dest = $this->getDest(); + $dest = $this->getFinalDest(); break; default: - $dest = ':' . $this->getProtocol() . ':' . $this->getDest(); + $dest = ':' . mb_strtolower($this->getProtocol()) . ':' . $this->getDest(); break; } $this->setManualArg($dest); } + + protected function getObscuredPassword() + { + $password = $this->getPassword(); + cache()->rememberForever('rclone_obscure_' . sha1($this->getPassword()), function () use ($password) { + return `rclone obscure $password`; + }); + } } \ No newline at end of file diff --git a/src/CommandLine/Rsync.php b/src/CommandLine/Rsync.php index c73a94c..2aa0901 100644 --- a/src/CommandLine/Rsync.php +++ b/src/CommandLine/Rsync.php @@ -8,6 +8,8 @@ use Cubist\Util\Files\Files; class Rsync extends CloneProgram { + protected $_prog = 'rsync'; + protected $_port = 22; protected $_excludes = array(); @@ -66,7 +68,7 @@ class Rsync extends CloneProgram protected function _preExecute() { - $dest = $this->getDest(); + $dest = $this->getFinalDest(); $port = $this->getPort(); $src = $this->getSrc(); $mirror = $this->getMirror();