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:
File diff suppressed because one or more lines are too long
@@ -194,7 +194,14 @@ function uninstallService(params)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
svc.stop();
|
if (process.platform == 'darwin')
|
||||||
|
{
|
||||||
|
svc.unload();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
svc.stop();
|
||||||
|
}
|
||||||
process.stdout.write(' [STOPPED]\n');
|
process.stdout.write(' [STOPPED]\n');
|
||||||
uninstallService2(params);
|
uninstallService2(params);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,6 +151,7 @@ if (process.platform == 'darwin')
|
|||||||
var files = require('fs').readdirSync(folder);
|
var files = require('fs').readdirSync(folder);
|
||||||
for (var file in files)
|
for (var file in files)
|
||||||
{
|
{
|
||||||
|
if (!files[file].endsWith('.plist')) { continue; }
|
||||||
var child = require('child_process').execFile('/bin/sh', ['sh']);
|
var child = require('child_process').execFile('/bin/sh', ['sh']);
|
||||||
child.stdout.str = '';
|
child.stdout.str = '';
|
||||||
child.stdout.on('data', function (chunk) { this.str += chunk.toString(); });
|
child.stdout.on('data', function (chunk) { this.str += chunk.toString(); });
|
||||||
@@ -411,7 +412,14 @@ if (process.platform == 'darwin')
|
|||||||
child.stderr.on('data', function (chunk) { this.str += chunk.toString(); });
|
child.stderr.on('data', function (chunk) { this.str += chunk.toString(); });
|
||||||
if (useBootout)
|
if (useBootout)
|
||||||
{
|
{
|
||||||
child.stdin.write('launchctl bootout gui/' + uid + ' ' + this.plist + '\nexit\n');
|
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
|
else
|
||||||
{
|
{
|
||||||
@@ -2203,35 +2211,23 @@ function serviceManager()
|
|||||||
}
|
}
|
||||||
else if(process.platform == 'darwin')
|
else if(process.platform == 'darwin')
|
||||||
{
|
{
|
||||||
if (require('fs').existsSync('/Library/LaunchDaemons/' + name + '.plist'))
|
service.unload();
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var child = require('child_process').execFile('/bin/sh', ['sh']);
|
require('fs').unlinkSync(service.plist);
|
||||||
child.stdout.on('data', function (chunk) { });
|
require('fs').unlinkSync(servicePath);
|
||||||
child.stdin.write('launchctl stop ' + name + '\n');
|
|
||||||
child.stdin.write('launchctl unload /Library/LaunchDaemons/' + name + '.plist\n');
|
|
||||||
child.stdin.write('exit\n');
|
|
||||||
child.waitExit();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
require('fs').unlinkSync('/Library/LaunchDaemons/' + name + '.plist');
|
|
||||||
require('fs').unlinkSync(servicePath);
|
|
||||||
}
|
|
||||||
catch(e)
|
|
||||||
{
|
|
||||||
throw ('Error uninstalling service: ' + name + ' => ' + e);
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
require('fs').rmdirSync('/usr/local/mesh_services/' + name);
|
|
||||||
}
|
|
||||||
catch(e)
|
|
||||||
{}
|
|
||||||
}
|
}
|
||||||
else
|
catch (e)
|
||||||
|
{
|
||||||
|
throw ('Error uninstalling service: ' + name + ' => ' + e);
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
require('fs').rmdirSync('/usr/local/mesh_services/' + name);
|
||||||
|
}
|
||||||
|
catch (e)
|
||||||
{
|
{
|
||||||
throw ('Service: ' + name + ' does not exist');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(process.platform == 'freebsd')
|
else if(process.platform == 'freebsd')
|
||||||
|
|||||||
Reference in New Issue
Block a user