|
|
@ -17,6 +17,10 @@ module.exports = function(io) { |
|
|
|
proc.exec(cmd, callback); |
|
|
|
proc.exec(cmd, callback); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function fail(txt, data) { |
|
|
|
|
|
|
|
console.log("** "+txt, data); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var oldcontainer = null; |
|
|
|
var oldcontainer = null; |
|
|
|
function containerinspect(error, stdout, stderr) { |
|
|
|
function containerinspect(error, stdout, stderr) { |
|
|
|
if (error || stderr) |
|
|
|
if (error || stderr) |
|
|
@ -96,7 +100,7 @@ module.exports = function(io) { |
|
|
|
|
|
|
|
|
|
|
|
function modify(cmd, name) { |
|
|
|
function modify(cmd, name) { |
|
|
|
if (!name.match(/^[a-z0-9][-_:.+a-z0-9]*$/i)) |
|
|
|
if (!name.match(/^[a-z0-9][-_:.+a-z0-9]*$/i)) |
|
|
|
return fail("illegal instance name"); |
|
|
|
return this.fail("illegal instance name"); |
|
|
|
exec("docker "+cmd+" "+name, updatecontainers); |
|
|
|
exec("docker "+cmd+" "+name, updatecontainers); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -104,7 +108,7 @@ module.exports = function(io) { |
|
|
|
if (cmds.length>0) |
|
|
|
if (cmds.length>0) |
|
|
|
exec(cmds.shift(), function(error, stdout, stderr) { |
|
|
|
exec(cmds.shift(), function(error, stdout, stderr) { |
|
|
|
if (error || stderr) |
|
|
|
if (error || stderr) |
|
|
|
return fail("create container failed", { |
|
|
|
return this.fail("create container failed", { |
|
|
|
error: error, stderr: stderr, stdout: stdout |
|
|
|
error: error, stderr: stderr, stdout: stdout |
|
|
|
}); |
|
|
|
}); |
|
|
|
createContainer(cmds); |
|
|
|
createContainer(cmds); |
|
|
@ -175,7 +179,7 @@ module.exports = function(io) { |
|
|
|
|
|
|
|
|
|
|
|
function new_bash(name) { |
|
|
|
function new_bash(name) { |
|
|
|
if (!name.match(/^[a-z0-9][-_:.+a-z0-9]*$/i)) |
|
|
|
if (!name.match(/^[a-z0-9][-_:.+a-z0-9]*$/i)) |
|
|
|
return fail("illegal instance name"); |
|
|
|
return this.fail("illegal instance name"); |
|
|
|
if (bash_connections[name]) return; |
|
|
|
if (bash_connections[name]) return; |
|
|
|
bash_connections[name] = |
|
|
|
bash_connections[name] = |
|
|
|
pty.spawn("docker", ["exec", "-it", name, "bash", "-i"]); |
|
|
|
pty.spawn("docker", ["exec", "-it", name, "bash", "-i"]); |
|
|
|