Merge pull request from resin-io/feature/resin-ssh-verbose

Support --verbose/-v flag in resin ssh
This commit is contained in:
Juan Cruz Viotti 2016-06-22 09:37:03 -04:00 committed by GitHub
commit c5452f9304
2 changed files with 18 additions and 4 deletions
build/actions
lib/actions

View File

@ -37,7 +37,7 @@ limitations under the License.
module.exports = {
signature: 'ssh <uuid>',
description: '(beta) get a shell into the running app container of a device',
help: 'WARNING: If you\'re running Windows, this command only supports `cmd.exe`.\n\nUse this command to get a shell into the running application container of\nyour device.\n\nExamples:\n\n $ resin ssh 7cf02a6\n $ resin ssh 7cf02a6 --port 8080',
help: 'WARNING: If you\'re running Windows, this command only supports `cmd.exe`.\n\nUse this command to get a shell into the running application container of\nyour device.\n\nExamples:\n\n $ resin ssh 7cf02a6\n $ resin ssh 7cf02a6 --port 8080\n $ resin ssh 7cf02a6 -v',
permission: 'user',
primary: true,
options: [
@ -46,10 +46,15 @@ limitations under the License.
parameter: 'port',
description: 'ssh gateway port',
alias: 't'
}, {
signature: 'verbose',
boolean: true,
description: 'increase verbosity',
alias: 'v'
}
],
action: function(params, options, done) {
var Promise, child_process, resin, settings;
var Promise, child_process, resin, settings, verbose;
child_process = require('child_process');
Promise = require('bluebird');
resin = require('resin-sdk');
@ -57,6 +62,7 @@ limitations under the License.
if (options.port == null) {
options.port = 22;
}
verbose = options.verbose ? '-vvv' : '';
console.info("Connecting with: " + params.uuid);
return Promise.props({
isOnline: resin.models.device.isOnline(params.uuid),
@ -74,7 +80,7 @@ limitations under the License.
}
return Promise["try"](function() {
var command, spawn, subShellCommand;
command = "ssh -t -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p " + options.port + " " + username + "@ssh." + (settings.get('proxyUrl')) + " enter " + uuid + " " + containerId;
command = "ssh " + verbose + " -t -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p " + options.port + " " + username + "@ssh." + (settings.get('proxyUrl')) + " enter " + uuid + " " + containerId;
subShellCommand = getSubShellCommand(command);
return spawn = child_process.spawn(subShellCommand.program, subShellCommand.args, {
stdio: 'inherit'

View File

@ -48,6 +48,7 @@ module.exports =
$ resin ssh 7cf02a6
$ resin ssh 7cf02a6 --port 8080
$ resin ssh 7cf02a6 -v
'''
permission: 'user'
primary: true
@ -56,6 +57,11 @@ module.exports =
parameter: 'port'
description: 'ssh gateway port'
alias: 't'
,
signature: 'verbose'
boolean: true
description: 'increase verbosity'
alias: 'v'
]
action: (params, options, done) ->
child_process = require('child_process')
@ -66,6 +72,8 @@ module.exports =
if not options.port?
options.port = 22
verbose = if options.verbose then '-vvv' else ''
console.info("Connecting with: #{params.uuid}")
Promise.props
@ -77,7 +85,7 @@ module.exports =
throw new Error('Device is not online') if not isOnline
throw new Error('Did not find running application container') if not containerId?
Promise.try ->
command = "ssh -t -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
command = "ssh #{verbose} -t -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
-p #{options.port} #{username}@ssh.#{settings.get('proxyUrl')} enter #{uuid} #{containerId}"
subShellCommand = getSubShellCommand(command)