7.0.1 • Published 24 days ago

balena-device-init v7.0.1

Weekly downloads
710
License
Apache-2.0
Repository
github
Last release
24 days ago

balena-device-init

npm version dependencies Build Status

Configure and initialize devices using device specs.

Role

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.

Installation

Install balena-device-init by running:

$ npm install --save balena-device-init

Documentation

init.configure(image, manifest, config, options) ⇒ Promise.<EventEmitter>

This function injects config.json and network settings into the image.

Kind: static method of init
Summary: Configure an image with an application
Returns: Promise.<EventEmitter> - configuration event emitter
Access: public

ParamTypeDescription
imageStringpath to image
manifestObjectdevice type manifest
configObjecta fully populated config object
optionsObjectconfiguration 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')

init.initialize(image, manifest, options) ⇒ Promise.<EventEmitter>

Kind: static method of init
Summary: Initialize an image
Returns: Promise.<EventEmitter> - initialization event emitter
Access: public

ParamTypeDescription
imageStringpath to image
manifestObjectdevice type manifest
optionsObjectconfiguration 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')

Support

If you're having any problem, please raise an issue on GitHub and the balena team will be happy to help.

Tests

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

Contribute

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

License

The project is licensed under the Apache 2.0 license.

7.0.1

24 days ago

6.0.0

3 years ago

5.0.2

4 years ago

5.0.1

4 years ago

5.0.0

5 years ago

4.3.0

6 years ago