Merge pull request #82 from resin-io/75-report-host-os-version

Report Host OS version to the API
This commit is contained in:
Pablo Carranza Vélez 2016-01-26 11:01:07 -03:00
commit 9c52149f0f
4 changed files with 18 additions and 0 deletions

View File

@ -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]

View File

@ -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: ''

View File

@ -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'

View File

@ -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