2017-07-27 11:07:05 +00:00
// Generated by CoffeeScript 1.12.7
2017-03-08 23:30:24 +00:00
/ *
Copyright 2017 Resin . io
Licensed under the Apache License , Version 2.0 ( the "License" ) ;
you may not use this file except in compliance with the License .
You may obtain a copy of the License at
http : //www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing , software
distributed under the License is distributed on an "AS IS" BASIS ,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
See the License for the specific language governing permissions and
limitations under the License .
* /
2017-03-22 09:46:06 +00:00
module . exports = {
signature : 'local promote [deviceIp]' ,
description : 'Promote a resinOS device' ,
help : 'Warning: \'resin promote\' requires an openssh-compatible client to be correctly\ninstalled in your shell environment. For more information (including Windows\nsupport) please check the README here: https://github.com/resin-io/resin-cli\n\nUse this command to promote your device.\n\nPromoting a device will provision it onto the Resin platform,\nconverting it from an unmanaged device to a managed device.\n\nExamples:\n\n $ resin local promote\n $ resin local promote --port 22222\n $ resin local promote --verbose' ,
options : [
{
signature : 'verbose' ,
boolean : true ,
description : 'increase verbosity' ,
alias : 'v'
} , {
signature : 'port' ,
parameter : 'port' ,
description : 'ssh port number (default: 22222)' ,
alias : 'p'
2017-03-08 23:30:24 +00:00
}
2017-03-22 09:46:06 +00:00
] ,
root : true ,
action : function ( params , options , done ) {
var Promise , _ , child _process , forms , getSubShellCommand , verbose ;
child _process = require ( 'child_process' ) ;
Promise = require ( 'bluebird' ) ;
_ = require ( 'lodash' ) ;
forms = require ( 'resin-sync' ) . forms ;
getSubShellCommand = require ( './common' ) . getSubShellCommand ;
if ( options . port == null ) {
options . port = 22222 ;
}
verbose = options . verbose ? '-vvv' : '' ;
return Promise [ "try" ] ( function ( ) {
return params . deviceIp != null ? params . deviceIp : params . deviceIp = forms . selectLocalResinOsDevice ( ) ;
} ) . then ( function ( deviceIp ) {
var command , subShellCommand ;
_ . assign ( options , {
deviceIp : deviceIp
} ) ;
2017-06-29 08:51:29 +00:00
command = "ssh " + verbose + " -t -p " + options . port + " -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@" + options . deviceIp + " -- \"resin-provision interactive\"" ;
2017-03-22 09:46:06 +00:00
subShellCommand = getSubShellCommand ( command ) ;
return child _process . spawn ( subShellCommand . program , subShellCommand . args , {
stdio : 'inherit'
} ) ;
} ) . nodeify ( done ) ;
}
} ;