This commit is contained in:
William Mantly 2016-01-30 00:26:17 -05:00
parent 1644812213
commit fe838a7719

9
lxc.js
View File

@ -1,11 +1,16 @@
'use strict'; 'use strict';
var exec = require('child_process').exec; var exec = require('child_process').exec;
var callback_parse = callbackParse(err, data, stderr, callback){
console.log(arguments)
return callback(data, err, stderr)
};
function sysExec(command, callback){ function sysExec(command, callback){
command = 'unset XDG_SESSION_ID XDG_RUNTIME_DIR; cgm movepid all virt $$; ' + command; command = 'unset XDG_SESSION_ID XDG_RUNTIME_DIR; cgm movepid all virt $$; ' + command;
callback = callback || function(){}; callback = callback || function(){};
return exec(command, callback); return exec(command, callback_parse(callback));
}; };
var lxc = { var lxc = {
@ -31,7 +36,7 @@ var lxc = {
startEphemeral: function(name, base_name, callback){ startEphemeral: function(name, base_name, callback){
var command = 'lxc-start-ephemeral -o '+base_name+ ' -n '+name +' --union-type overlayfs -d'; var command = 'lxc-start-ephemeral -o '+base_name+ ' -n '+name +' --union-type overlayfs -d';
callback = callback || function(){}; callback = callback || function(){};
return sysExec(command, function(data){ return sysExec(command, function(data){
if(data.match("doesn't exist.")){ if(data.match("doesn't exist.")){
return callback({status: 500, error: "doesn't exist."}); return callback({status: 500, error: "doesn't exist."});