diff --git a/src/components/ContainerDetailsSubheader.react.js b/src/components/ContainerDetailsSubheader.react.js index 42bda6c01c..5695417b30 100644 --- a/src/components/ContainerDetailsSubheader.react.js +++ b/src/components/ContainerDetailsSubheader.react.js @@ -12,6 +12,7 @@ var classNames = require('classnames'); var resources = require('../utils/ResourcesUtil'); var dockerUtil = require('../utils/DockerUtil'); var containerActions = require('../actions/ContainerActions'); +var dockerMachineUtil = require('../utils/DockerMachineUtil'); var ContainerDetailsSubheader = React.createClass({ contextTypes: { @@ -111,26 +112,7 @@ var ContainerDetailsSubheader = React.createClass({ if(!shell) { shell = 'sh'; } - machine.ip().then(ip => { - if(util.isWindows()) { - var cmd = ['ssh', '-p', '22', '-o', 'UserKnownHostsFile=/dev/null', '-o', 'LogLevel=quiet', '-o', 'StrictHostKeyChecking=no', '-i', util.home() + '/.docker/machine/machines/' + machine.name() + '/id_rsa', 'docker@' + ip, '-t', 'docker', - 'exec', '-i' , '-t', container.Name, shell]; - console.log(cmd.join(" ")); - util.execProper('start cmd.exe /C "' + cmd.join(" ") + '"', function (stderr, stdout, code) { - if (code) { - console.log(stderr); - } - }); - } else { - var cmd = [resources.terminal(), 'ssh', '-p', '22', '-o', 'UserKnownHostsFile=/dev/null', '-o', 'LogLevel=quiet', '-o', 'StrictHostKeyChecking=no', '-i', '~/.docker/machine/machines/' + machine.name() + '/id_rsa', 'docker@' + ip, '-t', 'docker', - 'exec', '-i', '-t', container.Name, shell]; - exec(cmd, function (stderr, stdout, code) { - if (code) { - console.log(stderr); - } - }); - } - }); + dockerMachineUtil.dockerTerminal(`docker exec -it ${this.props.container.Name} ${shell}`); } }, handleItemMouseEnterView: function () { diff --git a/src/stores/SetupStore.js b/src/stores/SetupStore.js index 8d7151c1ce..59e804b920 100644 --- a/src/stores/SetupStore.js +++ b/src/stores/SetupStore.js @@ -42,7 +42,7 @@ var _steps = [{ progressCallback(50); // TODO: detect when the installation has started so we can simulate progress try { if (util.isWindows()) { - yield util.exec([path.join(util.supportDir(), virtualBox.filename())]); + yield util.exec([path.join(util.supportDir(), virtualBox.filename()), '-msiparams', 'REBOOT=ReallySuppress', 'LIMITUI=INSTALLUILEVEL_PROGRESSONLY']); } else { yield util.exec(setupUtil.macSudoCmd(setupUtil.installVirtualBoxCmd())); } @@ -57,7 +57,7 @@ var _steps = [{ message: 'To run Docker containers on your computer, Kitematic is starting a Linux virtual machine. This may take a minute...', totalPercent: 60, percent: 0, - seconds: 72, + seconds: 80, run: Promise.coroutine(function* (progressCallback) { setupUtil.simulateProgress(this.seconds, progressCallback); var exists = yield machine.exists(); diff --git a/src/utils/DockerMachineUtil.js b/src/utils/DockerMachineUtil.js index 8ab38f4651..d5fdbba2d0 100644 --- a/src/utils/DockerMachineUtil.js +++ b/src/utils/DockerMachineUtil.js @@ -153,23 +153,29 @@ var DockerMachine = { }); }); }, - dockerTerminal: function () { + dockerTerminal: function (cmd) { if(util.isWindows()) { + cmd = cmd || ''; this.info().then(machine => { - util.execProper('start cmd.exe /k', - {'env': { + util.exec('start powershell.exe ' + cmd, + {env: { 'DOCKER_HOST' : machine.url, 'DOCKER_CERT_PATH' : path.join(util.home(), '.docker/machine/machines/' + machine.name), - 'DOCKER_TLS_VERIFY': 1 + 'DOCKER_TLS_VERIFY': 1, + 'PATH': resources.resourceDir() } }); }); } else { + cmd = cmd || '$SHELL'; this.info().then(machine => { - var cmd = [resources.terminal(), `DOCKER_HOST=${machine.url} DOCKER_CERT_PATH=${path.join(util.home(), '.docker/machine/machines/' + machine.name)} DOCKER_TLS_VERIFY=1 $SHELL`]; + var cmd = [resources.terminal(), `DOCKER_HOST=${machine.url} DOCKER_CERT_PATH=${path.join(util.home(), '.docker/machine/machines/' + machine.name)} DOCKER_TLS_VERIFY=1 ${cmd}`]; util.exec(cmd).then(() => {}); }); } + }, + exec: function () { + } }; diff --git a/src/utils/Util.js b/src/utils/Util.js index 231e0578b6..4566025bf5 100644 --- a/src/utils/Util.js +++ b/src/utils/Util.js @@ -1,5 +1,5 @@ var exec = require('exec'); -var execProper = require('child_process').exec; +var child_process = require('child_process'); var Promise = require('bluebird'); var fs = require('fs'); var path = require('path'); @@ -10,8 +10,9 @@ var app = remote.require('app'); module.exports = { exec: function (args, options) { options = options || {}; + let fn = Array.isArray(args) ? exec : child_process.exec; return new Promise((resolve, reject) => { - exec(args, options, (stderr, stdout, code) => { + fn(args, options, (stderr, stdout, code) => { if (code) { var cmd = Array.isArray(args) ? args.join(' ') : args; reject(new Error(cmd + ' returned non zero exit code. Stderr: ' + stderr)); @@ -21,19 +22,6 @@ module.exports = { }); }); }, - execProper: function (args, options) { - options = options || {}; - return new Promise((resolve, reject) => { - execProper(args, options, (error, stdout, stderr) => { - if (error != null) { - var cmd = Array.isArray(args) ? args.join(' ') : args; - reject(new Error(cmd + ' returned non zero exit code. Stderr: ' + stderr)); - } else { - resolve(stdout); - } - }); - }); - }, isWindows: function () { return process.platform === 'win32'; },