mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-20 18:23:21 +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,10 +216,24 @@ function installService(params)
|
|||||||
options.description = params.getParameter('description', options.name + ' background service'); params.deleteParameter('description');
|
options.description = params.getParameter('description', options.name + ' background service'); params.deleteParameter('description');
|
||||||
|
|
||||||
if (process.platform == 'win32') { options.companyName = ''; }
|
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 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
|
// if '--copy-msh' is specified, we will try to copy the .msh configuration file found in the current working directory
|
||||||
var i;
|
var i;
|
||||||
@@ -268,6 +282,8 @@ function installService(params)
|
|||||||
options.parameters.splice(i, 1);
|
options.parameters.splice(i, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (global.gOptions != null && global.gOptions.noParams === true) { options.parameters = []; }
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Let's actually install the service
|
// Let's actually install the service
|
||||||
@@ -657,11 +673,19 @@ function fullUninstall(jsonString)
|
|||||||
serviceExists(loc, parms);
|
serviceExists(loc, parms);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Entry point for -fullinstall
|
// Entry point for -fullinstall, using JSON string
|
||||||
function fullInstall(jsonString)
|
function fullInstall(jsonString, gOptions)
|
||||||
{
|
{
|
||||||
// Perform some checks on the specified parameters
|
|
||||||
var parms = JSON.parse(jsonString);
|
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);
|
checkParameters(parms);
|
||||||
|
|
||||||
var loc = null;
|
var loc = null;
|
||||||
@@ -708,6 +732,7 @@ function fullInstall(jsonString)
|
|||||||
|
|
||||||
module.exports =
|
module.exports =
|
||||||
{
|
{
|
||||||
|
fullInstallEx: fullInstallEx,
|
||||||
fullInstall: fullInstall,
|
fullInstall: fullInstall,
|
||||||
fullUninstall: fullUninstall
|
fullUninstall: fullUninstall
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
_MSH = function _MSH() { return ({}); };
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Object.defineProperty(Array.prototype, 'getParameterEx',
|
Object.defineProperty(Array.prototype, 'getParameterEx',
|
||||||
@@ -173,7 +174,6 @@ server.on('request', function (imsg, resp)
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
accumulator.sent = 0;
|
accumulator.sent = 0;
|
||||||
|
|
||||||
process.stdout.write('Pushing Update via HTTPS...[0%]');
|
process.stdout.write('Pushing Update via HTTPS...[0%]');
|
||||||
var update = require('fs').createReadStream(getCurrentUpdatePath(), { flags: 'rb' });
|
var update = require('fs').createReadStream(getCurrentUpdatePath(), { flags: 'rb' });
|
||||||
accumulator.total = require('fs').statSync(getCurrentUpdatePath()).size;
|
accumulator.total = require('fs').statSync(getCurrentUpdatePath()).size;
|
||||||
@@ -674,16 +674,25 @@ if (process.argv.getParameter('AltBinary') != null)
|
|||||||
updateSource.push(alt);
|
updateSource.push(alt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.argv.getParameter('NoInstall') == null)
|
if (process.argv.getParameter('NoInstall') == null)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Start by installing agent as service
|
// 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 params = ['--__skipExit=1', '--logUpdate=1', '--meshServiceName=TestAgent'];
|
||||||
var paramsString = JSON.stringify(params);
|
var options =
|
||||||
|
{
|
||||||
require('agent-installer').fullInstall(paramsString);
|
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.setDestination(console.Destinations.STDOUT);
|
||||||
}
|
}
|
||||||
console.log('\nWaiting for Agent Connection...');
|
console.log('\nWaiting for Agent Connection...');
|
||||||
|
|||||||
Reference in New Issue
Block a user