mirror of https://github.com/docker/docs.git
pruning some relevant changes
This commit is contained in:
parent
e6ec43f11b
commit
6933a158ee
21
appveyor.yml
21
appveyor.yml
|
@ -1,21 +0,0 @@
|
||||||
# Test against this version of Node.js
|
|
||||||
environment:
|
|
||||||
nodejs_version: "0.10"
|
|
||||||
|
|
||||||
# Install scripts. (runs after repo cloning)
|
|
||||||
install:
|
|
||||||
# Get the latest stable version of Node.js or io.js
|
|
||||||
- ps: Install-Product node $env:nodejs_version
|
|
||||||
# Updating NPM to avoid permission issues: http://www.appveyor.com/docs/lang/nodejs-iojs#locking-errors-eperm-eexist-tgz-lock
|
|
||||||
- npm -g install npm@2
|
|
||||||
- set PATH=%APPDATA%\npm;%PATH%
|
|
||||||
# install modules
|
|
||||||
- npm install
|
|
||||||
|
|
||||||
# Post-install test scripts.
|
|
||||||
test_script:
|
|
||||||
# Output useful info for debugging.
|
|
||||||
- node --version
|
|
||||||
- npm --version
|
|
||||||
# run tests
|
|
||||||
- npm test
|
|
|
@ -10,6 +10,7 @@ var machine = require('../utils/DockerMachineUtil');
|
||||||
var RetinaImage = require('react-retina-image');
|
var RetinaImage = require('react-retina-image');
|
||||||
var webPorts = require('../utils/Util').webPorts;
|
var webPorts = require('../utils/Util').webPorts;
|
||||||
var classNames = require('classnames');
|
var classNames = require('classnames');
|
||||||
|
var resources = require('../utils/ResourcesUtil');
|
||||||
|
|
||||||
var ContainerDetailsSubheader = React.createClass({
|
var ContainerDetailsSubheader = React.createClass({
|
||||||
contextTypes: {
|
contextTypes: {
|
||||||
|
|
|
@ -6,14 +6,9 @@ var Radial = require('./Radial.react');
|
||||||
var ContainerHomePreview = require('./ContainerHomePreview.react');
|
var ContainerHomePreview = require('./ContainerHomePreview.react');
|
||||||
var ContainerHomeLogs = require('./ContainerHomeLogs.react');
|
var ContainerHomeLogs = require('./ContainerHomeLogs.react');
|
||||||
var ContainerHomeFolders = require('./ContainerHomeFolders.react');
|
var ContainerHomeFolders = require('./ContainerHomeFolders.react');
|
||||||
<<<<<<< HEAD:src/ContainerHome.react.js
|
|
||||||
var ContainerUtil = require('./ContainerUtil');
|
|
||||||
var util = require('./Util');
|
|
||||||
var shell = require('shell');
|
var shell = require('shell');
|
||||||
=======
|
|
||||||
var ContainerUtil = require('../utils/ContainerUtil');
|
var ContainerUtil = require('../utils/ContainerUtil');
|
||||||
var util = require('../utils/Util');
|
var util = require('../utils/Util');
|
||||||
>>>>>>> master:src/components/ContainerHome.react.js
|
|
||||||
|
|
||||||
var resizeWindow = function () {
|
var resizeWindow = function () {
|
||||||
$('.left .wrapper').height(window.innerHeight - 240);
|
$('.left .wrapper').height(window.innerHeight - 240);
|
||||||
|
|
|
@ -2,9 +2,9 @@ var _ = require('underscore');
|
||||||
var React = require('react/addons');
|
var React = require('react/addons');
|
||||||
var remote = require('remote');
|
var remote = require('remote');
|
||||||
var dialog = remote.require('dialog');
|
var dialog = remote.require('dialog');
|
||||||
|
var shell = require('shell');
|
||||||
var metrics = require('../utils/MetricsUtil');
|
var metrics = require('../utils/MetricsUtil');
|
||||||
var ContainerStore = require('../stores/ContainerStore');
|
var ContainerStore = require('../stores/ContainerStore');
|
||||||
var util = require('../utils/Util');
|
|
||||||
|
|
||||||
var ContainerSettingsVolumes = React.createClass({
|
var ContainerSettingsVolumes = React.createClass({
|
||||||
handleChooseVolumeClick: function (dockerVol) {
|
handleChooseVolumeClick: function (dockerVol) {
|
||||||
|
@ -48,7 +48,7 @@ var ContainerSettingsVolumes = React.createClass({
|
||||||
metrics.track('Opened Volume Directory', {
|
metrics.track('Opened Volume Directory', {
|
||||||
from: 'settings'
|
from: 'settings'
|
||||||
});
|
});
|
||||||
util.showItemInFolder(path);
|
shell.showItemInFolder(path);
|
||||||
},
|
},
|
||||||
render: function () {
|
render: function () {
|
||||||
if (!this.props.container) {
|
if (!this.props.container) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ describe('SetupStore', function () {
|
||||||
pit('downloads virtualbox if it is not installed', function () {
|
pit('downloads virtualbox if it is not installed', function () {
|
||||||
virtualBox.installed.mockReturnValue(false);
|
virtualBox.installed.mockReturnValue(false);
|
||||||
setupUtil.download.mockReturnValue(Promise.resolve());
|
setupUtil.download.mockReturnValue(Promise.resolve());
|
||||||
setupUtil.virtualBoxFileName.mockReturnValue('');
|
virtualBox.filename.mockReturnValue('');
|
||||||
util.supportDir.mockReturnValue('');
|
util.supportDir.mockReturnValue('');
|
||||||
return setupStore.steps().download.run().then(() => {
|
return setupStore.steps().download.run().then(() => {
|
||||||
expect(setupUtil.download).toBeCalled();
|
expect(setupUtil.download).toBeCalled();
|
||||||
|
@ -23,7 +23,7 @@ describe('SetupStore', function () {
|
||||||
virtualBox.version.mockReturnValue(Promise.resolve('4.3.16'));
|
virtualBox.version.mockReturnValue(Promise.resolve('4.3.16'));
|
||||||
util.compareVersions.mockReturnValue(-1);
|
util.compareVersions.mockReturnValue(-1);
|
||||||
setupUtil.download.mockReturnValue(Promise.resolve());
|
setupUtil.download.mockReturnValue(Promise.resolve());
|
||||||
setupUtil.virtualBoxFileName.mockReturnValue('');
|
virtualBox.filename.mockReturnValue('');
|
||||||
util.supportDir.mockReturnValue('');
|
util.supportDir.mockReturnValue('');
|
||||||
return setupStore.steps().download.run().then(() => {
|
return setupStore.steps().download.run().then(() => {
|
||||||
expect(setupUtil.download).toBeCalled();
|
expect(setupUtil.download).toBeCalled();
|
||||||
|
@ -33,7 +33,6 @@ describe('SetupStore', function () {
|
||||||
|
|
||||||
describe('install step', function () {
|
describe('install step', function () {
|
||||||
util.exec.mockReturnValue(Promise.resolve());
|
util.exec.mockReturnValue(Promise.resolve());
|
||||||
util.execProper.mockReturnValue(Promise.resolve());
|
|
||||||
setupUtil.copyBinariesCmd.mockReturnValue(Promise.resolve());
|
setupUtil.copyBinariesCmd.mockReturnValue(Promise.resolve());
|
||||||
setupUtil.fixBinariesCmd.mockReturnValue(Promise.resolve());
|
setupUtil.fixBinariesCmd.mockReturnValue(Promise.resolve());
|
||||||
virtualBox.killall.mockReturnValue(Promise.resolve());
|
virtualBox.killall.mockReturnValue(Promise.resolve());
|
||||||
|
@ -64,8 +63,6 @@ describe('SetupStore', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('init step', function () {
|
describe('init step', function () {
|
||||||
virtualBox.vmdestroy.mockReturnValue(Promise.resolve());
|
|
||||||
|
|
||||||
pit('upgrades the vm if it exists and is out of date', function () {
|
pit('upgrades the vm if it exists and is out of date', function () {
|
||||||
machine.exists.mockReturnValue(Promise.resolve(true));
|
machine.exists.mockReturnValue(Promise.resolve(true));
|
||||||
machine.state.mockReturnValue(Promise.resolve('Stopped'));
|
machine.state.mockReturnValue(Promise.resolve('Stopped'));
|
||||||
|
|
|
@ -25,7 +25,7 @@ var _steps = [{
|
||||||
totalPercent: 35,
|
totalPercent: 35,
|
||||||
percent: 0,
|
percent: 0,
|
||||||
run: function (progressCallback) {
|
run: function (progressCallback) {
|
||||||
return setupUtil.download(setupUtil.virtualBoxUrl(), path.join(util.supportDir(), setupUtil.virtualBoxFileName()), setupUtil.virtualBoxChecksum(), percent => {
|
return setupUtil.download(virtualBox.url(), path.join(util.supportDir(), virtualBox.filename()), virtualBox.checksum(), percent => {
|
||||||
progressCallback(percent);
|
progressCallback(percent);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -37,20 +37,22 @@ var _steps = [{
|
||||||
percent: 0,
|
percent: 0,
|
||||||
seconds: 5,
|
seconds: 5,
|
||||||
run: Promise.coroutine(function* (progressCallback) {
|
run: Promise.coroutine(function* (progressCallback) {
|
||||||
yield setupUtil.copyBinariesCmd();
|
var cmd = '';
|
||||||
yield setupUtil.fixBinariesCmd();
|
|
||||||
|
|
||||||
if (!virtualBox.installed()) {
|
if (!virtualBox.installed()) {
|
||||||
yield virtualBox.killall();
|
yield virtualBox.killall();
|
||||||
|
cmd += ' && ' + setupUtil.installVirtualBoxCmd();
|
||||||
|
} else {
|
||||||
|
if (!setupUtil.needsBinaryFix()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
progressCallback(50); // TODO: detect when the installation has started so we can simulate progress
|
progressCallback(50); // TODO: detect when the installation has started so we can simulate progress
|
||||||
yield setupUtil.installVirtualBoxCmd();
|
yield setupUtil.installVirtualBoxCmd();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw null;
|
throw null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
})
|
})
|
||||||
}, {
|
}, {
|
||||||
name: 'init',
|
name: 'init',
|
||||||
|
@ -70,23 +72,7 @@ var _steps = [{
|
||||||
let parts = home.split('\\').slice(0, -1);
|
let parts = home.split('\\').slice(0, -1);
|
||||||
let usersDirName = parts[parts.length-1];
|
let usersDirName = parts[parts.length-1];
|
||||||
let usersDirPath = parts.join('\\');
|
let usersDirPath = parts.join('\\');
|
||||||
let shareName = driveLetter + "/" + usersDirName;
|
let shareName = driveLetter + '/' + usersDirName;
|
||||||
|
|
||||||
yield machine.stop();
|
|
||||||
yield virtualBox.mountSharedDir(machine.name(), shareName, usersDirPath);
|
|
||||||
yield machine.start();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
} else if ((yield machine.state()) === 'Error') {
|
|
||||||
yield machine.rm();
|
|
||||||
yield machine.create();
|
|
||||||
if(util.isWindows()) {
|
|
||||||
let home = util.home();
|
|
||||||
let driveLetter = home.charAt(0);
|
|
||||||
let parts = home.split('\\').slice(0, -1);
|
|
||||||
let usersDirName = parts[parts.length-1];
|
|
||||||
let usersDirPath = parts.join('\\');
|
|
||||||
let shareName = driveLetter + "/" + usersDirName;
|
|
||||||
|
|
||||||
yield machine.stop();
|
yield machine.stop();
|
||||||
yield virtualBox.mountSharedDir(machine.name(), shareName, usersDirPath);
|
yield virtualBox.mountSharedDir(machine.name(), shareName, usersDirPath);
|
||||||
|
@ -169,10 +155,10 @@ var SetupStore = assign(Object.create(EventEmitter.prototype), {
|
||||||
var packagejson = util.packagejson();
|
var packagejson = util.packagejson();
|
||||||
var isoversion = machine.isoversion();
|
var isoversion = machine.isoversion();
|
||||||
var required = {};
|
var required = {};
|
||||||
var vboxfile = path.join(util.supportDir(), setupUtil.virtualBoxFileName());
|
var vboxfile = path.join(util.supportDir(), virtualBox.filename());
|
||||||
var vboxNeedsInstall = !virtualBox.installed();
|
var vboxNeedsInstall = !virtualBox.installed();
|
||||||
|
|
||||||
required.download = vboxNeedsInstall && (!fs.existsSync(vboxfile) || setupUtil.checksum(vboxfile) !== setupUtil.virtualBoxChecksum());
|
required.download = vboxNeedsInstall && (!fs.existsSync(vboxfile) || setupUtil.checksum(vboxfile) !== virtualBox.checksum());
|
||||||
required.install = vboxNeedsInstall || setupUtil.needsBinaryFix();
|
required.install = vboxNeedsInstall || setupUtil.needsBinaryFix();
|
||||||
required.init = required.install || !(yield machine.exists()) || (yield machine.state()) !== 'Running' || !isoversion || util.compareVersions(isoversion, packagejson['docker-version']) < 0;
|
required.init = required.install || !(yield machine.exists()) || (yield machine.state()) !== 'Running' || !isoversion || util.compareVersions(isoversion, packagejson['docker-version']) < 0;
|
||||||
|
|
||||||
|
@ -257,8 +243,6 @@ var SetupStore = assign(Object.create(EventEmitter.prototype), {
|
||||||
metrics.track('Setup Failed', {
|
metrics.track('Setup Failed', {
|
||||||
step: _currentStep,
|
step: _currentStep,
|
||||||
});
|
});
|
||||||
console.log(err);
|
|
||||||
console.log(err.stack);
|
|
||||||
bugsnag.notify('SetupError', err.message, {
|
bugsnag.notify('SetupError', err.message, {
|
||||||
error: err,
|
error: err,
|
||||||
output: err.message
|
output: err.message
|
||||||
|
|
|
@ -9,7 +9,7 @@ var NAME = 'dev';
|
||||||
|
|
||||||
var DockerMachine = {
|
var DockerMachine = {
|
||||||
command: function () {
|
command: function () {
|
||||||
return resources.docker_machine();
|
return resources.dockerMachine();
|
||||||
},
|
},
|
||||||
name: function () {
|
name: function () {
|
||||||
return NAME;
|
return NAME;
|
||||||
|
|
|
@ -1,16 +1,19 @@
|
||||||
var _ = require('underscore');
|
var _ = require('underscore');
|
||||||
var crypto = require('crypto');
|
var crypto = require('crypto');
|
||||||
var fs = require('fs-promise');
|
var fs = require('fs');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var request = require('request');
|
var request = require('request');
|
||||||
var progress = require('request-progress');
|
var progress = require('request-progress');
|
||||||
var Promise = require('bluebird');
|
var Promise = require('bluebird');
|
||||||
var util = require('./Util');
|
var util = require('./Util');
|
||||||
var resources = require('./ResourcesUtil');
|
var resources = require('./ResourcesUtil');
|
||||||
|
var virtualBox = require ('./VirtualBoxUtil');
|
||||||
|
|
||||||
var SetupUtil = {
|
var SetupUtil = {
|
||||||
needsBinaryFix() {
|
needsBinaryFix() {
|
||||||
return !!(util.pathDoesNotExistOrDenied(util.binsPath()) || util.pathDoesNotExistOrDenied(util.dockerBinPath()) || util.pathDoesNotExistOrDenied(util.dockerMachineBinPath()));
|
return this.pathDoesNotExistOrDenied(util.binsPath()) ||
|
||||||
|
this.pathDoesNotExistOrDenied(util.dockerBinPath()) ||
|
||||||
|
this.pathDoesNotExistOrDenied(util.dockerMachineBinPath());
|
||||||
},
|
},
|
||||||
pathDoesNotExistOrDenied: function (path) {
|
pathDoesNotExistOrDenied: function (path) {
|
||||||
if(util.isWindows()) {
|
if(util.isWindows()) {
|
||||||
|
@ -19,49 +22,38 @@ var SetupUtil = {
|
||||||
return (!fs.existsSync(path) || fs.statSync(path).gid !== 80 || fs.statSync(path).uid !== process.getuid());
|
return (!fs.existsSync(path) || fs.statSync(path).gid !== 80 || fs.statSync(path).uid !== process.getuid());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
escapePath(str) {
|
shouldUpdateBinaries: function () {
|
||||||
return str.replace(/ /g, '\\ ').replace(/\(/g, '\\(').replace(/\)/g, '\\)');
|
|
||||||
},
|
|
||||||
shouldUpdateBinaries() {
|
|
||||||
return !fs.existsSync(util.dockerBinPath()) ||
|
return !fs.existsSync(util.dockerBinPath()) ||
|
||||||
!fs.existsSync(util.dockerMachineBinPath()) ||
|
!fs.existsSync(util.dockerMachineBinPath()) ||
|
||||||
this.checksum(util.dockerMachineBinPath()) !== this.checksum(resources.dockerMachine()) ||
|
this.checksum(util.dockerMachineBinPath()) !== this.checksum(resources.dockerMachine()) ||
|
||||||
this.checksum(util.dockerBinPath()) !== this.checksum(resources.docker());
|
this.checksum(util.dockerBinPath()) !== this.checksum(resources.docker());
|
||||||
|
|
||||||
},
|
},
|
||||||
copyBinariesCmd: Promise.coroutine(function* () {
|
copyBinariesCmd: function () {
|
||||||
yield fs.mkdirs(util.binsPath());
|
var cmd = ['mkdir', '-p', '/usr/local/bin'];
|
||||||
yield fs.copy(resources.dockerMachine(), util.dockerMachineBinPath());
|
cmd.push('&&');
|
||||||
yield fs.copy(resources.docker(), util.dockerBinPath());
|
cmd.push.apply(cmd, this.copycmd(util.escapePath(resources.dockerMachine()), '/usr/local/bin/docker-machine'));
|
||||||
}),
|
cmd.push('&&');
|
||||||
fixBinariesCmd: Promise.coroutine(function* () {
|
cmd.push.apply(cmd, this.copycmd(util.escapePath(resources.docker()), '/usr/local/bin/docker'));
|
||||||
|
return cmd.join(' ');
|
||||||
|
},
|
||||||
|
fixBinariesCmd: function () {
|
||||||
|
var cmd = [];
|
||||||
|
cmd.push.apply(cmd, ['chown', `${process.getuid()}:${80}`, path.join('/usr/local/bin')]);
|
||||||
|
cmd.push('&&');
|
||||||
|
cmd.push.apply(cmd, ['chown', `${process.getuid()}:${80}`, path.join('/usr/local/bin', 'docker-machine')]);
|
||||||
|
cmd.push('&&');
|
||||||
|
cmd.push.apply(cmd, ['chown', `${process.getuid()}:${80}`, path.join('/usr/local/bin', 'docker')]);
|
||||||
|
return cmd.join(' ');
|
||||||
|
},
|
||||||
|
installVirtualBoxCmd: function () {
|
||||||
if(util.isWindows()) {
|
if(util.isWindows()) {
|
||||||
return;
|
return `powershell.exe -ExecutionPolicy unrestricted -Command "Start-Process \\\"${path.join(util.supportDir(), virtualBox.filename())}\\\" -ArgumentList \\\"--silent --msiparams REBOOT=ReallySuppress\\\" -Verb runAs -Wait"`;
|
||||||
}
|
|
||||||
|
|
||||||
yield fs.chown(util.binsPath(), process.getuid(), 80);
|
|
||||||
yield fs.chown(util.dockerBinPath(), process.getuid(), 80);
|
|
||||||
yield fs.chown(util.dockerMachineBinPath(), process.getuid(), 80);
|
|
||||||
return Promise.resolve();
|
|
||||||
}),
|
|
||||||
installVirtualBoxCmd: Promise.coroutine(function* () {
|
|
||||||
if(util.isWindows()) {
|
|
||||||
yield util.execProper(`powershell.exe -ExecutionPolicy unrestricted -Command "Start-Process \\\"${path.join(util.supportDir(), this.virtualBoxFileName())}\\\" -ArgumentList \\\"--silent --msiparams REBOOT=ReallySuppress\\\" -Verb runAs -Wait"`);
|
|
||||||
} else {
|
} else {
|
||||||
yield util.exec(this.macSudoCmd(`installer -pkg ${this.escapePath(path.join(util.supportDir(), this.virtualBoxFileName()))} -target /`));
|
return `installer -pkg ${util.escapePath(path.join(util.supportDir(), virtualBox.filename()))} -target /`;
|
||||||
}
|
|
||||||
|
|
||||||
return Promise.resolve();
|
|
||||||
}),
|
|
||||||
virtualBoxUrl() {
|
|
||||||
if(util.isWindows()) {
|
|
||||||
return 'http://download.virtualbox.org/virtualbox/4.3.26/VirtualBox-4.3.26-98988-Win.exe';
|
|
||||||
} else {
|
|
||||||
return `https://github.com/kitematic/virtualbox/releases/download/${util.packagejson()['virtualbox-version']}/${this.virtualBoxFileName()}`;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
macSudoCmd(cmd) {
|
macSudoCmd(cmd) {
|
||||||
return `${this.escapePath(resources.macsudo())} -p "Kitematic requires administrative privileges to install." sh -c \"${cmd}\"`;
|
return `${util.escapePath(resources.macsudo())} -p "Kitematic requires administrative privileges to install." sh -c \"${cmd}\"`;
|
||||||
},
|
},
|
||||||
simulateProgress(estimateSeconds, progress) {
|
simulateProgress(estimateSeconds, progress) {
|
||||||
var times = _.range(0, estimateSeconds * 1000, 200);
|
var times = _.range(0, estimateSeconds * 1000, 200);
|
||||||
|
@ -103,12 +95,6 @@ var SetupUtil = {
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
|
||||||
virtualBoxFileName() {
|
|
||||||
return util.isWindows() ? util.packagejson()['virtualbox-filename-win'] : util.packagejson()['virtualbox-filename'];
|
|
||||||
},
|
|
||||||
virtualBoxChecksum() {
|
|
||||||
return util.isWindows() ? util.packagejson()['virtualbox-checksum-win'] : util.packagejson()['virtualbox-checksum'];
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
var exec = require('exec');
|
var exec = require('exec');
|
||||||
var Promise = require('bluebird');
|
var Promise = require('bluebird');
|
||||||
var fs = require('fs');
|
var fs = require('fs-promise');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
exec: function (args, options) {
|
exec: function (args, options) {
|
||||||
|
if (typeof args === 'string') {
|
||||||
|
args = args.split(' ');
|
||||||
|
}
|
||||||
options = options || {};
|
options = options || {};
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
exec(args, options, (stderr, stdout, code) => {
|
exec(args, options, (stderr, stdout, code) => {
|
||||||
|
@ -20,18 +23,6 @@ module.exports = {
|
||||||
isWindows: function () {
|
isWindows: function () {
|
||||||
return process.platform === 'win32';
|
return process.platform === 'win32';
|
||||||
},
|
},
|
||||||
home: function () {
|
|
||||||
return process.env[this.isWindows() ? 'USERPROFILE' : 'HOME'];
|
|
||||||
},
|
|
||||||
supportDir: function () {
|
|
||||||
var acc = path.join(this.home(), 'Library', 'Application\ Support', 'Kitematic');
|
|
||||||
fs.mkdirsSync(acc);
|
|
||||||
return acc;
|
|
||||||
},
|
|
||||||
CommandOrCtrl: function () {
|
|
||||||
return this.isWindows() ? 'Ctrl' : 'Command';
|
|
||||||
},
|
|
||||||
|
|
||||||
binsPath: function () {
|
binsPath: function () {
|
||||||
return this.isWindows() ? path.join(this.home(), 'Kitematic-bins') : path.join('/usr/local/bin');
|
return this.isWindows() ? path.join(this.home(), 'Kitematic-bins') : path.join('/usr/local/bin');
|
||||||
},
|
},
|
||||||
|
@ -44,6 +35,20 @@ module.exports = {
|
||||||
dockerMachineBinPath: function () {
|
dockerMachineBinPath: function () {
|
||||||
return path.join(this.binsPath(), 'docker-machine' + this.binsEnding());
|
return path.join(this.binsPath(), 'docker-machine' + this.binsEnding());
|
||||||
},
|
},
|
||||||
|
escapePath: function (str) {
|
||||||
|
return str.replace(/ /g, '\\ ').replace(/\(/g, '\\(').replace(/\)/g, '\\)');
|
||||||
|
},
|
||||||
|
home: function () {
|
||||||
|
return process.env[this.isWindows() ? 'USERPROFILE' : 'HOME'];
|
||||||
|
},
|
||||||
|
supportDir: function () {
|
||||||
|
var acc = path.join(this.home(), 'Library', 'Application\ Support', 'Kitematic');
|
||||||
|
fs.mkdirsSync(acc);
|
||||||
|
return acc;
|
||||||
|
},
|
||||||
|
CommandOrCtrl: function () {
|
||||||
|
return this.isWindows() ? 'Ctrl' : 'Command';
|
||||||
|
},
|
||||||
removeSensitiveData: function (str) {
|
removeSensitiveData: function (str) {
|
||||||
if (!str || str.length === 0 || typeof str !== 'string' ) {
|
if (!str || str.length === 0 || typeof str !== 'string' ) {
|
||||||
return str;
|
return str;
|
||||||
|
|
|
@ -10,6 +10,19 @@ var VirtualBox = {
|
||||||
return '/usr/bin/VBoxManage';
|
return '/usr/bin/VBoxManage';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
filename: function () {
|
||||||
|
return util.isWindows() ? util.packagejson()['virtualbox-filename-win'] : util.packagejson()['virtualbox-filename'];
|
||||||
|
},
|
||||||
|
checksum: function () {
|
||||||
|
return util.isWindows() ? util.packagejson()['virtualbox-checksum-win'] : util.packagejson()['virtualbox-checksum'];
|
||||||
|
},
|
||||||
|
url: function () {
|
||||||
|
if(util.isWindows()) {
|
||||||
|
return 'http://download.virtualbox.org/virtualbox/4.3.26/VirtualBox-4.3.26-98988-Win.exe';
|
||||||
|
} else {
|
||||||
|
return `https://github.com/kitematic/virtualbox/releases/download/${util.packagejson()['virtualbox-version']}/${this.virtualBoxFileName()}`;
|
||||||
|
}
|
||||||
|
},
|
||||||
installed: function () {
|
installed: function () {
|
||||||
if(util.isWindows()) {
|
if(util.isWindows()) {
|
||||||
return fs.existsSync('C:\\Program Files\\Oracle\\VirtualBox\\VBoxManage.exe') && fs.existsSync('C:\\Program Files\\Oracle\\VirtualBox\\VirtualBox.exe');
|
return fs.existsSync('C:\\Program Files\\Oracle\\VirtualBox\\VBoxManage.exe') && fs.existsSync('C:\\Program Files\\Oracle\\VirtualBox\\VirtualBox.exe');
|
||||||
|
@ -45,9 +58,7 @@ var VirtualBox = {
|
||||||
if(util.isWindows()) {
|
if(util.isWindows()) {
|
||||||
return this.poweroffall().then(() => {
|
return this.poweroffall().then(() => {
|
||||||
return util.exec(['powershell.exe', '\"get-process VBox* | stop-process\"']);
|
return util.exec(['powershell.exe', '\"get-process VBox* | stop-process\"']);
|
||||||
}).catch(() => {
|
}).catch(() => {});
|
||||||
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
return this.poweroffall().then(() => {
|
return this.poweroffall().then(() => {
|
||||||
return util.exec(['pkill', 'VirtualBox']);
|
return util.exec(['pkill', 'VirtualBox']);
|
||||||
|
@ -58,9 +69,6 @@ var VirtualBox = {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
wake: function (name) {
|
|
||||||
return util.exec([this.command(), 'startvm', name, '--type', 'headless']);
|
|
||||||
},
|
|
||||||
vmstate: function (name) {
|
vmstate: function (name) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
util.exec([this.command(), 'showvminfo', name, '--machinereadable']).then(stdout => {
|
util.exec([this.command(), 'showvminfo', name, '--machinereadable']).then(stdout => {
|
||||||
|
@ -71,17 +79,6 @@ var VirtualBox = {
|
||||||
resolve(match[1]);
|
resolve(match[1]);
|
||||||
}).catch(reject);
|
}).catch(reject);
|
||||||
});
|
});
|
||||||
},
|
|
||||||
vmdestroy: function (name) {
|
|
||||||
return Promise.coroutine(function* () {
|
|
||||||
try {
|
|
||||||
var state = yield this.vmstate(name);
|
|
||||||
if (state === 'running') {
|
|
||||||
yield util.exec([this.command(), 'controlvm', name, 'poweroff']);
|
|
||||||
}
|
|
||||||
yield util.exec([this.command(), 'unregistervm', name, '--delete']);
|
|
||||||
} catch (err) {}
|
|
||||||
}.bind(this))();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue