fixing installer

This commit is contained in:
Jeff Morgan 2014-08-29 00:59:30 -07:00
parent b0d03ccbd3
commit 548d8f33ba
6 changed files with 64 additions and 37 deletions

View File

@ -1,5 +1,5 @@
var fs = require('fs');
var exec = require('exec');
var child_process = require('child_process');
var path = require('path');
isVirtualBoxInstalled = function (callback) {
@ -24,22 +24,15 @@ isResolverSetup = function (callback) {
});
};
setupVirtualBoxAndResolver = function (skipVirtualBox, callback) {
setupResolver = function (callback) {
var installFile = path.join(getBinDir(), 'install');
var cocoaSudo = path.join(getBinDir(), 'cocoasudo');
var execCommand = cocoaSudo + ' --prompt="Kitematic Setup wants to make changes. Type your password to allow this." ' + installFile;
console.log(execCommand);
var env = {
VIRTUALBOX_PKG_PATH: path.join(getBinDir(), 'virtualbox-4.3.12.pkg')
};
if (!skipVirtualBox) {
env.INSTALL_VIRTUALBOX = true;
}
exec(execCommand, {env: env}, function (err, stdout) {
child_process.exec(execCommand, function (error, stdout, stderr) {
console.log(stdout);
if (err) {
console.log(err);
callback(err);
if (error) {
console.log(error);
callback(error);
return;
}
console.log('Virtualbox Installation & Resolver config complete.');
@ -47,3 +40,16 @@ setupVirtualBoxAndResolver = function (skipVirtualBox, callback) {
});
};
setupVirtualBox = function (callback) {
child_process.exec('open -W ' + path.join(getBinDir(), 'virtualbox-4.3.12.pkg'), function (error, stdout, stderr) {
console.log(stdout);
if (error) {
console.log(error);
callback(error);
return;
}
console.log('Virtualbox Installation running.');
callback();
});
};

View File

@ -21,10 +21,17 @@
{{/if}}
{{#if $eq this.index currentInstallStep}}
<span class="pull-left">
{{> spinner}}
{{#if $eq this.index failedStep}}
<img src="/step_failed.png">
{{else}}
{{> spinner}}
{{/if}}
</span>
<div class="media-body">
{{this.message}}
{{#if $eq this.index failedStep}}
<p>{{failedError}}</p>
{{/if}}
</div>
{{/if}}
</div>

View File

@ -8,13 +8,18 @@ var async = require('async');
// - imperativeMessage: Message to show before running
var steps = [
// Step 0, set up VirtualBox
// Set up VirtualBox
{
install: function (callback) {
isVirtualBoxInstalled(function (err, virtualBoxInstalled) {
setupVirtualBoxAndResolver(virtualBoxInstalled, function () {
var installedYet = false;
if (!virtualBoxInstalled) {
setupVirtualBox(function (err) {
callback(err);
});
} else {
callback();
});
}
});
},
pastMessage: 'VirtualBox installed',
@ -22,7 +27,19 @@ var steps = [
imperativeMessage: 'Install VirtualBox if necessary'
},
// Step 1: Set up the VM for running Kitematic apps
// Set up the routing.
{
install: function (callback) {
setupResolver(function (err) {
callback(err);
});
},
pastMessage: 'Container routing set up (root required).',
message: 'Setting up container routing (root required).',
imperativeMessage: 'Set up container routing to VM (root required).'
},
// Set up the VM for running Kitematic apps
{
install: function (callback) {
console.log('Checking if vm exists...');
@ -49,7 +66,7 @@ var steps = [
imperativeMessage: 'Set up the Kitematic VM'
},
// Step 2: Start the Kitematic VM
// Start the Kitematic VM
{
install: function (callback) {
startBoot2Docker(function (err) {
@ -61,7 +78,7 @@ var steps = [
imperativeMessage: 'Start the Kitematic VM'
},
// Step 3: Set up the default Kitematic images
// Set up the default Kitematic images
{
install: function (callback) {
Meteor.call('reloadDefaultContainers', function (err) {
@ -93,8 +110,10 @@ runSetup = function (callback) {
}, function (err) {
if (err) {
// if any of the steps fail
console.log('Kitematic setup failed at step' + currentStep);
console.log('Kitematic setup failed at step ' + currentStep);
console.log(err);
Session.set('failedStep', currentStep);
Session.set('failedError', err);
callback(err);
} else {
// Setup Finished
@ -121,10 +140,6 @@ Template.setup_install.rendered = function() {
}
};
Template.setup_install.events({
});
Template.setup_install.steps = function () {
return steps.map(function (step, index) {
step.index = index;
@ -135,11 +150,15 @@ Template.setup_install.steps = function () {
Template.setup_install.helpers({
currentInstallStep: function () {
return Session.get('currentInstallStep');
},
installComplete: function () {
return Session.get('currentInstallStep') === steps.length;
},
failedStep: function () {
return Session.get('failedStep');
},
failedError: function () {
return Session.get('failedError');
}
});
Template.setup_install.helpers({
installComplete: function () {
return Session.get('currentInstallStep') === steps.length;
}
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@ -3,10 +3,8 @@
# Lookup the Kitematic VM resolver for .dev domains
echo "nameserver 172.17.42.1" > /etc/resolver/dev
# Install virtualbox
if [ -n "$INSTALL_VIRTUALBOX" ]; then
/usr/sbin/installer -pkg $VIRTUALBOX_PKG_PATH -target /
fi
DIR=$(dirname "$0")
USER=`w -h | sort -u -t' ' -k1,1 | awk '{print $1}'`
/bin/rm -rf /Library/LaunchAgents/com.kitematic.route.plist
@ -37,9 +35,6 @@ echo '<?xml version="1.0" encoding="UTF-8"?>
</dict>
</plist>' > /Library/LaunchAgents/com.kitematic.route.plist
DIR=$(dirname "$0")
USER=`w -h | sort -u -t' ' -k1,1 | awk '{print $1}'`
sudo -u $USER $DIR/boot2docker init --lowerip=192.168.59.103 --upperip=192.168.59.103
# Add entries to routing table for Kitematic VM