1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2026-01-09 03:53:26 +00:00

Updated installer, to delete old .msh file before installing/updating agent

This commit is contained in:
Bryan Roe
2020-06-04 13:53:56 -07:00
parent f590c53ac8
commit a0ed803cf6
2 changed files with 22 additions and 10 deletions

View File

@@ -194,13 +194,15 @@ function uninstallService3(params)
}
}
function uninstallService2(params)
function uninstallService2(params, msh)
{
var secondaryagent = false;
var i;
var dataFolder = null;
var appPrefix = null;
try { require('fs').unlinkSync(msh); } catch (mshe) { }
if (params && params.includes('--_deleteData="1"'))
{
for (i = 0; i < params.length; ++i)
@@ -310,6 +312,16 @@ function uninstallService2(params)
function uninstallService(params)
{
var svc = require('service-manager').manager.getService(process.platform == 'win32' ? 'Mesh Agent' : 'meshagent');
var msh = svc.appLocation();
if (process.platform == 'win32')
{
msh = msh.substring(0, msh.length - 4) + '.msh';
}
else
{
msh = msh + '.msh';
}
if (svc.isRunning())
{
process.stdout.write(' -> Stopping Service...');
@@ -319,12 +331,12 @@ function uninstallService(params)
{
process.stdout.write(' [STOPPED]\n');
svc.close();
uninstallService2(this._params);
uninstallService2(this._params, msh);
}, function ()
{
process.stdout.write(' [ERROR]\n');
svc.close();
uninstallService2(this._params);
uninstallService2(this._params, ms);
}).parentPromise._params = params;
}
else
@@ -338,13 +350,13 @@ function uninstallService(params)
svc.stop();
}
process.stdout.write(' [STOPPED]\n');
uninstallService2(params);
uninstallService2(params, msh);
}
}
else
{
if (process.platform == 'win32') { svc.close(); }
uninstallService2(params);
uninstallService2(params, msh);
}
}
function serviceExists(loc, params)