mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-02-21 17:56:57 +00:00
Implement config reconfigure command
This command allows the user to reconfigure an already provisioned device. Fixes: https://github.com/resin-io/resin-cli/issues/102
This commit is contained in:
parent
d522cbe1ca
commit
f64676ab98
@ -1,10 +1,12 @@
|
|||||||
(function() {
|
(function() {
|
||||||
var Promise, _, config, prettyjson, umount, visuals;
|
var Promise, _, capitano, config, prettyjson, umount, visuals;
|
||||||
|
|
||||||
_ = require('lodash');
|
_ = require('lodash');
|
||||||
|
|
||||||
Promise = require('bluebird');
|
Promise = require('bluebird');
|
||||||
|
|
||||||
|
capitano = Promise.promisifyAll(require('capitano'));
|
||||||
|
|
||||||
umount = Promise.promisifyAll(require('umount'));
|
umount = Promise.promisifyAll(require('umount'));
|
||||||
|
|
||||||
visuals = require('resin-cli-visuals');
|
visuals = require('resin-cli-visuals');
|
||||||
@ -83,4 +85,49 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.reconfigure = {
|
||||||
|
signature: 'config reconfigure',
|
||||||
|
description: 'reconfigure a provisioned device',
|
||||||
|
help: 'Use this command to reconfigure a provisioned device\n\nExamples:\n\n $ resin config reconfigure --type raspberry-pi\n $ resin config reconfigure --type raspberry-pi --advanced\n $ resin config reconfigure --type raspberry-pi --drive /dev/disk2',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
signature: 'type',
|
||||||
|
description: 'device type',
|
||||||
|
parameter: 'type',
|
||||||
|
alias: 't',
|
||||||
|
required: 'You have to specify a device type'
|
||||||
|
}, {
|
||||||
|
signature: 'drive',
|
||||||
|
description: 'drive',
|
||||||
|
parameter: 'drive',
|
||||||
|
alias: 'd'
|
||||||
|
}, {
|
||||||
|
signature: 'advanced',
|
||||||
|
description: 'show advanced commands',
|
||||||
|
boolean: true,
|
||||||
|
alias: 'v'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
permission: 'user',
|
||||||
|
root: true,
|
||||||
|
action: function(params, options, done) {
|
||||||
|
return Promise["try"](function() {
|
||||||
|
return options.drive || visuals.drive('Select the device drive');
|
||||||
|
}).tap(umount.umountAsync).then(function(drive) {
|
||||||
|
return config.read(drive, options.type).get('uuid').tap(function() {
|
||||||
|
return umount.umountAsync(drive);
|
||||||
|
}).then(function(uuid) {
|
||||||
|
var configureCommand;
|
||||||
|
configureCommand = "os configure " + drive + " " + uuid;
|
||||||
|
if (options.advanced) {
|
||||||
|
configureCommand += ' --advanced';
|
||||||
|
}
|
||||||
|
return capitano.runAsync(configureCommand);
|
||||||
|
});
|
||||||
|
}).then(function() {
|
||||||
|
return console.info('Done');
|
||||||
|
}).nodeify(done);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
}).call(this);
|
}).call(this);
|
||||||
|
@ -100,6 +100,8 @@
|
|||||||
|
|
||||||
capitano.command(actions.config.write);
|
capitano.command(actions.config.write);
|
||||||
|
|
||||||
|
capitano.command(actions.config.reconfigure);
|
||||||
|
|
||||||
capitano.command(actions.logs);
|
capitano.command(actions.logs);
|
||||||
|
|
||||||
update.notify();
|
update.notify();
|
||||||
|
@ -79,6 +79,7 @@ Now you have access to all the commands referenced below.
|
|||||||
|
|
||||||
- [config read](#config-read)
|
- [config read](#config-read)
|
||||||
- [config write <key> <value>](#config-write-60-key-62-60-value-62-)
|
- [config write <key> <value>](#config-write-60-key-62-60-value-62-)
|
||||||
|
- [config reconfigure](#config-reconfigure)
|
||||||
|
|
||||||
- Wizard
|
- Wizard
|
||||||
|
|
||||||
@ -627,6 +628,30 @@ device type
|
|||||||
|
|
||||||
drive
|
drive
|
||||||
|
|
||||||
|
## config reconfigure
|
||||||
|
|
||||||
|
Use this command to reconfigure a provisioned device
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin config reconfigure --type raspberry-pi
|
||||||
|
$ resin config reconfigure --type raspberry-pi --advanced
|
||||||
|
$ resin config reconfigure --type raspberry-pi --drive /dev/disk2
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
#### --type, -t <type>
|
||||||
|
|
||||||
|
device type
|
||||||
|
|
||||||
|
#### --drive, -d <drive>
|
||||||
|
|
||||||
|
drive
|
||||||
|
|
||||||
|
#### --advanced, -v
|
||||||
|
|
||||||
|
show advanced commands
|
||||||
|
|
||||||
# Wizard
|
# Wizard
|
||||||
|
|
||||||
## quickstart [name]
|
## quickstart [name]
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
_ = require('lodash')
|
_ = require('lodash')
|
||||||
Promise = require('bluebird')
|
Promise = require('bluebird')
|
||||||
|
capitano = Promise.promisifyAll(require('capitano'))
|
||||||
umount = Promise.promisifyAll(require('umount'))
|
umount = Promise.promisifyAll(require('umount'))
|
||||||
visuals = require('resin-cli-visuals')
|
visuals = require('resin-cli-visuals')
|
||||||
config = require('resin-config-json')
|
config = require('resin-config-json')
|
||||||
@ -88,3 +89,55 @@ exports.write =
|
|||||||
.tap ->
|
.tap ->
|
||||||
console.info('Done')
|
console.info('Done')
|
||||||
.nodeify(done)
|
.nodeify(done)
|
||||||
|
|
||||||
|
exports.reconfigure =
|
||||||
|
signature: 'config reconfigure'
|
||||||
|
description: 'reconfigure a provisioned device'
|
||||||
|
help: '''
|
||||||
|
Use this command to reconfigure a provisioned device
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ resin config reconfigure --type raspberry-pi
|
||||||
|
$ resin config reconfigure --type raspberry-pi --advanced
|
||||||
|
$ resin config reconfigure --type raspberry-pi --drive /dev/disk2
|
||||||
|
'''
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
signature: 'type'
|
||||||
|
description: 'device type'
|
||||||
|
parameter: 'type'
|
||||||
|
alias: 't'
|
||||||
|
required: 'You have to specify a device type'
|
||||||
|
}
|
||||||
|
{
|
||||||
|
signature: 'drive'
|
||||||
|
description: 'drive'
|
||||||
|
parameter: 'drive'
|
||||||
|
alias: 'd'
|
||||||
|
}
|
||||||
|
{
|
||||||
|
signature: 'advanced'
|
||||||
|
description: 'show advanced commands'
|
||||||
|
boolean: true
|
||||||
|
alias: 'v'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
permission: 'user'
|
||||||
|
root: true
|
||||||
|
action: (params, options, done) ->
|
||||||
|
Promise.try ->
|
||||||
|
return options.drive or visuals.drive('Select the device drive')
|
||||||
|
.tap(umount.umountAsync)
|
||||||
|
.then (drive) ->
|
||||||
|
config.read(drive, options.type).get('uuid')
|
||||||
|
.tap ->
|
||||||
|
umount.umountAsync(drive)
|
||||||
|
.then (uuid) ->
|
||||||
|
configureCommand = "os configure #{drive} #{uuid}"
|
||||||
|
if options.advanced
|
||||||
|
configureCommand += ' --advanced'
|
||||||
|
return capitano.runAsync(configureCommand)
|
||||||
|
.then ->
|
||||||
|
console.info('Done')
|
||||||
|
.nodeify(done)
|
||||||
|
@ -72,6 +72,7 @@ capitano.command(actions.os.initialize)
|
|||||||
# ---------- Config Module ----------
|
# ---------- Config Module ----------
|
||||||
capitano.command(actions.config.read)
|
capitano.command(actions.config.read)
|
||||||
capitano.command(actions.config.write)
|
capitano.command(actions.config.write)
|
||||||
|
capitano.command(actions.config.reconfigure)
|
||||||
|
|
||||||
# ---------- Logs Module ----------
|
# ---------- Logs Module ----------
|
||||||
capitano.command(actions.logs)
|
capitano.command(actions.logs)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user