mirror of https://github.com/docker/docs.git
Fixing remaining installer bugs
This commit is contained in:
parent
f5b784491c
commit
c370a4cf89
|
@ -81,6 +81,7 @@ Boot2Docker.start = function (callback) {
|
|||
// Success as well
|
||||
if (!err || (err.indexOf('Waiting for VM to be started') !== -1 || err.indexOf('..........') !== -1)) {
|
||||
self.correct(function (err) {
|
||||
if (err) { callback(err); return; }
|
||||
self.injectUtilities(function (err) {
|
||||
callback(err);
|
||||
});
|
||||
|
@ -96,17 +97,14 @@ Boot2Docker.correct = function (callback) {
|
|||
Boot2Docker.setIp('eth2', Boot2Docker.REQUIRED_IP, function(err) {
|
||||
if (err) { callback(err); return; }
|
||||
VirtualBox.removeDHCP(function (err) {
|
||||
callback(err);
|
||||
callback();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Boot2Docker.state = function (callback) {
|
||||
this.exec('info', function (err, stdout) {
|
||||
if (err) {
|
||||
callback(err, null);
|
||||
return;
|
||||
}
|
||||
this.exec('info', function (err, stdout, stderr) {
|
||||
if (err) { callback(err, null); return; }
|
||||
try {
|
||||
var info = JSON.parse(stdout);
|
||||
callback(null, info.State);
|
||||
|
@ -177,23 +175,21 @@ Boot2Docker.memoryUsage = function (callback) {
|
|||
};
|
||||
|
||||
Boot2Docker.stats = function (callback) {
|
||||
this.state(function (err, state) {
|
||||
if (err) {
|
||||
callback(err, null);
|
||||
return;
|
||||
}
|
||||
var self = this;
|
||||
self.state(function (err, state) {
|
||||
if (err) { callback(err, null); return; }
|
||||
if (state === 'poweroff') {
|
||||
callback(null, {state: state});
|
||||
return;
|
||||
}
|
||||
this.memoryUsage(function (err, mem) {
|
||||
self.memoryUsage(function (err, mem) {
|
||||
if (err) {
|
||||
callback(null, {state: state});
|
||||
return;
|
||||
}
|
||||
this.diskUsage(function (err, disk) {
|
||||
self.diskUsage(function (err, disk) {
|
||||
if (err) {
|
||||
callback(null, {state: state});
|
||||
callback(null, {state: state, memory: mem});
|
||||
return;
|
||||
}
|
||||
callback(null, {
|
||||
|
|
|
@ -24,7 +24,7 @@ Installer.steps = [
|
|||
callback(err);
|
||||
return;
|
||||
}
|
||||
var needsUpdate = Utilities.compareVersions(installedVersion, VirtualBox.REQUIRED_VERSION) < 0;
|
||||
var needsUpdate = Util.compareVersions(installedVersion, VirtualBox.REQUIRED_VERSION) < 0;
|
||||
if (needsUpdate) {
|
||||
VirtualBox.install(function (err) {
|
||||
callback(err);
|
||||
|
@ -44,16 +44,14 @@ Installer.steps = [
|
|||
{
|
||||
run: function (callback) {
|
||||
Boot2Docker.exists(function (err, exists) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
if (err) { callback(err); return; }
|
||||
if (!exists) {
|
||||
Boot2Docker.init(function (err) {
|
||||
callback(err);
|
||||
});
|
||||
} else {
|
||||
Boot2Docker.stop(function (err) {
|
||||
if (err) { callback(err); return; }
|
||||
Boot2Docker.upgrade(function (err) {
|
||||
callback(err);
|
||||
});
|
||||
|
@ -66,24 +64,24 @@ Installer.steps = [
|
|||
futureMessage: 'Set up the Boot2Docker VM(if required)'
|
||||
},
|
||||
|
||||
// Set up the routing.
|
||||
{
|
||||
run: function (callback) {
|
||||
VirtualBox.setupRouting('boot2docker-vm', function (err, ifname) {
|
||||
VirtualBox.addCustomHostAdapter('boot2docker-vm', function (err, ifname) {
|
||||
callback(err);
|
||||
});
|
||||
},
|
||||
pastMessage: 'Container routing set up.',
|
||||
message: 'Setting up container routing (root required).',
|
||||
subMessage: '(This may take a few minutes)',
|
||||
futureMessage: 'Set up container routing to VM (root required).'
|
||||
pastMessage: 'Added custom host adapter to the Boot2Docker VM',
|
||||
message: 'Adding custom host adapter to the Boot2Docker VM',
|
||||
futureMessage: 'Add custom host adapter to the Boot2Docker VM'
|
||||
},
|
||||
|
||||
// Start the Kitematic VM
|
||||
{
|
||||
run: function (callback) {
|
||||
Boot2Docker.state(function (err, state) {
|
||||
if (err) { callback(err); return; }
|
||||
if (state !== 'running') {
|
||||
console.log('starting');
|
||||
Boot2Docker.start(function (err) {
|
||||
callback(err);
|
||||
});
|
||||
|
@ -96,10 +94,20 @@ Installer.steps = [
|
|||
},
|
||||
pastMessage: 'Started the Boot2Docker VM',
|
||||
message: 'Starting the Boot2Docker VM',
|
||||
subMessage: '(This may take a few minutes)',
|
||||
futureMessage: 'Start the Kitematic VM',
|
||||
},
|
||||
|
||||
{
|
||||
run: function (callback) {
|
||||
VirtualBox.setupRouting('boot2docker-vm', function (err, ifname) {
|
||||
callback(err);
|
||||
});
|
||||
},
|
||||
pastMessage: 'Container routing set up',
|
||||
message: 'Setting up container routing (root required)',
|
||||
futureMessage: 'Set up container routing to VM (root required)'
|
||||
},
|
||||
|
||||
// Set up the default Kitematic images
|
||||
{
|
||||
run: function (callback) {
|
||||
|
|
|
@ -106,16 +106,12 @@ VirtualBox.hostOnlyAdapter = function (callback) {
|
|||
if (!iface) {
|
||||
self.exec('hostonlyif create', function (err, stdout, stderr) {
|
||||
var match = stdout.match(/Interface '(vboxnet\d+)' was successfully created/);
|
||||
console.log(match);
|
||||
if (!match) {
|
||||
callback('Could not parse output of hostonlyif create');
|
||||
return;
|
||||
}
|
||||
self.exec('hostonlyif ipconfig ' + match[1] + ' --ip ' + VirtualBox.HOSTONLY_HOSTIP + ' --netmask ' + VirtualBox.HOSTONLY_NETWORKMASK, function(err, stdout, stderr) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
if (err) { callback(err); return; }
|
||||
callback(null, match[1]);
|
||||
});
|
||||
});
|
||||
|
@ -128,10 +124,7 @@ VirtualBox.hostOnlyAdapter = function (callback) {
|
|||
VirtualBox.addCustomHostAdapter = function (vm, callback) {
|
||||
var self = this;
|
||||
self.hostOnlyAdapter(function (err, ifname) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
if (err) { callback(err); return; }
|
||||
self.exec('modifyvm ' + vm + ' --nic3 hostonly --nictype3 virtio --cableconnected3 on --hostonlyadapter3 ' + ifname, function (err, stdout, stderr) {
|
||||
callback(err, ifname);
|
||||
});
|
||||
|
@ -143,7 +136,7 @@ VirtualBox.setupRouting = function (vm, callback) {
|
|||
this.addCustomHostAdapter(vm, function (err, ifname) {
|
||||
var installFile = path.join(Util.getBinDir(), 'install');
|
||||
var cocoaSudo = path.join(Util.getBinDir(), 'cocoasudo');
|
||||
var execCommand = cocoaSudo + ' --prompt="Kitematic needs your password to allow routing *.dev requests to containers." ' + installFile;
|
||||
var execCommand = cocoaSudo + ' --prompt="Kitematic needs your password to allow routing *.kite requests to containers." ' + installFile;
|
||||
exec(execCommand, {env: {IFNAME: ifname, GATEWAY: Boot2Docker.REQUIRED_IP}}, function (error, stdout, stderr) {
|
||||
if (error) {
|
||||
callback(error);
|
||||
|
|
|
@ -126,17 +126,17 @@ fixDefaultContainers = function (callback) {
|
|||
|
||||
Meteor.setInterval(function () {
|
||||
Boot2Docker.exists(function (err, exists) {
|
||||
if (err) { return; }
|
||||
if (err) { console.log(err); return; }
|
||||
if (exists) {
|
||||
Boot2Docker.state(function (err, state) {
|
||||
if (err) { return; }
|
||||
if (err) { console.log(err); return; }
|
||||
Session.set('boot2dockerState', state);
|
||||
if (state === 'running') {
|
||||
Boot2Docker.info(function (err, info) {
|
||||
if (err) { return; }
|
||||
Session.set('boot2dockerState', info.state);
|
||||
if (info.state !== 'poweroff' && info.memory && info.disk) {
|
||||
Session.set('boot2dockerMemoryUsage', info.memory);
|
||||
Session.set('boot2dockerDiskUsage', info.disk);
|
||||
Boot2Docker.stats(function (err, stats) {
|
||||
if (err) { console.log(err); return; }
|
||||
if (stats.state !== 'poweroff' && stats.memory && stats.disk) {
|
||||
Session.set('boot2dockerMemoryUsage', stats.memory);
|
||||
Session.set('boot2dockerDiskUsage', stats.disk);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -148,16 +148,18 @@ Meteor.setInterval(function () {
|
|||
Meteor.setInterval(function () {
|
||||
if (Installs.findOne()) {
|
||||
resolveWatchers(function () {});
|
||||
fixBoot2DockerVM(function (err) {
|
||||
if (err) { console.log(err); return; }
|
||||
Meteor.call('recoverApps');
|
||||
fixDefaultImages(function (err) {
|
||||
if (!Session.get('boot2dockerOff')) {
|
||||
fixBoot2DockerVM(function (err) {
|
||||
if (err) { console.log(err); return; }
|
||||
fixDefaultContainers(function (err) {
|
||||
if (err) { console.log(err); }
|
||||
Meteor.call('recoverApps');
|
||||
fixDefaultImages(function (err) {
|
||||
if (err) { console.log(err); return; }
|
||||
fixDefaultContainers(function (err) {
|
||||
if (err) { console.log(err); }
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}, 5000);
|
||||
|
||||
|
|
|
@ -3,18 +3,22 @@ Template.dashboard_settings.events({
|
|||
var $btn = $(e.currentTarget);
|
||||
$btn.html('Starting Boot2Docker...');
|
||||
$btn.attr("disabled", "disabled");
|
||||
//startFixInterval();
|
||||
startBoot2Docker(function (err) {
|
||||
if (err) { console.error(err); }
|
||||
Session.set('boot2dockerOff', false);
|
||||
Boot2Docker.start(function (err) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
},
|
||||
'click .btn-stop-boot2docker': function (e) {
|
||||
var $btn = $(e.currentTarget);
|
||||
$btn.html('Stopping Boot2Docker...');
|
||||
$btn.attr("disabled", "disabled");
|
||||
stopFixInterval();
|
||||
stopBoot2Docker(function (err) {
|
||||
if (err) { console.error(err); }
|
||||
Session.set('boot2dockerOff', true);
|
||||
Boot2Docker.stop(function (err) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#!/bin/sh
|
||||
|
||||
# This script must be run as root and sets up Mac OS X to route all .dev domains to the virtual box VM with the name
|
||||
# This script must be run as root and sets up Mac OS X to route all .kite domains to the virtual box VM with the name
|
||||
# 'boot2docker-vm'. It does the following:
|
||||
# 1) Adds a file under /etc/resolver/dev
|
||||
# 1) Adds a file under /etc/resolver/kite
|
||||
# 2) Sets up a LaunchAgent for adding entries to the route table to route all requests to the Docker subnet (172.17.0.0/16)
|
||||
# And expects the $IFNAME variable to contain the interface on which to send traffic to the boot2docker VM.
|
||||
|
||||
mkdir -p /etc/resolver
|
||||
echo "nameserver 172.17.42.1" > /etc/resolver/dev
|
||||
echo "nameserver 172.17.42.1" > /etc/resolver/kite
|
||||
|
||||
DIR=$(dirname "$0")
|
||||
USER=`w -h | sort -u -t' ' -k1,1 | awk '{print $1}'`
|
||||
|
|
Loading…
Reference in New Issue