1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-24 04:04:31 +00:00

Fixed uninstall logic for macOS

This commit is contained in:
Bryan Roe
2020-02-26 11:25:01 -08:00
parent ee8bf176e8
commit 908698fb68
3 changed files with 46 additions and 43 deletions

File diff suppressed because one or more lines are too long

View File

@@ -193,8 +193,15 @@ function uninstallService(params)
}).parentPromise._params = params;
}
else
{
if (process.platform == 'darwin')
{
svc.unload();
}
else
{
svc.stop();
}
process.stdout.write(' [STOPPED]\n');
uninstallService2(params);
}

View File

@@ -151,6 +151,7 @@ if (process.platform == 'darwin')
var files = require('fs').readdirSync(folder);
for (var file in files)
{
if (!files[file].endsWith('.plist')) { continue; }
var child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = '';
child.stdout.on('data', function (chunk) { this.str += chunk.toString(); });
@@ -410,9 +411,16 @@ if (process.platform == 'darwin')
child.stdout.on('data', function (chunk) { this.str += chunk.toString(); });
child.stderr.on('data', function (chunk) { this.str += chunk.toString(); });
if (useBootout)
{
if (uid == null)
{
child.stdin.write('launchctl bootout system ' + this.plist + '\nexit\n');
}
else
{
child.stdin.write('launchctl bootout gui/' + uid + ' ' + this.plist + '\nexit\n');
}
}
else
{
child.stdin.write('launchctl unload ' + this.plist + '\nexit\n');
@@ -2203,18 +2211,10 @@ function serviceManager()
}
else if(process.platform == 'darwin')
{
if (require('fs').existsSync('/Library/LaunchDaemons/' + name + '.plist'))
{
var child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.on('data', function (chunk) { });
child.stdin.write('launchctl stop ' + name + '\n');
child.stdin.write('launchctl unload /Library/LaunchDaemons/' + name + '.plist\n');
child.stdin.write('exit\n');
child.waitExit();
service.unload();
try
{
require('fs').unlinkSync('/Library/LaunchDaemons/' + name + '.plist');
require('fs').unlinkSync(service.plist);
require('fs').unlinkSync(servicePath);
}
catch (e)
@@ -2227,11 +2227,7 @@ function serviceManager()
require('fs').rmdirSync('/usr/local/mesh_services/' + name);
}
catch (e)
{}
}
else
{
throw ('Service: ' + name + ' does not exist');
}
}
else if(process.platform == 'freebsd')