Report Host OS version to the API

This commit is contained in:
Pablo Carranza Velez 2016-01-20 19:57:17 +00:00
parent 686c40461e
commit 8a4514ac00
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] * Use _.defaults instead of _.extend to ensure internal env vars are not overwritten [Pablo]
* Expose resin API key to apps [Pablo] * Expose resin API key to apps [Pablo]
* On download start, set download_progress to 0. On finish, set state to Idle [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 bootstrap.done
.then -> .then ->
device.getOSVersion()
.then (osVersion) ->
console.log('Starting API server..') console.log('Starting API server..')
api(application).listen(config.listenPort) api(application).listen(config.listenPort)
# Let API know what version we are, and our api connection info. # Let API know what version we are, and our api connection info.
@ -31,6 +33,7 @@ knex.init.then ->
device.updateState( device.updateState(
api_port: config.listenPort api_port: config.listenPort
api_secret: secret api_secret: secret
os_version: osVersion
supervisor_version: utils.supervisorVersion supervisor_version: utils.supervisorVersion
provisioning_progress: null provisioning_progress: null
provisioning_state: '' provisioning_state: ''

View File

@ -36,3 +36,4 @@ module.exports = config =
logsChannel: process.env.RESIN_SUPERVISOR_LOGS_CHANNEL ? null logsChannel: process.env.RESIN_SUPERVISOR_LOGS_CHANNEL ? null
vpnStatusPath: process.env.VPN_STATUS_PATH ? '/mnt/root/run/openvpn/vpn_status' vpnStatusPath: process.env.VPN_STATUS_PATH ? '/mnt/root/run/openvpn/vpn_status'
checkInt: checkInt 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() if !applyPromise.isPending()
applyState() applyState()
return 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