mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-14 23:33:38 +00:00
1. Changed Array.includes polyfill to be nonenumerable, fixing potential problems when using for loops
2. Added uninstall helper 3. Fixed macOS bug on 'load' function
This commit is contained in:
@@ -3883,6 +3883,10 @@ int MeshAgent_AgentMode(MeshAgentHostContainer *agentHost, int paramLen, char **
|
|||||||
{
|
{
|
||||||
installFlag = 1;
|
installFlag = 1;
|
||||||
}
|
}
|
||||||
|
if (strcmp("-funinstall", param[ri]) == 0)
|
||||||
|
{
|
||||||
|
installFlag = 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
paramLen -= ixr;
|
paramLen -= ixr;
|
||||||
if (installFlag != 0)
|
if (installFlag != 0)
|
||||||
@@ -3917,10 +3921,23 @@ int MeshAgent_AgentMode(MeshAgentHostContainer *agentHost, int paramLen, char **
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
duk_pop(ctxx);
|
duk_pop(ctxx);
|
||||||
|
|
||||||
ILibMemory_Free(buf);
|
ILibMemory_Free(buf);
|
||||||
return(1);
|
return(1);
|
||||||
break;
|
break;
|
||||||
|
case 2:
|
||||||
|
duk_eval_string(ctxx, "require('agent-installer');");
|
||||||
|
duk_get_prop_string(ctxx, -1, "fullUninstall");
|
||||||
|
duk_swap_top(ctxx, -2);
|
||||||
|
if (duk_pcall_method(ctxx, 0) != 0)
|
||||||
|
{
|
||||||
|
if (strcmp(duk_safe_to_string(ctxx, -1), "Process.exit() forced script termination") != 0)
|
||||||
|
{
|
||||||
|
printf("%s\n", duk_safe_to_string(ctxx, -1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
duk_pop(ctxx);
|
||||||
|
return(1);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -953,7 +953,7 @@ int wmain(int argc, char* wargv[])
|
|||||||
WideCharToMultiByte(CP_UTF8, 0, (LPCWCH)wargv[argvi], -1, argv[argvi], argvsz, NULL, NULL);
|
WideCharToMultiByte(CP_UTF8, 0, (LPCWCH)wargv[argvi], -1, argv[argvi], argvsz, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc > 1 && (strcasecmp(argv[1], "-finstall") == 0))
|
if (argc > 1 && (strcasecmp(argv[1], "-finstall") == 0 || strcasecmp(argv[1], "-funinstall") == 0))
|
||||||
{
|
{
|
||||||
argv[argc] = argv[1];
|
argv[argc] = argv[1];
|
||||||
argv[1] = (char*)ILibMemory_SmartAllocate(4);
|
argv[1] = (char*)ILibMemory_SmartAllocate(4);
|
||||||
@@ -961,7 +961,6 @@ int wmain(int argc, char* wargv[])
|
|||||||
argc += 1;
|
argc += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#ifndef NOMESHCMD
|
#ifndef NOMESHCMD
|
||||||
// Check if this is a Mesh command operation
|
// Check if this is a Mesh command operation
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -37,6 +37,11 @@ function installService(params)
|
|||||||
process.exit();
|
process.exit();
|
||||||
}
|
}
|
||||||
var svc = require('service-manager').manager.getService(process.platform=='win32'?'Mesh Agent':'meshagent');
|
var svc = require('service-manager').manager.getService(process.platform=='win32'?'Mesh Agent':'meshagent');
|
||||||
|
if (process.platform == 'darwin')
|
||||||
|
{
|
||||||
|
svc.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(process.platform == 'win32')
|
if(process.platform == 'win32')
|
||||||
{
|
{
|
||||||
@@ -126,7 +131,14 @@ function uninstallService2(params)
|
|||||||
{
|
{
|
||||||
process.stdout.write(' [ERROR]\n');
|
process.stdout.write(' [ERROR]\n');
|
||||||
}
|
}
|
||||||
installService(params);
|
if (params != null)
|
||||||
|
{
|
||||||
|
installService(params);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
process.exit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function uninstallService(params)
|
function uninstallService(params)
|
||||||
{
|
{
|
||||||
@@ -185,7 +197,24 @@ function serviceExists(loc, params)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fullUninstall()
|
||||||
|
{
|
||||||
|
console.setDestination(console.Destinations.DISABLED);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
process.stdout.write('...Checking for previous installation');
|
||||||
|
var s = require('service-manager').manager.getService(process.platform == 'win32' ? 'Mesh Agent' : 'meshagent');
|
||||||
|
var loc = s.appLocation();
|
||||||
|
s.close();
|
||||||
|
}
|
||||||
|
catch (e)
|
||||||
|
{
|
||||||
|
process.stdout.write(' [NONE]\n');
|
||||||
|
process.exit();
|
||||||
|
}
|
||||||
|
serviceExists(loc, null);
|
||||||
|
}
|
||||||
|
|
||||||
function fullInstall(jsonString)
|
function fullInstall(jsonString)
|
||||||
{
|
{
|
||||||
@@ -211,5 +240,6 @@ function fullInstall(jsonString)
|
|||||||
|
|
||||||
module.exports =
|
module.exports =
|
||||||
{
|
{
|
||||||
fullInstall: fullInstall
|
fullInstall: fullInstall,
|
||||||
|
fullUninstall: fullUninstall
|
||||||
};
|
};
|
||||||
@@ -308,7 +308,7 @@ if (process.platform == 'darwin')
|
|||||||
|
|
||||||
if (this.daemon)
|
if (this.daemon)
|
||||||
{
|
{
|
||||||
if(uid!=null || uid!=0)
|
if(uid!=null && uid!=0)
|
||||||
{
|
{
|
||||||
throw ('LaunchDaemon must run as root');
|
throw ('LaunchDaemon must run as root');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user