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 -> Service Check... [NO]");
|
||||||
ILIBLOGMESSSAGE("SelfUpdate -> Manual Mode (COMPLETE)");
|
ILIBLOGMESSSAGE("SelfUpdate -> Manual Mode (COMPLETE)");
|
||||||
}
|
}
|
||||||
|
ignore_result(write(STDOUT_FILENO, "SelfUpdate -> Updating Agent...\n", 32));
|
||||||
|
|
||||||
// Generic update process, call our own update with arguments.
|
// Generic update process, call our own update with arguments.
|
||||||
struct stat results;
|
struct stat results;
|
||||||
@@ -5660,6 +5661,7 @@ int MeshAgent_Start(MeshAgentHostContainer *agentHost, int paramLen, char **para
|
|||||||
remove(agentHost->exePath);
|
remove(agentHost->exePath);
|
||||||
sprintf_s(ILibScratchPad, sizeof(ILibScratchPad), "cp %s %s", updateFilePath, agentHost->exePath);
|
sprintf_s(ILibScratchPad, sizeof(ILibScratchPad), "cp %s %s", updateFilePath, agentHost->exePath);
|
||||||
if (system(ILibScratchPad)) {}
|
if (system(ILibScratchPad)) {}
|
||||||
|
ignore_result(write(STDOUT_FILENO, "SelfUpdate -> Restarting Agent...\n", 34));
|
||||||
|
|
||||||
execv(agentHost->exePath, agentHost->execparams);
|
execv(agentHost->exePath, agentHost->execparams);
|
||||||
_exit(1);
|
_exit(1);
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -585,27 +585,28 @@ function sys_update(isservice, b64)
|
|||||||
{
|
{
|
||||||
// This is run on the 'updated' agent.
|
// This is run on the 'updated' agent.
|
||||||
|
|
||||||
var parm = b64 != null ? JSON.parse(Buffer.from(b64, 'base64').toString()) : null;
|
|
||||||
var service = null;
|
var service = null;
|
||||||
var serviceLocation = "";
|
var serviceLocation = "";
|
||||||
var px;
|
var px;
|
||||||
|
|
||||||
console.setInfoLevel(1);
|
|
||||||
console.info1('sys_update(' + isservice + ', ' + JSON.stringify(parm) + ')');
|
|
||||||
if ((px = parm.getParameterIndex('fakeUpdate')) >= 0)
|
|
||||||
{
|
|
||||||
console.info1('Removing "fakeUpdate" parameter');
|
|
||||||
parm.splice(px, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isservice)
|
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)
|
||||||
|
{
|
||||||
|
console.info1('Removing "fakeUpdate" parameter');
|
||||||
|
parm.splice(px, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Service Mode
|
// Service Mode
|
||||||
//
|
//
|
||||||
|
|
||||||
// Check if we have sufficient permission
|
// 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...
|
// 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
|
// 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();
|
process._exit();
|
||||||
return;
|
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
|
try
|
||||||
{
|
{
|
||||||
service = require('service-manager').manager.getService(servicename)
|
service = require('service-manager').manager.getService(servicename)
|
||||||
serviceLocation = service.appLocation();
|
serviceLocation = service.appLocation();
|
||||||
console.log(' Updating service: ' + servicename);
|
console.log(' Updating service: ' + servicename);
|
||||||
}
|
}
|
||||||
catch(f)
|
catch (f)
|
||||||
{
|
{
|
||||||
console.log(' * ' + servicename + ' SERVICE NOT FOUND *');
|
console.log(' * ' + servicename + ' SERVICE NOT FOUND *');
|
||||||
process._exit();
|
process._exit();
|
||||||
|
|||||||
Reference in New Issue
Block a user