From 89bfce1dc66e5f025c58668a66af1739e51a33c6 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Thu, 18 Jul 2019 13:30:49 -0700 Subject: [PATCH] Fixed server self-update --- meshcentral.js | 17 ++++++----------- package.json | 2 +- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/meshcentral.js b/meshcentral.js index 2783f1ac..20bd85d8 100644 --- a/meshcentral.js +++ b/meshcentral.js @@ -176,21 +176,16 @@ function CreateMeshCentralServer(config, args) { process.exit(); // User CTRL-C exit. } else if (childProcess.xrestart == 3) { // Server self-update exit - var updateArgs = []; - var npmpath = ((typeof obj.args.npmpath == 'string') ? obj.args.npmpath : 'npm'); - if (typeof obj.args.npmproxy == 'string') { updateArgs.push('--proxy', obj.args.npmproxy); } - updateArgs.push('install', 'meshcentral'); - if (typeof obj.args.selfupdate == 'string') { updateArgs.push('@' + obj.args.selfupdate); } - + var version = ''; + if (typeof obj.args.selfupdate == 'string') { version = '@' + obj.args.selfupdate; } var child_process = require('child_process'); - var xxprocess = child_process.execFile(npmpath, updateArgs, { maxBuffer: Infinity, cwd: obj.parentpath }, function (error, stdout, stderr) { }); + var npmpath = ((typeof obj.args.npmpath == 'string') ? obj.args.npmpath : 'npm'); + var npmproxy = ((typeof obj.args.npmproxy == 'string') ? (' --proxy ' + obj.args.npmproxy) : ''); + var xxprocess = child_process.exec(npmpath + ' install meshcentral' + version + npmproxy, { maxBuffer: Infinity, cwd: obj.parentpath }, function (error, stdout, stderr) { }); xxprocess.data = ''; xxprocess.stdout.on('data', function (data) { xxprocess.data += data; }); xxprocess.stderr.on('data', function (data) { xxprocess.data += data; }); - xxprocess.on('close', function (code) { - console.log('Update completed...'); - setTimeout(function () { obj.launchChildServer(startArgs); }, 1000); - }); + xxprocess.on('close', function (code) { console.log('Update completed...'); setTimeout(function () { obj.launchChildServer(startArgs); }, 1000); }); } else { if (error != null) { // This is an un-expected restart diff --git a/package.json b/package.json index 1ed9283f..3ae66b41 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.3.8-b", + "version": "0.3.8-d", "keywords": [ "Remote Management", "Intel AMT",