Configure and initialize devices using device specs.
The intention of this module is to provide low level access to how balena configures and initialises devices using device specs.
THIS MODULE IS LOW LEVEL AND IS NOT MEANT TO BE USED BY END USERS DIRECTLY.
Install balena-device-init
by running:
$ npm install --save balena-device-init
- init
- ~configure(image, manifest, config, [options]) ⇒
Promise.<EventEmitter>
- ~initialize(image, manifest, options) ⇒
Promise.<EventEmitter>
- ~configure(image, manifest, config, [options]) ⇒
This function injects config.json
and network settings into the image.
Kind: inner method of init
Summary: Configure an image with an application
Returns: Promise.<EventEmitter>
- configuration event emitter
Access: public
Param | Type | Description |
---|---|---|
image | String |
path to image |
manifest | Object |
device type manifest |
config | Object |
a fully populated config object |
[options] | Object |
configuration options |
Example
init.configure('my/rpi.img', manifest, config).then (configuration) ->
configuration.on('stdout', process.stdout.write)
configuration.on('stderr', process.stderr.write)
configuration.on 'state', (state) ->
console.log(state.operation.command)
console.log(state.percentage)
configuration.on 'error', (error) ->
throw error
configuration.on 'end', ->
console.log('Configuration finished')
Kind: inner method of init
Summary: Initialize an image
Returns: Promise.<EventEmitter>
- initialization event emitter
Access: public
Param | Type | Description |
---|---|---|
image | String |
path to image |
manifest | Object |
device type manifest |
options | Object |
configuration options |
Example
init.initialize('my/rpi.img', manifest, network: 'ethernet').then (configuration) ->
configuration.on('stdout', process.stdout.write)
configuration.on('stderr', process.stderr.write)
configuration.on 'state', (state) ->
console.log(state.operation.command)
console.log(state.percentage)
configuration.on 'burn', (state) ->
console.log(state)
configuration.on 'error', (error) ->
throw error
configuration.on 'end', ->
console.log('Configuration finished')
If you're having any problem, please raise an issue on GitHub and the balena team will be happy to help.
Create an .env
file and put the following lines in it, replacing the asterisks
with the valid credentials for a test user on balena-staging.com
TEST_EMAIL=***
TEST_PASSWORD=***
Run the test suite by doing:
$ npm test
- Issue Tracker: github.com/balena-io/balena-device-init/issues
- Source Code: github.com/balena-io/balena-device-init
Before submitting a PR, please make sure that you include tests, and that coffeelint runs without any warning:
$ gulp lint
You can then run the tests with:
npm test
The project is licensed under the Apache 2.0 license.