Bind mount /boot in RPi

This commit is contained in:
Pablo Carranza Vélez 2015-09-18 17:51:36 +00:00
parent 1848a819da
commit bd889e06a1
3 changed files with 38 additions and 16 deletions

View File

@ -1,3 +1,4 @@
* Bind mount /boot in Raspberry Pis [Pablo]
* Implement and use golang endpoint for getting IPs of the device, also fixes duplicate IP reporting in the JS implementation [Praneeth]
* Refactor bootstrapping to run in background [Pablo]
* Run preloaded app images [Pablo]

View File

@ -136,7 +136,29 @@ fetch = (app) ->
throw err
application.start = start = (app) ->
Promise.try ->
volumes =
'/data': {}
'/lib/modules': {}
'/lib/firmware': {}
'/run/dbus': {}
binds = [
'/resin-data/' + app.appId + ':/data'
'/lib/modules:/lib/modules'
'/lib/firmware:/lib/firmware'
'/run/dbus:/run/dbus'
'/run/dbus:/host_run/dbus'
'/var/run/docker.sock:/run/docker.sock'
'/var/run/docker.sock:/host_run/docker.sock'
'/etc/resolv.conf:/etc/resolv.conf:rw'
]
device.getDeviceType()
.then (deviceType) ->
if deviceType.match(/^raspberry-pi/)?
volumes['/boot'] = {}
binds.push('/boot:/boot')
.catch (err) ->
console.log('Could not determine device type: ', err)
.then ->
# Parse the env vars before trying to access them, that's because they have to be stringified for knex..
JSON.parse(app.env)
.then (env) ->
@ -174,11 +196,7 @@ application.start = start = (app) ->
Image: app.imageId
Cmd: cmd
Tty: true
Volumes:
'/data': {}
'/lib/modules': {}
'/lib/firmware': {}
'/run/dbus': {}
Volumes: volumes
Env: _.map env, (v, k) -> k + '=' + v
ExposedPorts: ports
)
@ -205,16 +223,7 @@ application.start = start = (app) ->
Privileged: true
NetworkMode: 'host'
PortBindings: ports
Binds: [
'/resin-data/' + app.appId + ':/data'
'/lib/modules:/lib/modules'
'/lib/firmware:/lib/firmware'
'/run/dbus:/run/dbus'
'/run/dbus:/host_run/dbus'
'/var/run/docker.sock:/run/docker.sock'
'/var/run/docker.sock:/host_run/docker.sock'
'/etc/resolv.conf:/etc/resolv.conf:rw'
]
Binds: binds
)
.catch (err) ->
statusCode = '' + err.statusCode

View File

@ -4,6 +4,7 @@ knex = require './db'
utils = require './utils'
{ resinApi } = require './request'
device = exports
configPath = '/boot/config.json'
exports.getID = do ->
deviceIdPromise = null
@ -31,6 +32,17 @@ exports.getID = do ->
throw new Error('Could not find this device?!')
return devices[0].id
exports.getDeviceType = do ->
deviceTypePromise = null
return ->
deviceTypePromise ?= Promise.rejected()
deviceTypePromise = deviceTypePromise.catch ->
fs.readFileAsync(configPath, 'utf8')
.then(JSON.parse)
.then (configFromFile) ->
if !configFromFile.deviceType?
throw new Error('Device type not specified in config file')
return configFromFile.deviceType
# Calling this function updates the local device state, which is then used to synchronise
# the remote device state, repeating any failed updates until successfully synchronised.