diff --git a/app/Livewire/Project/Shared/GetLogs.php b/app/Livewire/Project/Shared/GetLogs.php index 996131f37..e14cd6113 100644 --- a/app/Livewire/Project/Shared/GetLogs.php +++ b/app/Livewire/Project/Shared/GetLogs.php @@ -91,15 +91,35 @@ class GetLogs extends Component if ($this->container) { if ($this->showTimeStamps) { if ($this->server->isSwarm()) { - $sshCommand = generateSshCommand($this->server, "docker service logs -n {$this->numberOfLines} -t {$this->container}"); + $command = "docker service logs -n {$this->numberOfLines} -t {$this->container}"; + if ($this->server->isNonRoot()) { + $command = parseCommandsByLineForSudo(collect($command), $this->server); + $command = $command[0]; + } + $sshCommand = generateSshCommand($this->server, $command); } else { - $sshCommand = generateSshCommand($this->server, "docker logs -n {$this->numberOfLines} -t {$this->container}"); + $command = "docker logs -n {$this->numberOfLines} -t {$this->container}"; + if ($this->server->isNonRoot()) { + $command = parseCommandsByLineForSudo(collect($command), $this->server); + $command = $command[0]; + } + $sshCommand = generateSshCommand($this->server, $command); } } else { if ($this->server->isSwarm()) { - $sshCommand = generateSshCommand($this->server, "docker service logs -n {$this->numberOfLines} {$this->container}"); + $command = "docker service logs -n {$this->numberOfLines} {$this->container}"; + if ($this->server->isNonRoot()) { + $command = parseCommandsByLineForSudo(collect($command), $this->server); + $command = $command[0]; + } + $sshCommand = generateSshCommand($this->server, $command); } else { - $sshCommand = generateSshCommand($this->server, "docker logs -n {$this->numberOfLines} {$this->container}"); + $command = "docker logs -n {$this->numberOfLines} {$this->container}"; + if ($this->server->isNonRoot()) { + $command = parseCommandsByLineForSudo(collect($command), $this->server); + $command = $command[0]; + } + $sshCommand = generateSshCommand($this->server, $command); } } if ($refresh) {