]> _ Git - cubist_util.git/commitdiff
wip #5700 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 13 Feb 2023 17:11:35 +0000 (18:11 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 13 Feb 2023 17:11:35 +0000 (18:11 +0100)
src/CommandLine.php
src/CommandLine/LFTP.php
src/CommandLine/Rclone.php
src/CommandLine/Rsync.php

index 3fa383aad3acbfc756bc2c2ef23663b46c982a97..7bcd850a24e67ea94af111f675930bdd94b2304b 100644 (file)
@@ -315,4 +315,11 @@ class CommandLine
     {
         $this->sudo = $sudo;
     }
+
+    public function ddCommand()
+    {
+        $this->_preExecute();
+        $this->makeCommande();
+        dd($this->getCommand());
+    }
 }
index d241ae0c7bf6a672e6d9a34dec9eaa0b5449b320..d3321b624e7890b47daba1800bfcf38d15aeae15 100644 (file)
@@ -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';
index 94634b59aa4872970334c879d4ce4ed12d128200..c957d6ac19d104f7eff0285dc669116f2701bacb 100644 (file)
@@ -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
index c73a94c2d52180840753f747c9969b61f2d4ab6f..2aa0901e092e13fcc0aea83bb8c7a899f53cebe8 100644 (file)
@@ -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();