]> _ Git - cubist_util.git/commitdiff
#7407
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 1 Apr 2025 10:28:22 +0000 (12:28 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 1 Apr 2025 10:28:22 +0000 (12:28 +0200)
src/CommandLine.php
src/CommandLine/Owncloud.php

index 55602b4377a13e2066f8c250ac85f219fc7db8a8..5f6e8196edfb4ae8a9cfe9ee0dcf69ed24db0d86 100644 (file)
@@ -26,6 +26,7 @@ class CommandLine
     protected $sudo = false;
     protected $unique = false;
     protected $uniqueCommand = null;
+    protected $docker = null;
 
     function __construct($program, $output = null, $error = true, $outputPrefix = null)
     {
@@ -54,6 +55,11 @@ class CommandLine
         $this->error = $error;
     }
 
+    public function docker($container)
+    {
+        $this->docker = $container;
+    }
+
     public function setArg($name = null, $val = null)
     {
         if (null === $name && null === $val) {
@@ -161,7 +167,7 @@ class CommandLine
                 $key = ' -i ' . $this->ssh['key'];
             }
 
-            $c = 'echo "' . $this->commande . '" | ssh ' . $key . ' -p ' . $this->ssh['port'] . ' ' . $this->ssh['username'] . '@' . $this->ssh['host'] . ' \'bash -s\'';
+            $c = 'echo "' . addcslashes($this->commande, '"') . '" | ssh ' . $key . ' -p ' . $this->ssh['port'] . ' ' . $this->ssh['username'] . '@' . $this->ssh['host'] . ' \'bash -s\'';
             $c .= ' > ' . $this->output;
             if ($this->error) {
                 $c .= ' 2>&1 ';
@@ -214,7 +220,11 @@ class CommandLine
 
     public function makeCommande($output = false, $error = false)
     {
-        $commande = $this->program;
+        $commande = '';
+        if (null !== $this->docker) {
+            $commande = 'docker exec ' . $this->docker . ' ';
+        }
+        $commande .= $this->program;
         $commandes = array();
         foreach ($this->args as $arg) {
             if (null === $arg[0]) {
index 4cfe19de3494a5e331ef8d638a5cd217b35c7b28..48bfb16f03d797313b80619caaa6ef0256c72e7f 100644 (file)
@@ -27,6 +27,7 @@ class Owncloud extends CommandLine
         // user:add [--password-from-env] [--generate-password] [--display-name [DISPLAY-NAME]] [-g|--group [GROUP]] [--email EMAIL] [--] <uid>
 
         $this->setArg(null, 'user:add');
+        $this->setArg(null, $userID ?? $email);
         if (null === $password) {
             $this->setArg('generate-password');
         } else {
@@ -37,7 +38,6 @@ class Owncloud extends CommandLine
             $this->setArg('display-name', $name);
         }
         $this->setArg('email', $email);
-        $this->setArg(null, $userID ?? $email);
         $this->execute();
         $this->debug();
     }