mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-26 15:15:53 -05:00
Updated MeshCMD with MEI hang workaround.
This commit is contained in:
parent
315a399e36
commit
81d903672a
Binary file not shown.
Binary file not shown.
@ -514,8 +514,6 @@ function run(argv) {
|
||||
if (result.Versions[version].Description == 'AMT') { mestate.ver = result.Versions[version].Version; }
|
||||
if (result.Versions[version].Description == 'Sku') { mestate.sku = parseInt(result.Versions[version].Version); }
|
||||
}
|
||||
}
|
||||
});
|
||||
amtMei.getProvisioningState(function (result) { if (result) { mestate.ProvisioningState = result; } });
|
||||
amtMei.getProvisioningMode(function (result) { if (result) { mestate.ProvisioningMode = result; } });
|
||||
amtMei.getEHBCState(function (result) { if (result) { mestate.ehbc = result; } });
|
||||
@ -562,7 +560,7 @@ function run(argv) {
|
||||
}
|
||||
}
|
||||
if (typeof mestate.networkStatus == 'number') {
|
||||
str += '\r\nConnection Status: ' + ['Direct', 'VPN', 'Outside'][mestate.networkStatus];
|
||||
str += '\r\nConnection Status: ' + ['Direct', 'VPN', 'Outside', 'Unknown'][mestate.networkStatus];
|
||||
str += ', CIRA: ' + ['Disconnected', 'Connecting', 'Connected'][mestate.remoteAccessStatus];
|
||||
if ((mestate.remoteAccessStatus > 0) && (mestate.mpsHostname != null) && (mestate.mpsHostname.length > 0)) {
|
||||
str += ' to ' + mestate.mpsHostname + ', ' + ['User initiated', 'Alert', 'Periodic', 'Provisioning'][mestate.remoteAccessTrigger];
|
||||
@ -574,7 +572,12 @@ function run(argv) {
|
||||
}
|
||||
exit(1);
|
||||
});
|
||||
} catch (ex) { console.log("Unable to perform MEI operations, try running as administrator."); exit(1); return; }
|
||||
} else {
|
||||
console.log("Unable to perform MEI operations, try running as " + ((process.platform == 'win32')?"administrator.":"root."));
|
||||
exit(1); return;
|
||||
}
|
||||
});
|
||||
} catch (ex) { console.log("Unable to perform MEI operations, try running as " + ((process.platform == 'win32')?"administrator.":"root.")); exit(1); return; }
|
||||
} else if (settings.action == 'amtinfodebug') {
|
||||
// Display Intel AMT version and activation state
|
||||
getMeiState(15, function (state) { console.log(JSON.stringify(state, null, 2)); exit(1); }); // Flags: 1 = Versions, 2 = OsAdmin, 4 = Hashes, 8 = Network
|
||||
@ -590,10 +593,14 @@ function run(argv) {
|
||||
saveEntireAmtState();
|
||||
} else if ((settings.action == 'microlms') || (settings.action == 'amtlms') || (settings.action == 'lms')) {
|
||||
// Start Intel AMT MicroLMS
|
||||
// Because of a bug in MEI on Linux, LMS will jam if not root. To work around this, start by checking AMT state first.
|
||||
getMeiState(0, function (xstate) { // Flags: 1 = Versions, 2 = OsAdmin, 4 = Hashes, 8 = Network
|
||||
if (xstate == null) { console.log("Unable to get Intel AMT state, try running as " + ((process.platform == 'win32')?"administrator.":"root.")); exit(1); return; }
|
||||
startLms(function (state) {
|
||||
console.log(['MicroLMS did not start. Must run as administrator or LMS already active.', 'MicroLMS started.', 'MicroLMS started, MeshCommander on HTTP/16994.', 'MEI error'][state]);
|
||||
if (((state == 0) || (state == 3)) && (settings.noconsole === true)) { exit(0); } else { console.log('Press ctrl-c to exit.'); }
|
||||
}, settings.noconsole !== true);
|
||||
}, false, xstate);
|
||||
});
|
||||
} else if (settings.action == 'amtpresence') {
|
||||
// Heartbeat a Intel AMT watchdog
|
||||
if ((settings.password == null) || (typeof settings.password != 'string') || (settings.password == '')) { console.log('No or invalid \"password\" specified, use --password [password].'); exit(1); return; }
|
||||
@ -1110,13 +1117,15 @@ function startMeshCommander() {
|
||||
|
||||
function configureAmt() {
|
||||
settings.noconsole = true;
|
||||
startLms(configureAmt2, amtMei);
|
||||
// Due to a bug in MEI handling, we have to pull MEI state first before starting LMS.
|
||||
getMeiState(15, function (state) { // Flags: 1 = Versions, 2 = OsAdmin, 4 = Hashes, 8 = Network
|
||||
if (state == null) { console.log("Unable to get Intel AMT state, try running as " + ((process.platform == 'win32')?"administrator.":"root.")); exit(1); return; }
|
||||
if (state.ProvisioningState == null) { console.log('Intel AMT not ready for configuration.'); exit(1); return; }
|
||||
startLms(configureAmt2, false, state);
|
||||
});
|
||||
}
|
||||
|
||||
function configureAmt2() {
|
||||
getMeiState(15, function (state) { // Flags: 1 = Versions, 2 = OsAdmin, 4 = Hashes, 8 = Network
|
||||
if (state == null) { console.log('Unable to get Intel AMT state, try running as administrator.'); exit(1); return; }
|
||||
if (state.ProvisioningState == null) { console.log('Intel AMT not ready for configuration.'); exit(1); return; }
|
||||
function configureAmt2(err, state) {
|
||||
console.log('Starting Intel AMT configuration...');
|
||||
|
||||
// Add indication if the device is battery powered, this is used to show a mobile icon when adding the device
|
||||
@ -1159,7 +1168,6 @@ function configureAmt2() {
|
||||
exit(1); return;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function configureJsonControl(data) {
|
||||
@ -1476,7 +1484,7 @@ function startLms(func, lmscommander, tag) {
|
||||
try { amtLms = new lme_heci({ debug: settings.lmsdebug }); } catch (ex) { if (func != null) { func(0, tag); } return; }
|
||||
amtLms.promise = ret;
|
||||
amtLms.on('error', function (e) {
|
||||
//console.log('LME connection failed', e);
|
||||
console.log('LME connection failed', e);
|
||||
if (lmscommander === true) { //settings.noconsole !== true) {
|
||||
startMeshCommanderLms();
|
||||
//console.log("LMS started, MeshCommander on HTTP/16994.");
|
||||
@ -2745,8 +2753,12 @@ function getMeiState(flags, func) {
|
||||
amtMei.on('error', function (e) { func(null); return; });
|
||||
try {
|
||||
var amtMeiTmpState = { 'core-ver': 1, OsHostname: require('os').hostname(), Flags: 0 }; // Flags: 1=EHBC, 2=CCM, 4=ACM
|
||||
amtMei.getVersion(function (result) {
|
||||
if (result == null) { func(null); return; }
|
||||
amtMeiTmpState.Versions = {}; for (var version in result.Versions) { amtMeiTmpState.Versions[result.Versions[version].Description] = result.Versions[version].Version; }
|
||||
|
||||
amtMei.getProtocolVersion(function (result) { if (result != null) { amtMeiTmpState.MeiVersion = result; } });
|
||||
if ((flags & 1) != 0) { amtMei.getVersion(function (result) { if (result) { amtMeiTmpState.Versions = {}; for (var version in result.Versions) { amtMeiTmpState.Versions[result.Versions[version].Description] = result.Versions[version].Version; } } }); }
|
||||
//if ((flags & 1) != 0) { amtMei.getVersion(function (result) { if (result) { } }); }
|
||||
amtMei.getProvisioningMode(function (result) { if (result) { amtMeiTmpState.ProvisioningMode = result.mode; } });
|
||||
amtMei.getProvisioningState(function (result) { if (result) { amtMeiTmpState.ProvisioningState = result.state; } }); // 0: "Not Activated (Pre)", 1: "Not Activated (In)", 2: "Activated"
|
||||
amtMei.getEHBCState(function (result) { if ((result != null) && (result.EHBC == true)) { amtMeiTmpState.Flags += 1; } });
|
||||
@ -2772,6 +2784,7 @@ function getMeiState(flags, func) {
|
||||
for (var i = 0; i < handles.length; ++i) { this.getCertHashEntry(handles[i], function (hashresult) { amtMeiTmpState.Hashes.push(hashresult); if (--exitOnCount == 0) { if (func != null) { func(amtMeiTmpState); } } }); }
|
||||
});
|
||||
}
|
||||
});
|
||||
} catch (e) { if (func != null) { func(null); } return; }
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user