diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c48b2b4..ca7c8ae7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY! This project adheres to [Semantic Versioning](http://semver.org/). +## v6.5.9 - 2018-01-12 + +* Fix saving deviceApiKey to the DB (to fix the RESIN_API_KEY env var) when updating from some older supervisors #544 [Pablo Carranza Velez] + ## v6.5.8 - 2018-01-10 * Update docker-toolbelt to v3.2.1 to fix a bug in deltas #543 [Pablo Carranza Velez] diff --git a/package.json b/package.json index 33260304..67c9db39 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "resin-supervisor", "description": "This is resin.io's Supervisor, a program that runs on IoT devices and has the task of running user Apps (which are Docker containers), and updating them as Resin's API informs it to.", - "version": "6.5.8", + "version": "6.5.9", "license": "Apache-2.0", "repository": { "type": "git", diff --git a/src/bootstrap.coffee b/src/bootstrap.coffee index d35303c7..c2943866 100644 --- a/src/bootstrap.coffee +++ b/src/bootstrap.coffee @@ -223,6 +223,17 @@ bootstrapper.done = new Promise (resolve) -> # This will only be the case when the supervisor/OS has been updated. if userConfig.apiKey? exchangeKeyOrRetry() + else + Promise.join( + knex('config').select('value').where(key: 'apiKey') + knex('config').select('value').where(key: 'deviceApiKey') + ([ apiKey ], [ deviceApiKey ]) -> + if !deviceApiKey?.value + # apiKey in the DB is actually the deviceApiKey, but it was + # exchanged in a supervisor version that didn't save it to the DB + # (which mainly affects the RESIN_API_KEY env var) + knex('config').insert({ key: 'deviceApiKey', value: apiKey.value }) + ) return bootstrapper.bootstrapped = false