mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-19 13:47:54 +00:00
update device supervisor_version
This commit is contained in:
parent
567784b3e9
commit
523a8b5637
@ -52,7 +52,7 @@ knex('config').select('value').where(key: 'uuid').then ([ uuid ]) ->
|
|||||||
|
|
||||||
api = require './api'
|
api = require './api'
|
||||||
application = require './application'
|
application = require './application'
|
||||||
supervisor = require './supervisor-update'
|
supervisor = require './supervisor'
|
||||||
|
|
||||||
console.log('Starting OpenVPN..')
|
console.log('Starting OpenVPN..')
|
||||||
openvpn = spawn('openvpn', [ 'client.conf' ], cwd: '/data')
|
openvpn = spawn('openvpn', [ 'client.conf' ], cwd: '/data')
|
||||||
@ -97,3 +97,8 @@ knex('config').select('value').where(key: 'uuid').then ([ uuid ]) ->
|
|||||||
|
|
||||||
# Tell the supervisor updater that we have successfully started, so that it can do whatever it needs to.
|
# Tell the supervisor updater that we have successfully started, so that it can do whatever it needs to.
|
||||||
supervisor.startupSuccessful()
|
supervisor.startupSuccessful()
|
||||||
|
|
||||||
|
# Let API know we are running a new version
|
||||||
|
application.updateDeviceInfo(
|
||||||
|
supervisor_version: supervisor.version
|
||||||
|
)
|
||||||
|
@ -9,6 +9,7 @@ config = require './config'
|
|||||||
csrgen = Promise.promisify require 'csr-gen'
|
csrgen = Promise.promisify require 'csr-gen'
|
||||||
request = Promise.promisify require 'request'
|
request = Promise.promisify require 'request'
|
||||||
PlatformAPI = require 'resin-platform-api/request'
|
PlatformAPI = require 'resin-platform-api/request'
|
||||||
|
supervisor = require './supervisor'
|
||||||
|
|
||||||
PLATFORM_ENDPOINT = url.resolve(config.apiEndpoint, '/ewa/')
|
PLATFORM_ENDPOINT = url.resolve(config.apiEndpoint, '/ewa/')
|
||||||
resinAPI = new PlatformAPI(PLATFORM_ENDPOINT)
|
resinAPI = new PlatformAPI(PLATFORM_ENDPOINT)
|
||||||
@ -44,8 +45,6 @@ module.exports = ->
|
|||||||
.tap (uuid) ->
|
.tap (uuid) ->
|
||||||
userConfig.uuid = uuid
|
userConfig.uuid = uuid
|
||||||
.then (uuid) ->
|
.then (uuid) ->
|
||||||
version = utils.getSupervisorVersion()
|
|
||||||
|
|
||||||
# Generate SSL certificate
|
# Generate SSL certificate
|
||||||
keys = csrgen(uuid,
|
keys = csrgen(uuid,
|
||||||
company: 'Rulemotion Ltd'
|
company: 'Rulemotion Ltd'
|
||||||
@ -60,19 +59,18 @@ module.exports = ->
|
|||||||
division: ''
|
division: ''
|
||||||
)
|
)
|
||||||
|
|
||||||
return [keys, version, uuid]
|
return [keys, uuid]
|
||||||
.spread (keys, version, uuid) ->
|
.spread (keys, uuid) ->
|
||||||
console.log('UUID:', uuid)
|
console.log('UUID:', uuid)
|
||||||
console.log('User ID:', userConfig.userId)
|
console.log('User ID:', userConfig.userId)
|
||||||
console.log('User:', userConfig.username)
|
console.log('User:', userConfig.username)
|
||||||
console.log('Supervisor Version:', version)
|
console.log('Supervisor Version:', supervisor.version)
|
||||||
console.log('API key:', userConfig.apiKey)
|
console.log('API key:', userConfig.apiKey)
|
||||||
console.log('Application ID:', userConfig.applicationId)
|
console.log('Application ID:', userConfig.applicationId)
|
||||||
console.log('CSR :', keys.csr)
|
console.log('CSR :', keys.csr)
|
||||||
console.log('Posting to the API..')
|
console.log('Posting to the API..')
|
||||||
userConfig.csr = keys.csr
|
userConfig.csr = keys.csr
|
||||||
userConfig.uuid = uuid
|
userConfig.uuid = uuid
|
||||||
userConfig.version = version
|
|
||||||
return request(
|
return request(
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
url: url.resolve(config.apiEndpoint, 'sign_certificate?apikey=' + userConfig.apiKey)
|
url: url.resolve(config.apiEndpoint, 'sign_certificate?apikey=' + userConfig.apiKey)
|
||||||
@ -106,7 +104,7 @@ module.exports = ->
|
|||||||
{ key: 'apiKey', value: userConfig.apiKey }
|
{ key: 'apiKey', value: userConfig.apiKey }
|
||||||
{ key: 'username', value: userConfig.username }
|
{ key: 'username', value: userConfig.username }
|
||||||
{ key: 'userId', value: userConfig.userId }
|
{ key: 'userId', value: userConfig.userId }
|
||||||
{ key: 'version', value: userConfig.version }
|
{ key: 'version', value: supervisor.version }
|
||||||
])
|
])
|
||||||
knex('app').truncate()
|
knex('app').truncate()
|
||||||
])
|
])
|
||||||
|
@ -1,8 +1,15 @@
|
|||||||
process.on 'uncaughtException', (e) ->
|
process.on 'uncaughtException', (e) ->
|
||||||
console.error('Got unhandled exception', e, e?.stack)
|
console.error('Got unhandled exception', e, e?.stack)
|
||||||
|
|
||||||
|
fs = require 'fs'
|
||||||
supervisor = require './supervisor-update'
|
supervisor = require './supervisor-update'
|
||||||
|
|
||||||
|
# Parses package.json and returns resin-supervisor's version
|
||||||
|
supervisor.version = version = do ->
|
||||||
|
packageJson = fs.readFileSync(__dirname + '/../package.json', 'utf-8')
|
||||||
|
obj = JSON.parse packageJson
|
||||||
|
return obj.version
|
||||||
|
|
||||||
# Make sure the supervisor-update has initialised before we continue, as it will handle restarting to add mounts if
|
# Make sure the supervisor-update has initialised before we continue, as it will handle restarting to add mounts if
|
||||||
# necessary.
|
# necessary.
|
||||||
supervisor.initialised.then ->
|
supervisor.initialised.then ->
|
||||||
@ -19,3 +26,5 @@ supervisor.initialised.then ->
|
|||||||
# Wait for the DB schema to be created
|
# Wait for the DB schema to be created
|
||||||
knex.init.then ->
|
knex.init.then ->
|
||||||
require('./app')
|
require('./app')
|
||||||
|
|
||||||
|
module.exports = exports = supervisor
|
||||||
|
@ -5,13 +5,6 @@ config = require './config'
|
|||||||
mixpanel = require 'mixpanel'
|
mixpanel = require 'mixpanel'
|
||||||
request = Promise.promisifyAll require 'request'
|
request = Promise.promisifyAll require 'request'
|
||||||
|
|
||||||
# Parses package.json and returns resin-supervisor's version
|
|
||||||
exports.getSupervisorVersion = ->
|
|
||||||
fs.readFileAsync(__dirname + '/../package.json', 'utf-8')
|
|
||||||
.then (data) ->
|
|
||||||
obj = JSON.parse data
|
|
||||||
return obj.version
|
|
||||||
|
|
||||||
mixpanelClient = mixpanel.init(config.mixpanelToken)
|
mixpanelClient = mixpanel.init(config.mixpanelToken)
|
||||||
|
|
||||||
exports.mixpanelProperties = mixpanelProperties =
|
exports.mixpanelProperties = mixpanelProperties =
|
||||||
|
Loading…
Reference in New Issue
Block a user