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,13 +196,23 @@ 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;
|
||||||
var id = this.get();
|
var id = this.get();
|
||||||
if (id.linux && id.linux.sys_vendor)
|
if (id.linux && id.linux.sys_vendor)
|
||||||
{
|
{
|
||||||
switch(id.linux.sys_vendor)
|
switch (id.linux.sys_vendor)
|
||||||
{
|
{
|
||||||
case 'VMware, Inc.':
|
case 'VMware, Inc.':
|
||||||
case 'QEMU':
|
case 'QEMU':
|
||||||
@@ -216,7 +226,7 @@ module.exports.isVM = function isVM()
|
|||||||
if (id.identifiers.board_vendor && id.identifiers.board_vendor == 'VMware, Inc.') { ret = true; }
|
if (id.identifiers.board_vendor && id.identifiers.board_vendor == 'VMware, Inc.') { ret = true; }
|
||||||
if (id.identifiers.board_name)
|
if (id.identifiers.board_name)
|
||||||
{
|
{
|
||||||
switch(id.identifiers.board_name)
|
switch (id.identifiers.board_name)
|
||||||
{
|
{
|
||||||
case 'VirtualBox':
|
case 'VirtualBox':
|
||||||
case 'Virtual Machine':
|
case 'Virtual Machine':
|
||||||
@@ -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