diff --git a/CHANGELOG.md b/CHANGELOG.md index bc0b2436..d77ff8d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +* Fix preloaded apps so that they have the complete environment [Pablo] + # v0.0.17 * Updated bases image to board-specific, and all node versions to 0.10.40-slim [Pablo] diff --git a/src/application.coffee b/src/application.coffee index 2af00807..c96bd5c6 100644 --- a/src/application.coffee +++ b/src/application.coffee @@ -354,13 +354,7 @@ application.update = update = (force) -> .then (remoteApps) -> remoteAppEnvs = {} remoteApps = _.map remoteApps, (app) -> - env = - RESIN_DEVICE_UUID: uuid - RESIN: '1' - USER: 'root' - - if app.environment_variable? - _.extend(env, app.environment_variable) + env = utils.extendEnvVars(app.environment_variable, uuid) remoteAppEnvs[app.id] = env env = _.omit(env, _.keys(specialActionEnvVars)) return { diff --git a/src/bootstrap.coffee b/src/bootstrap.coffee index 63e878af..d22a8b9c 100644 --- a/src/bootstrap.coffee +++ b/src/bootstrap.coffee @@ -22,12 +22,7 @@ loadPreloadedApps = -> fs.readFileAsync(appsPath, 'utf8') .then(JSON.parse) .map (app) -> - env = - RESIN_DEVICE_UUID: userConfig.uuid - RESIN: '1' - USER: 'root' - _.extend(app.env, env) - app.env = JSON.stringify(app.env) + app.env = JSON.stringify(utils.extendEnvVars(app.env, userConfig.uuid)) knex('app').insert(app) .catch (err) -> utils.mixpanelTrack('Loading preloaded apps failed', {error: err}) diff --git a/src/utils.coffee b/src/utils.coffee index 1394d358..f61c7d48 100644 --- a/src/utils.coffee +++ b/src/utils.coffee @@ -96,3 +96,12 @@ exports.connectivityCheck = _.once -> else console.log('Waiting for connectivity...') blink.pattern.start(networkPattern) + +exports.extendEnvVars = (env, uuid) -> + newEnv = + RESIN_DEVICE_UUID: uuid + RESIN: '1' + USER: 'root' + if env? + _.extend(newEnv, env) + return newEnv