Skip to content

Commit 2eca092

Browse files
committed
Showing the server MOTD when calling scw run <image> [COMMAND] without *COMMAND*
1 parent 2304af9 commit 2eca092

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,6 +1019,7 @@ $ scw inspect myserver | jq '.[0].public_ip.address'
10191019

10201020
#### Features
10211021

1022+
* Showing the server MOTD when calling `scw run <image> [COMMAND]` without *COMMAND*
10221023
* Support of `scw attach --no-stdin` option
10231024
* Hiding sensitive data by default on `scw inspect` ([#64](https://github.com/scaleway/scaleway-cli/issues/64))
10241025
* Support of `scw --sensitive` option ([#64](https://github.com/scaleway/scaleway-cli/issues/64))

commands/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func runRun(cmd *types.Command, args []string) {
9494
// exec -w SERVER COMMAND ARGS...
9595
log.Debugf("Executing command")
9696
if len(args) < 2 {
97-
err = utils.SSHExec(server.PublicAddress.IP, []string{"if [ -x /bin/bash ]; then exec /bin/bash; else exec /bin/sh; fi"}, false)
97+
err = utils.SSHExec(server.PublicAddress.IP, []string{}, false)
9898
} else {
9999
err = utils.SSHExec(server.PublicAddress.IP, args[1:], false)
100100
}

utils/utils.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,17 @@ func NewSSHExecCmd(ipAddress string, allocateTTY bool, command []string) []strin
6060
execCmd = append(execCmd, "-t")
6161
}
6262

63-
execCmd = append(execCmd, "--", "/bin/sh", "-e")
63+
if len(command) > 0 {
64+
execCmd = append(execCmd, "--", "/bin/sh", "-e")
6465

65-
if os.Getenv("DEBUG") == "1" {
66-
execCmd = append(execCmd, "-x")
67-
}
66+
if os.Getenv("DEBUG") == "1" {
67+
execCmd = append(execCmd, "-x")
68+
}
6869

69-
execCmd = append(execCmd, "-c")
70+
execCmd = append(execCmd, "-c")
7071

71-
execCmd = append(execCmd, fmt.Sprintf("%q", strings.Join(command, " ")))
72+
execCmd = append(execCmd, fmt.Sprintf("%q", strings.Join(command, " ")))
73+
}
7274

7375
return execCmd
7476
}

0 commit comments

Comments
 (0)