mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-16 00:03:45 +00:00
Updated self update to display update message in console mode on linux
This commit is contained in:
@@ -5651,6 +5651,7 @@ int MeshAgent_Start(MeshAgentHostContainer *agentHost, int paramLen, char **para
|
||||
ILIBLOGMESSSAGE("SelfUpdate -> Service Check... [NO]");
|
||||
ILIBLOGMESSSAGE("SelfUpdate -> Manual Mode (COMPLETE)");
|
||||
}
|
||||
ignore_result(write(STDOUT_FILENO, "SelfUpdate -> Updating Agent...\n", 32));
|
||||
|
||||
// Generic update process, call our own update with arguments.
|
||||
struct stat results;
|
||||
@@ -5660,6 +5661,7 @@ int MeshAgent_Start(MeshAgentHostContainer *agentHost, int paramLen, char **para
|
||||
remove(agentHost->exePath);
|
||||
sprintf_s(ILibScratchPad, sizeof(ILibScratchPad), "cp %s %s", updateFilePath, agentHost->exePath);
|
||||
if (system(ILibScratchPad)) {}
|
||||
ignore_result(write(STDOUT_FILENO, "SelfUpdate -> Restarting Agent...\n", 34));
|
||||
|
||||
execv(agentHost->exePath, agentHost->execparams);
|
||||
_exit(1);
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -585,12 +585,14 @@ function sys_update(isservice, b64)
|
||||
{
|
||||
// This is run on the 'updated' agent.
|
||||
|
||||
var parm = b64 != null ? JSON.parse(Buffer.from(b64, 'base64').toString()) : null;
|
||||
var service = null;
|
||||
var serviceLocation = "";
|
||||
var px;
|
||||
|
||||
console.setInfoLevel(1);
|
||||
if (isservice)
|
||||
{
|
||||
var parm = b64 != null ? JSON.parse(Buffer.from(b64, 'base64').toString()) : null;
|
||||
|
||||
console.info1('sys_update(' + isservice + ', ' + JSON.stringify(parm) + ')');
|
||||
if ((px = parm.getParameterIndex('fakeUpdate')) >= 0)
|
||||
{
|
||||
@@ -598,14 +600,13 @@ function sys_update(isservice, b64)
|
||||
parm.splice(px, 1);
|
||||
}
|
||||
|
||||
if (isservice)
|
||||
{
|
||||
|
||||
//
|
||||
// Service Mode
|
||||
//
|
||||
|
||||
// Check if we have sufficient permission
|
||||
if(!require('user-sessions').isRoot())
|
||||
if (!require('user-sessions').isRoot())
|
||||
{
|
||||
// We don't have enough permissions, so copying the binary will likely fail, and we can't start...
|
||||
// This is just to prevent looping, because agentcore.c should not call us in this scenario
|
||||
@@ -613,14 +614,14 @@ function sys_update(isservice, b64)
|
||||
process._exit();
|
||||
return;
|
||||
}
|
||||
var servicename = parm!=null?(parm.getParameter('meshServiceName', process.platform=='win32'?'Mesh Agent' : 'meshagent')):(process.platform == 'win32' ? 'Mesh Agent' : 'meshagent');
|
||||
var servicename = parm != null ? (parm.getParameter('meshServiceName', process.platform == 'win32' ? 'Mesh Agent' : 'meshagent')) : (process.platform == 'win32' ? 'Mesh Agent' : 'meshagent');
|
||||
try
|
||||
{
|
||||
service = require('service-manager').manager.getService(servicename)
|
||||
serviceLocation = service.appLocation();
|
||||
console.log(' Updating service: ' + servicename);
|
||||
}
|
||||
catch(f)
|
||||
catch (f)
|
||||
{
|
||||
console.log(' * ' + servicename + ' SERVICE NOT FOUND *');
|
||||
process._exit();
|
||||
|
||||
Reference in New Issue
Block a user