balena-cli
Version:
The official balena Command Line Interface
57 lines (55 loc) • 2.37 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@oclif/core");
const cf = require("../../utils/common-flags");
const lazy_1 = require("../../utils/lazy");
class ConfigWriteCmd extends core_1.Command {
async run() {
const { args: params, flags: options } = await this.parse(ConfigWriteCmd);
const { denyMount, safeUmount } = await Promise.resolve().then(() => require('../../utils/umount'));
const drive = options.drive || (await (0, lazy_1.getVisuals)().drive('Select the device drive'));
await safeUmount(drive);
const config = await Promise.resolve().then(() => require('balena-config-json'));
const configJSON = await config.read(drive, '');
console.info(`Setting ${params.key} to ${params.value}`);
ConfigWriteCmd.updateConfigJson(configJSON, params.key, params.value);
await denyMount(drive, async () => {
await safeUmount(drive);
await config.write(drive, '', configJSON);
});
console.info('Done');
}
static updateConfigJson(configJSON, key, value) {
const _ = require('lodash');
_.setWith(configJSON, key, value, (v) => v || {});
}
}
ConfigWriteCmd.description = (0, lazy_1.stripIndent) `
Write a key-value pair to the config.json file of an OS image or attached media.
Write a key-value pair to the 'config.json' file of a balenaOS image file or
attached SD card or USB stick.
Documentation for the balenaOS 'config.json' file can be found at:
https://www.balena.io/docs/reference/OS/configuration/
`;
ConfigWriteCmd.examples = [
'$ balena config write ntpServers "0.resinio.pool.ntp.org 1.resinio.pool.ntp.org"',
'$ balena config write --drive /dev/disk2 hostname custom-hostname',
'$ balena config write --drive balena.img os.network.connectivity.interval 300',
];
ConfigWriteCmd.args = {
key: core_1.Args.string({
description: 'the key of the config parameter to write',
required: true,
}),
value: core_1.Args.string({
description: 'the value of the config parameter to write',
required: true,
}),
};
ConfigWriteCmd.flags = {
drive: cf.driveOrImg,
};
ConfigWriteCmd.root = true;
ConfigWriteCmd.offlineCompatible = true;
exports.default = ConfigWriteCmd;
//# sourceMappingURL=write.js.map
;