From 17f30af2ce1b81a570b7cd16c31d3119562bd52e Mon Sep 17 00:00:00 2001 From: Maximilian Walter Date: Wed, 7 Feb 2018 12:56:01 +0100 Subject: [PATCH] Make used shell configurable --- src/Host/FileLoader.php | 1 + src/Host/Host.php | 16 ++++++++++++++++ src/Ssh/Client.php | 4 +++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Host/FileLoader.php b/src/Host/FileLoader.php index 46a669bcd..7d6b0cd51 100644 --- a/src/Host/FileLoader.php +++ b/src/Host/FileLoader.php @@ -53,6 +53,7 @@ public function load($file) 'multiplexing', 'sshOptions', 'sshFlags', + 'shellCommand', ]; foreach ($methods as $method) { diff --git a/src/Host/Host.php b/src/Host/Host.php index deaa023c2..78da6361e 100644 --- a/src/Host/Host.php +++ b/src/Host/Host.php @@ -25,6 +25,7 @@ class Host private $forwardAgent = true; private $multiplexing = null; private $sshArguments; + private $shellCommand = 'bash -s'; /** * @param string $hostname @@ -239,6 +240,21 @@ public function addSshFlag(string $flag, string $value = null) : Host return $this; } + public function getShellCommand() : string + { + return $this->shellCommand; + } + + /** + * @param string $shellCommand + * @return $this + */ + public function shellCommand(string $shellCommand) + { + $this->shellCommand = $shellCommand; + return $this; + } + /** * Set stage * diff --git a/src/Ssh/Client.php b/src/Ssh/Client.php index 250b8c0d6..31faef19a 100644 --- a/src/Ssh/Client.php +++ b/src/Ssh/Client.php @@ -80,7 +80,9 @@ public function run(Host $host, string $command, array $config = []) $sshArguments = $this->initMultiplexing($host); } - $ssh = "ssh $sshArguments $host $become 'bash -s; printf \"[exit_code:%s]\" $?;'"; + $shellCommand = $host->getShellCommand(); + + $ssh = "ssh $sshArguments $host $become '$shellCommand; printf \"[exit_code:%s]\" $?;'"; $process = new Process($ssh); $process