Skip to content
This repository has been archived by the owner on Jul 30, 2019. It is now read-only.

Commit

Permalink
fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias ETIENNE committed Aug 6, 2015
1 parent 48e1792 commit bfa52a2
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 37 deletions.
71 changes: 39 additions & 32 deletions lib/check-config.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
"use strict";

var exec = require('child_process').exec
, execSync = require('sync-exec')
var execSync = require('sync-exec')
, Logger = require('./logger')


var routePaquets = exports.routePaquets = function () {

if (isBoot2DockerRunning() === false) {
Logger.error('Please start boot2docker first (boot2docker up)')
return false
}

var boot2dockerIp = getBoot2DockerIP()
var routeExec = execSync('route -n add 172.17.0.0/16 ' + boot2dockerIp)

if (routeExec.status !== 0) {
Logger.error("Cannot add route to boot2docker")
Logger.error(routeExec.stderr)
return false
}
/**
*
* @param command
* @returns {Object}
*/
var execAsNormalUser = function (command) {
return execSync('sudo -u ' + process.env.SUDO_USER + ' ' + command)
}

return true
/**
*
* @returns {String}
*/
var getBoot2DockerIP = function () {
return execAsNormalUser('boot2docker ip').stdout.trim()
}


/**
*
* @returns {boolean}
Expand All @@ -42,19 +40,28 @@ var isBoot2DockerRunning = exports.isBoot2DockerRunning = function () {
return b2dStatusStr === 'running'
}

var getBoot2DockerIP = function () {
return execAsNormalUser('boot2docker ip').stdout.trim()
}
var routePaquets = exports.routePaquets = function () {

/**
*
* @param command
* @returns {Object}
*/
var execAsNormalUser = function (command) {
return execSync('sudo -u ' + process.env.SUDO_USER + ' ' + command)
if (isBoot2DockerRunning() === false) {
Logger.error('Please start boot2docker first (boot2docker up)')
return false
}

var boot2dockerIp = getBoot2DockerIP()
var routeExec = execSync('route -n add 172.17.0.0/16 ' + boot2dockerIp)

if (routeExec.status !== 0) {
Logger.error("Cannot add route to boot2docker")
Logger.error(routeExec.stderr)
return false
}

return true
}




exports.setup = function (loopback_ip) {

var hasBoot = hasBoot2Docker()
Expand All @@ -72,18 +79,18 @@ exports.setup = function (loopback_ip) {

// ad loopback URL
var loopbackExec = execSync('ifconfig lo0 alias ' + loopback_ip)
if (loopbackExec.status != 0) {
if (loopbackExec.status !== 0) {
Logger.error('Error while setting up loopback IP');
Logger.error(loopbackExec.stderr);
return
return false
}

// route paquets
routePaquets()

Logger.info("Updating boot2docker DNS");

var updateDNSStatus = execAsNormalUser('boot2docker ssh -t \'sudo touch /var/lib/boot2docker/profile && echo EXTRA_ARGS=\\"--dns ' + loopback_ip +'\\" | sudo tee /var/lib/boot2docker/profile\'');
var updateDNSStatus = execAsNormalUser('boot2docker ssh -t \'sudo touch /var/lib/boot2docker/profile && echo EXTRA_ARGS=\\"--dns ' + loopback_ip + '\\" | sudo tee /var/lib/boot2docker/profile\'');

if (updateDNSStatus.status !== 0) {
return Logger.error("Error while updating boot2docker DNS")
Expand All @@ -95,7 +102,7 @@ exports.setup = function (loopback_ip) {
Logger.error("boot2docker DNS has not been updated.")
Logger.error("stdout: " + updateDNSStatus.stdout.trim())
Logger.error("stderr: " + updateDNSStatus.stderr.trim())
return
return false
}

Logger.info("Restarting boot2docker VM... please wait...");
Expand Down
2 changes: 0 additions & 2 deletions lib/dns-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

var EventEmitter = require('events').EventEmitter
, Logger = require('./logger')
, fs = require('fs-extra')
, path = require('path')
, util = require('util')
, dns = require('dns')
, _ = require('lodash')
Expand Down
2 changes: 1 addition & 1 deletion lib/docker-watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ DockerWatcher.prototype._onContainersListReceived = function (list) {
diff = !this.containers[id] || (_.isEqual(list[id].getComparableInfos(), this.containers[id].getComparableInfos()) === false)
}.bind(this));

if (!this.setup || (!diff && Object.keys(list).length != Object.keys(this.containers).length)) {
if (!this.setup || (!diff && Object.keys(list).length !== Object.keys(this.containers).length)) {
diff = true
}

Expand Down
3 changes: 1 addition & 2 deletions lib/network.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use strict";

var exec = require('child_process').exec
, Logger = require('./logger')
var Logger = require('./logger')
, path = require('path')
, fs = require('fs-extra')

Expand Down

0 comments on commit bfa52a2

Please sign in to comment.