mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-10 13:23:41 +00:00
Updated agent-installer and update-test so that the self update test can be used with very old agents, to test updating to/from old releases.
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -216,11 +216,25 @@ function installService(params)
|
||||
options.description = params.getParameter('description', options.name + ' background service'); params.deleteParameter('description');
|
||||
|
||||
if (process.platform == 'win32') { options.companyName = ''; }
|
||||
if (global.gOptions != null)
|
||||
{
|
||||
if(Array.isArray(global.gOptions.files))
|
||||
{
|
||||
options.files = global.gOptions.files;
|
||||
}
|
||||
if(global.gOptions.binary != null)
|
||||
{
|
||||
options.servicePath = global.gOptions.binary;
|
||||
}
|
||||
}
|
||||
|
||||
// If a .proxy file was found, we'll include it in the list of files to be copied when installing the agent
|
||||
if (require('fs').existsSync(proxyFile)) { options.files = [{ source: proxyFile, newName: options.target + '.proxy' }]; }
|
||||
if (require('fs').existsSync(proxyFile))
|
||||
{
|
||||
if (options.files == null) { options.files = []; }
|
||||
options.files.push({ source: proxyFile, newName: options.target + '.proxy' });
|
||||
}
|
||||
|
||||
|
||||
// if '--copy-msh' is specified, we will try to copy the .msh configuration file found in the current working directory
|
||||
var i;
|
||||
if ((i = params.indexOf('--copy-msh="1"')) >= 0)
|
||||
@@ -268,6 +282,8 @@ function installService(params)
|
||||
options.parameters.splice(i, 1);
|
||||
}
|
||||
|
||||
if (global.gOptions != null && global.gOptions.noParams === true) { options.parameters = []; }
|
||||
|
||||
try
|
||||
{
|
||||
// Let's actually install the service
|
||||
@@ -657,11 +673,19 @@ function fullUninstall(jsonString)
|
||||
serviceExists(loc, parms);
|
||||
}
|
||||
|
||||
// Entry point for -fullinstall
|
||||
function fullInstall(jsonString)
|
||||
// Entry point for -fullinstall, using JSON string
|
||||
function fullInstall(jsonString, gOptions)
|
||||
{
|
||||
// Perform some checks on the specified parameters
|
||||
var parms = JSON.parse(jsonString);
|
||||
fullInstallEx(parms, gOptions);
|
||||
}
|
||||
|
||||
// Entry point for -fullinstall, using JSON object
|
||||
function fullInstallEx(parms, gOptions)
|
||||
{
|
||||
if (gOptions != null) { global.gOptions = gOptions; }
|
||||
|
||||
// Perform some checks on the specified parameters
|
||||
checkParameters(parms);
|
||||
|
||||
var loc = null;
|
||||
@@ -708,6 +732,7 @@ function fullInstall(jsonString)
|
||||
|
||||
module.exports =
|
||||
{
|
||||
fullInstallEx: fullInstallEx,
|
||||
fullInstall: fullInstall,
|
||||
fullUninstall: fullUninstall
|
||||
};
|
||||
|
||||
@@ -15,6 +15,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
_MSH = function _MSH() { return ({}); };
|
||||
try
|
||||
{
|
||||
Object.defineProperty(Array.prototype, 'getParameterEx',
|
||||
@@ -173,7 +174,6 @@ server.on('request', function (imsg, resp)
|
||||
}
|
||||
});
|
||||
accumulator.sent = 0;
|
||||
|
||||
process.stdout.write('Pushing Update via HTTPS...[0%]');
|
||||
var update = require('fs').createReadStream(getCurrentUpdatePath(), { flags: 'rb' });
|
||||
accumulator.total = require('fs').statSync(getCurrentUpdatePath()).size;
|
||||
@@ -674,16 +674,25 @@ if (process.argv.getParameter('AltBinary') != null)
|
||||
updateSource.push(alt);
|
||||
}
|
||||
}
|
||||
|
||||
if (process.argv.getParameter('NoInstall') == null)
|
||||
{
|
||||
//
|
||||
// Start by installing agent as service
|
||||
//
|
||||
var params = ['--__skipExit=1', '--logUpdate=1', '--MeshID=0x43FEF862BF941B2BBE5964CC7CA02573BBFB94D5A717C5AA3FC103558347D0BE26840ACBD30FFF981F7F5A2083D0DABC', '--MeshServer=wss://127.0.0.1:9250/agent.ashx', '--meshServiceName=TestAgent', '--ServerID=' + loadedCert.getKeyHash().toString('hex')];
|
||||
var paramsString = JSON.stringify(params);
|
||||
|
||||
require('agent-installer').fullInstall(paramsString);
|
||||
var params = ['--__skipExit=1', '--logUpdate=1', '--meshServiceName=TestAgent'];
|
||||
var options =
|
||||
{
|
||||
files:
|
||||
[
|
||||
{
|
||||
newName: (process.platform == 'win32' ? 'MeshAgent.msh' : 'meshagent.msh'),
|
||||
_buffer: 'logUpdate=1\nMeshID=0x43FEF862BF941B2BBE5964CC7CA02573BBFB94D5A717C5AA3FC103558347D0BE26840ACBD30FFF981F7F5A2083D0DABC\nMeshServer=wss://127.0.0.1:9250/agent.ashx\nmeshServiceName=TestAgent\nServerID=' + loadedCert.getKeyHash().toString('hex')
|
||||
}
|
||||
],
|
||||
binary: updateSource.length > 1 ? updateSource[1] : null,
|
||||
noParams: true
|
||||
};
|
||||
require('agent-installer').fullInstallEx(params, options);
|
||||
console.setDestination(console.Destinations.STDOUT);
|
||||
}
|
||||
console.log('\nWaiting for Agent Connection...');
|
||||
|
||||
Reference in New Issue
Block a user