mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-19 09:43:20 +00:00
Added Docker container detection
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -196,6 +196,16 @@ switch(process.platform)
|
|||||||
module.exports = { get: function () { throw ('Unsupported Platform'); } };
|
module.exports = { get: function () { throw ('Unsupported Platform'); } };
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
module.exports.isDocker = function isDocker()
|
||||||
|
{
|
||||||
|
if (process.platform != 'linux') { return (false); }
|
||||||
|
|
||||||
|
var child = require('child_process').execFile('/bin/sh', ['sh']);
|
||||||
|
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
||||||
|
child.stdin.write("cat /proc/self/cgroup | tr '\n' '`' | awk -F'`' '{ split($1, res, " + '"/"); if(res[2]=="docker"){print "1";} }\'\nexit\n');
|
||||||
|
child.waitExit();
|
||||||
|
return (child.stdout.str != '');
|
||||||
|
};
|
||||||
module.exports.isVM = function isVM()
|
module.exports.isVM = function isVM()
|
||||||
{
|
{
|
||||||
var ret = false;
|
var ret = false;
|
||||||
@@ -228,8 +238,10 @@ module.exports.isVM = function isVM()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!ret) { ret = this.isDocker(); }
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
// bios_date = BIOS->ReleaseDate
|
// bios_date = BIOS->ReleaseDate
|
||||||
|
|||||||
Reference in New Issue
Block a user