mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-30 02:28:53 +00:00
Merge pull request #82 from resin-io/75-report-host-os-version
Report Host OS version to the API
This commit is contained in:
commit
9c52149f0f
@ -1,3 +1,4 @@
|
||||
* Report Host OS version to the API [Pablo]
|
||||
* Use _.defaults instead of _.extend to ensure internal env vars are not overwritten [Pablo]
|
||||
* Expose resin API key to apps [Pablo]
|
||||
* On download start, set download_progress to 0. On finish, set state to Idle [Pablo]
|
||||
|
@ -24,6 +24,8 @@ knex.init.then ->
|
||||
|
||||
bootstrap.done
|
||||
.then ->
|
||||
device.getOSVersion()
|
||||
.then (osVersion) ->
|
||||
console.log('Starting API server..')
|
||||
api(application).listen(config.listenPort)
|
||||
# Let API know what version we are, and our api connection info.
|
||||
@ -31,6 +33,7 @@ knex.init.then ->
|
||||
device.updateState(
|
||||
api_port: config.listenPort
|
||||
api_secret: secret
|
||||
os_version: osVersion
|
||||
supervisor_version: utils.supervisorVersion
|
||||
provisioning_progress: null
|
||||
provisioning_state: ''
|
||||
|
@ -36,3 +36,4 @@ module.exports = config =
|
||||
logsChannel: process.env.RESIN_SUPERVISOR_LOGS_CHANNEL ? null
|
||||
vpnStatusPath: process.env.VPN_STATUS_PATH ? '/mnt/root/run/openvpn/vpn_status'
|
||||
checkInt: checkInt
|
||||
hostOsVersionPath: process.env.HOST_OS_VERSION_PATH ? '/mnt/root/etc/os-release'
|
||||
|
@ -177,3 +177,16 @@ exports.updateState = do ->
|
||||
if !applyPromise.isPending()
|
||||
applyState()
|
||||
return
|
||||
|
||||
exports.getOSVersion = ->
|
||||
fs.readFileAsync(config.hostOsVersionPath)
|
||||
.then (releaseData) ->
|
||||
lines = _.split(releaseData, "\n")
|
||||
releaseItems = {}
|
||||
for line in lines
|
||||
[ key, val ] = _.split(line, '=')
|
||||
releaseItems[_.trim(key)] = _.trim(val)
|
||||
return releaseItems['PRETTY_NAME']
|
||||
.catch (err) ->
|
||||
console.log("Could not get OS Version: ", err, err.stack)
|
||||
return undefined
|
||||
|
Loading…
Reference in New Issue
Block a user