protected $sudo = false;
protected $unique = false;
protected $uniqueCommand = null;
+ protected $docker = null;
function __construct($program, $output = null, $error = true, $outputPrefix = null)
{
$this->error = $error;
}
+ public function docker($container)
+ {
+ $this->docker = $container;
+ }
+
public function setArg($name = null, $val = null)
{
if (null === $name && null === $val) {
$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 ';
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]) {
// 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 {
$this->setArg('display-name', $name);
}
$this->setArg('email', $email);
- $this->setArg(null, $userID ?? $email);
$this->execute();
$this->debug();
}