From 91b59abd420c96c7eb0c54840cff002a9d17c4c1 Mon Sep 17 00:00:00 2001 From: Petros Aggelatos Date: Mon, 23 Dec 2013 04:28:34 +0000 Subject: [PATCH] Save parameters in SQLite on successful bootstrapping --- src/bootstrap.coffee | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/bootstrap.coffee b/src/bootstrap.coffee index 0cdb4b56..da08583e 100644 --- a/src/bootstrap.coffee +++ b/src/bootstrap.coffee @@ -54,4 +54,19 @@ module.exports = (uuid) -> fs.writeFileAsync('/supervisor/data/client.crt', body.cert) vpnConf ]) - ).then(knex('config').select('value').where(key: 'uuid') + ).then(-> + console.log('Finishing bootstrapping') + Promise.all([ + knex('config').truncate().then(config).then((config) -> + knex('config').insert([ + {key: 'uuid', value: uuid} + {key: 'apiKey', value: config.apiKey} + {key: 'username', value: config.username} + {key: 'userId', value: config.userId} + ]) + ) + knex('app').truncate() + ]) + ).catch((error) -> + console.log(error) + )