1
0
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:
Bryan Roe
2020-02-25 23:32:21 -08:00
parent 7c77677b3e
commit 6f5f065eb5
5 changed files with 68 additions and 23 deletions

View File

@@ -3883,6 +3883,10 @@ int MeshAgent_AgentMode(MeshAgentHostContainer *agentHost, int paramLen, char **
{
installFlag = 1;
}
if (strcmp("-funinstall", param[ri]) == 0)
{
installFlag = 2;
}
}
paramLen -= ixr;
if (installFlag != 0)
@@ -3917,10 +3921,23 @@ int MeshAgent_AgentMode(MeshAgentHostContainer *agentHost, int paramLen, char **
}
}
duk_pop(ctxx);
ILibMemory_Free(buf);
return(1);
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:
break;
}

View File

@@ -953,7 +953,7 @@ int wmain(int argc, char* wargv[])
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[1] = (char*)ILibMemory_SmartAllocate(4);
@@ -961,7 +961,6 @@ int wmain(int argc, char* wargv[])
argc += 1;
}
/*
#ifndef NOMESHCMD
// Check if this is a Mesh command operation

File diff suppressed because one or more lines are too long

View File

@@ -37,6 +37,11 @@ function installService(params)
process.exit();
}
var svc = require('service-manager').manager.getService(process.platform=='win32'?'Mesh Agent':'meshagent');
if (process.platform == 'darwin')
{
svc.load();
}
if(process.platform == 'win32')
{
@@ -126,7 +131,14 @@ function uninstallService2(params)
{
process.stdout.write(' [ERROR]\n');
}
if (params != null)
{
installService(params);
}
else
{
process.exit();
}
}
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)
{
@@ -211,5 +240,6 @@ function fullInstall(jsonString)
module.exports =
{
fullInstall: fullInstall
fullInstall: fullInstall,
fullUninstall: fullUninstall
};

View File

@@ -308,7 +308,7 @@ if (process.platform == 'darwin')
if (this.daemon)
{
if(uid!=null || uid!=0)
if(uid!=null && uid!=0)
{
throw ('LaunchDaemon must run as root');
}