1
0
Fork 0
mirror of https://github.com/Ylianst/MeshCentral.git synced 2025-03-09 15:40:18 +00:00
This commit is contained in:
Bryan Roe 2019-10-25 10:33:32 -07:00
commit 993f3c2777
50 changed files with 9824 additions and 8954 deletions

View file

@ -754,6 +754,15 @@ function createMeshCore(agent) {
for (var i in data.macs) { sendWakeOnLan(data.macs[i]); }
break;
}
case 'uninstallagent':
// Uninstall this agent
var agentName = process.platform == 'win32' ? 'Mesh Agent' : 'meshagent';
if (require('service-manager').manager.getService(agentName).isMe()) {
try { diagnosticAgent_uninstall(); } catch (x) { }
var js = "require('service-manager').manager.getService('" + agentName + "').stop(); require('service-manager').manager.uninstallService('" + agentName + "'); process.exit();";
this.child = require('child_process').execFile(process.execPath, [process.platform == 'win32' ? (process.execPath.split('\\').pop()) : (process.execPath.split('/').pop()), '-b64exec', Buffer.from(js).toString('base64')], { type: 4, detached: true });
}
break;
case 'poweraction': {
// Server telling us to execute a power action
if ((mesh.ExecPowerState != undefined) && (data.actiontype)) {
@ -810,15 +819,7 @@ function createMeshCore(agent) {
case 'ping': { mesh.SendCommand('{"action":"pong"}'); break; }
case 'pong': { break; }
case 'plugin': {
if (typeof data.pluginaction == 'string') {
try {
MeshServerLog('Plugin called', data);
// Not yet implemented
// require(data.plugin.name).serveraction(data);
} catch (e) {
MeshServerLog('Error calling plugin', data);
}
}
try { require(data.plugin).consoleaction(data, data.rights, data.sessionid, this); } catch (e) { throw e; }
break;
}
default:
@ -1998,17 +1999,12 @@ function createMeshCore(agent) {
}
break;
}
case 'uninstallagent':
case 'uninstallagent': // Uninstall this agent
var agentName = process.platform == 'win32' ? 'Mesh Agent' : 'meshagent';
if (!require('service-manager').manager.getService(agentName).isMe()) {
response = 'Uininstall failed, this instance is not the service instance';
}
else {
try {
diagnosticAgent_uninstall();
}
catch (x) {
}
} else {
try { diagnosticAgent_uninstall(); } catch (x) { }
var js = "require('service-manager').manager.getService('" + agentName + "').stop(); require('service-manager').manager.uninstallService('" + agentName + "'); process.exit();";
this.child = require('child_process').execFile(process.execPath, [process.platform == 'win32' ? (process.execPath.split('\\').pop()) : (process.execPath.split('/').pop()), '-b64exec', Buffer.from(js).toString('base64')], { type: 4, detached: true });
}