1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-17 16:53:13 +00:00

Updated PID handling for OpenBSD

This commit is contained in:
Bryan Roe
2021-08-31 13:38:54 -07:00
parent 294fc2f492
commit d4cdabef31
2 changed files with 61 additions and 21 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1196,6 +1196,22 @@ function serviceManager()
};
ret.pid = function pid()
{
if (this.OpenBSD)
{
// OpenBSD
try
{
var pid = require('fs').readFileSync('/var/run/' + this.name + '.pid');
return(parseInt(pid.toString().trim()));
}
catch(e)
{
return (-1);
}
}
else
{
// FreeBSD
var child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stdin.write("service " + this.name + " onestatus | awk '");
@@ -1208,6 +1224,7 @@ function serviceManager()
child.stdin.write('}\'\nexit\n');
child.waitExit();
return (parseInt(child.stdout.str.trim()));
}
};
ret.isMe = function isMe()
{
@@ -1256,10 +1273,22 @@ function serviceManager()
throw ('Error Restarting via execve()');
}
if (this.OpenBSD)
{
// OpenBSD
var child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stdin.write("rcctl restart " + this.name + "\nexit\n");
child.waitExit();
}
else
{
// FreeBSD
var child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stdin.write("service " + this.name + " onerestart\nexit\n");
child.waitExit();
}
};
ret.parameters = function parameters()
{
@@ -3119,6 +3148,17 @@ function serviceManager()
{
require('fs').unlinkSync(service.appLocation());
}
if (this.OpenBSD)
{
// OpenBSD specific
try
{
require('fs').unlinkSync(workingPath + name + '_loader');
}
catch(e)
{
}
}
if (this.pfSense)
{
try