diff --git a/index.js b/index.js index b030f32b39..6adb0184c5 100644 --- a/index.js +++ b/index.js @@ -47,7 +47,7 @@ var start = function (callback) { console.log('MongoDB: ' + mongoPort); console.log('webPort: ' + webPort); child_process.exec('kill $(ps aux -e | grep PURPOSE=KITEMATIC | awk \'{print $2}\') && rm ' + path.join(dataPath, 'mongod.lock'), function (error, stdout, stderr) { - var mongoChild = child_process.spawn(path.join(process.cwd(), 'resources', 'mongod'), ['--bind_ip', '127.0.0.1', '--dbpath', dataPath, '--port', mongoPort, '--unixSocketPrefix', dataPath], { + var mongoChild = child_process.spawn(path.join(__dirname, 'resources', 'mongod'), ['--bind_ip', '127.0.0.1', '--dbpath', dataPath, '--port', mongoPort, '--unixSocketPrefix', dataPath], { env: { PURPOSE: 'KITEMATIC' } @@ -65,29 +65,16 @@ var start = function (callback) { console.log('Starting node child...'); var rootURL = 'http://localhost:' + webPort; var user_env = process.env; - user_env.ROOT_URL = rootURL; - user_env.PORT = webPort; - user_env.BIND_IP = '127.0.0.1'; - user_env.DB_PATH = dataPath; - user_env.MONGO_URL = 'mongodb://localhost:' + mongoPort + '/meteor'; - user_env.METEOR_SETTINGS = fs.readFileSync(path.join(process.cwd(), 'resources', 'settings.json'), 'utf8'); - var nodeChild = child_process.spawn(path.join(process.cwd(), 'resources', 'node'), ['./bundle/main.js'], { - env: user_env - }); - - var opened = false; - nodeChild.stdout.setEncoding('utf8'); - nodeChild.stdout.on('data', function (data) { - console.log(data); - if (data.indexOf('Kitematic started.') !== -1) { - if (!opened) { - opened = true; - } else { - return; - } - callback(rootURL, nodeChild, mongoChild); - } - }); + process.env.ROOT_URL = rootURL; + process.env.PORT = webPort; + process.env.BIND_IP = '127.0.0.1'; + process.env.DB_PATH = dataPath; + process.env.MONGO_URL = 'mongodb://localhost:' + mongoPort + '/meteor'; + process.env.METEOR_SETTINGS = fs.readFileSync(path.join(__dirname, 'resources', 'settings.json'), 'utf8'); + process.env.DIR = __dirname; + process.env.NODE_ENV = 'production'; + process.env.NODE_PATH = path.join(__dirname, 'node_modules'); + require('./bundle/main.js'); } }); }); @@ -128,5 +115,7 @@ app.on('ready', function() { // and load the index.html of the app. mainWindow.loadUrl(url); mainWindow.show(); + mainWindow.focus(); }); }); + diff --git a/kitematic.icns b/kitematic.icns new file mode 100644 index 0000000000..8f8fdaac95 Binary files /dev/null and b/kitematic.icns differ diff --git a/meteor/client/lib/docker.js b/meteor/client/lib/docker.js index 4759ab0a53..feb5d44ebd 100644 --- a/meteor/client/lib/docker.js +++ b/meteor/client/lib/docker.js @@ -7,7 +7,7 @@ Docker = {}; Docker.DOCKER_HOST = '192.168.60.103'; Docker.DEFAULT_IMAGES_FILENAME = 'base-images-0.0.2.tar.gz'; -Docker.DEFAULT_IMAGES_CHECKSUM = '67e7c7562991a4208c90007461ec14bc184a52ad6048e6bed3e8a8c2b306cee7'; // Sha256 Checksum +Docker.DEFAULT_IMAGES_CHECKSUM = 'a3517ac21034a1969d9ff15e3c41b1e2f1aa83c67b16a8bd0bc378ffefaf573b'; // Sha256 Checksum Docker.client = function () { return new Dockerode({host: Docker.DOCKER_HOST, port: '2375'}); diff --git a/meteor/client/lib/installer.js b/meteor/client/lib/installer.js index aa20d8bc52..aeeebd177f 100644 --- a/meteor/client/lib/installer.js +++ b/meteor/client/lib/installer.js @@ -88,7 +88,9 @@ Installer.steps = [ callback('Boot2Docker SSH key doesn\'t exist. Fix by deleting the existing Boot2Docker VM and re-run the installer. This usually occurs because an old version of Boot2Docker is installed.'); } else { Boot2Docker.stop(function(err) { - callback(); + Boot2Docker.upgrade(function (err) { + callback(err); + }); }); } } diff --git a/meteor/client/lib/router.js b/meteor/client/lib/router.js index ad5f20fb0f..dac40de9da 100755 --- a/meteor/client/lib/router.js +++ b/meteor/client/lib/router.js @@ -13,14 +13,14 @@ Router.configure({ SetupController = RouteController.extend({ layoutTemplate: 'setup_layout', waitOn: function () { - return [Meteor.subscribe('installs')]; + return [Meteor.subscribe('installs'), Meteor.subscribe('settings')]; } }); DashboardController = RouteController.extend({ layoutTemplate: 'dashboard_layout', waitOn: function () { - return [Meteor.subscribe('apps'), Meteor.subscribe('images'), Meteor.subscribe('installs')]; + return [Meteor.subscribe('apps'), Meteor.subscribe('images'), Meteor.subscribe('installs'), Meteor.subscribe('settings')]; } }); @@ -50,6 +50,11 @@ Router.map(function () { controller: 'SetupController' }); + this.route('setup_finish', { + path: '/setup/finish', + controller: 'SetupController' + }); + this.route('setup', { path: '/', controller: 'SetupController', @@ -58,12 +63,11 @@ Router.map(function () { if (!Installer.isUpToDate()) { if (!Installs.findOne()) { console.log('No installs detected, running installer again.'); - this.redirect('/setup/intro'); } else { // There's an install but it's lower than the current version, re-run as an 'update'. Session.set('isUpdating', true); - this.redirect('/setup/intro'); } + this.redirect('/setup/intro'); } else { this.redirect('/apps'); } diff --git a/meteor/client/lib/util.js b/meteor/client/lib/util.js index 29fcbf8b8c..f66d8a3e16 100755 --- a/meteor/client/lib/util.js +++ b/meteor/client/lib/util.js @@ -1,7 +1,8 @@ var path = require('path'); var fs = require('fs'); -var wget = require('wget'); var nodeCrypto = require('crypto'); +var request = require('request'); +var progress = require('request-progress'); Util = {}; @@ -10,15 +11,7 @@ Util.getHomePath = function () { }; Util.getBinDir = function () { - if (process.env.NODE_ENV === 'development') { - return path.join(path.join(process.env.PWD, '..'), 'resources'); - } else { - if (Meteor.isClient) { - return path.join(process.cwd(), 'resources'); - } else { - return path.join(process.cwd(), '../../../resources'); - } - } + return path.join(process.env.DIR, 'resources'); }; Util.getResourceDir = function () { @@ -97,22 +90,16 @@ Util.openTerminal = function (command) { Util.downloadFile = function (url, filename, checksum, callback, progressCallback) { var doDownload = function () { - var percent = 0; - var interval = setInterval(function () { - progressCallback(percent); - }, 250); - var download = wget.download(url, filename); - download.on('error', function (err) { - console.log(err); - clearInterval(interval); - }); - download.on('end', function (output) { - console.log(output); - callback(); - clearInterval(interval); - }); - download.on('progress', function (progress) { - percent = Math.round(progress * 100.0); + progress(request(url), { + throttle: 250, + }).on('progress', function (state) { + progressCallback(state.percent); + }).on('error', function (err) { + callback(err); + }).pipe(fs.createWriteStream(filename)).on('error', function (err) { + callback(err); + }).on('close', function (err) { + callback(err); }); }; diff --git a/meteor/client/lib/virtualbox.js b/meteor/client/lib/virtualbox.js index ee172fb1bb..de70fe6c74 100644 --- a/meteor/client/lib/virtualbox.js +++ b/meteor/client/lib/virtualbox.js @@ -1,7 +1,6 @@ var fs = require('fs'); var exec = require('exec'); var path = require('path'); -var crypto = require('crypto'); VirtualBox = {}; diff --git a/meteor/client/stylesheets/setup.import.less b/meteor/client/stylesheets/setup.import.less index 232640052e..a520c3a160 100644 --- a/meteor/client/stylesheets/setup.import.less +++ b/meteor/client/stylesheets/setup.import.less @@ -40,6 +40,25 @@ margin-top: 60px; } + .install-finish { + -webkit-app-region: no-drag; + margin-top: 80px; + p { + margin-top: 0; + font-size: 13px; + } + } + + .install-diagonistics { + -webkit-app-region: no-drag; + label { + text-align: left; + } + margin: 0 auto; + max-width: 300px; + margin-top: 50px; + } + .install-continue { -webkit-app-region: no-drag; margin-top: 140px; diff --git a/meteor/client/views/dashboard/layouts/dashboard-apps-layout.js b/meteor/client/views/dashboard/layouts/dashboard-apps-layout.js index 46d5cfb567..8cb8e72c8a 100644 --- a/meteor/client/views/dashboard/layouts/dashboard-apps-layout.js +++ b/meteor/client/views/dashboard/layouts/dashboard-apps-layout.js @@ -1,5 +1,3 @@ -var path = require('path'); - Template.dashboard_apps_layout.rendered = function () { Meteor.setInterval(function () { $('.header .icons a').tooltip(); @@ -26,7 +24,7 @@ Template.dashboard_apps_layout.events({ AppUtil.logs(this._id); }, 'click .btn-terminal': function () { - var cmd = Boot2Docker.command() + ' ssh -t "sudo docker-enter ' + app.docker.Id + '"'; + var cmd = Boot2Docker.command() + ' ssh -t "sudo docker-enter ' + this.docker.Id + '"'; Util.openTerminal(cmd); }, 'click .btn-restart': function () { diff --git a/meteor/client/views/dashboard/settings/dashboard-settings.html b/meteor/client/views/dashboard/settings/dashboard-settings.html index 9796d42e91..67cc58fb9e 100644 --- a/meteor/client/views/dashboard/settings/dashboard-settings.html +++ b/meteor/client/views/dashboard/settings/dashboard-settings.html @@ -41,14 +41,14 @@
-

Usage Analytics

-

Send usage analytics to help us improve the developer experience. No sensitive data will be tracked. We really appreciate the help.

+

Usage Diagnostics

+

Send anonymized usage diagnostics to help us improve Kitematic.

- {{#if install.tracking}} - Turn Off Usage Analytics + {{#if settings.tracking}} + Turn Off Usage Diagnostics {{else}} - Turn On Usage Analytics + Turn On Usage Diagnostics {{/if}}
diff --git a/meteor/client/views/dashboard/settings/dashboard-settings.js b/meteor/client/views/dashboard/settings/dashboard-settings.js index 2919d189ca..2028f2edd6 100644 --- a/meteor/client/views/dashboard/settings/dashboard-settings.js +++ b/meteor/client/views/dashboard/settings/dashboard-settings.js @@ -22,16 +22,16 @@ Template.dashboard_settings.events({ }); }, 'click .btn-usage-analytics-on': function () { - var install = Installs.findOne({}); - Installs.update(install._id, { + var settings = Settings.findOne(); + Settings.update(settings._id, { $set: { tracking: true } }); }, 'click .btn-usage-analytics-off': function () { - var install = Installs.findOne({}); - Installs.update(install._id, { + var settings = Settings.findOne(); + Settings.update(settings._id, { $set: { tracking: false } @@ -40,8 +40,8 @@ Template.dashboard_settings.events({ }); Template.dashboard_settings.helpers({ - install: function () { - return Installs.findOne({}); + settings: function () { + return Settings.findOne({}); } }); diff --git a/meteor/client/views/dashboard/setup/setup-finish.html b/meteor/client/views/dashboard/setup/setup-finish.html new file mode 100644 index 0000000000..de5f103ff0 --- /dev/null +++ b/meteor/client/views/dashboard/setup/setup-finish.html @@ -0,0 +1,21 @@ + diff --git a/meteor/client/views/dashboard/setup/setup-finish.js b/meteor/client/views/dashboard/setup/setup-finish.js new file mode 100644 index 0000000000..7f4a53c81e --- /dev/null +++ b/meteor/client/views/dashboard/setup/setup-finish.js @@ -0,0 +1,20 @@ +Template.setup_finish.events({ + 'click .finish-button': function (e) { + var enableDiagnostics = $('.install-diagonistics input').attr('checked') ? true : false; + Installs.insert({version: Installer.CURRENT_VERSION}); + var settings = Settings.findOne(); + if (!settings) { + Settings.insert({tracking: enableDiagnostics}); + } else { + settings.update(settings._id, { + $set: { + tracking: true + } + }); + } + Router.go('dashboard_apps'); + e.preventDefault(); + e.stopPropagation(); + return false; + } +}); diff --git a/meteor/client/views/dashboard/setup/setup-install.html b/meteor/client/views/dashboard/setup/setup-install.html index bb76f77e74..9f16050b26 100644 --- a/meteor/client/views/dashboard/setup/setup-install.html +++ b/meteor/client/views/dashboard/setup/setup-install.html @@ -1,4 +1,11 @@