mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-19 17:53:28 +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'); } };
|
||||
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()
|
||||
{
|
||||
var ret = false;
|
||||
@@ -228,8 +238,10 @@ module.exports.isVM = function isVM()
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ret) { ret = this.isDocker(); }
|
||||
return (ret);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// bios_date = BIOS->ReleaseDate
|
||||
|
||||
Reference in New Issue
Block a user