Fix windows straight-to-container SSH

Closes: #1211
Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
Cameron Diver 2019-05-10 13:24:59 +01:00 committed by Paulo Castro
parent 64c2f00d2a
commit 94c9e13106

View File

@ -32,6 +32,7 @@ export async function performLocalDeviceSSH(
const { getSubShellCommand } = await import('../helpers'); const { getSubShellCommand } = await import('../helpers');
const { exitWithExpectedError } = await import('../patterns'); const { exitWithExpectedError } = await import('../patterns');
const { stripIndent } = await import('common-tags'); const { stripIndent } = await import('common-tags');
const os = await import('os');
let command = ''; let command = '';
@ -98,10 +99,19 @@ export async function performLocalDeviceSSH(
`); `);
} }
const shellCmd = `/bin/sh -c $"'if [ -e /bin/bash ]; then exec /bin/bash; else exec /bin/sh; fi'"`; // Getting a command to work on all platforms is a pain,
command = `'${deviceContainerEngineBinary}' exec -ti ${ // so we just define slightly different ones for windows
containers[0]!.id if (os.platform() !== 'win32') {
} ${shellCmd}`; const shellCmd = `/bin/sh -c "if [ -e /bin/bash ]; then exec /bin/bash; else exec /bin/sh; fi"`;
command = `'${deviceContainerEngineBinary}' exec -ti ${
containers[0]!.id
} '${shellCmd}'`;
} else {
const shellCmd = `/bin/sh -c "if [ -e /bin/bash ]; then exec /bin/bash; else exec /bin/sh; fi"`;
command = `${deviceContainerEngineBinary} exec -ti ${
containers[0]!.id
} ${shellCmd}`;
}
} }
// Generate the SSH command // Generate the SSH command
const sshCommand = `ssh \ const sshCommand = `ssh \