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:
File diff suppressed because one or more lines are too long
@@ -1196,6 +1196,22 @@ function serviceManager()
|
|||||||
};
|
};
|
||||||
ret.pid = function pid()
|
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']);
|
var child = require('child_process').execFile('/bin/sh', ['sh']);
|
||||||
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
||||||
child.stdin.write("service " + this.name + " onestatus | awk '");
|
child.stdin.write("service " + this.name + " onestatus | awk '");
|
||||||
@@ -1208,6 +1224,7 @@ function serviceManager()
|
|||||||
child.stdin.write('}\'\nexit\n');
|
child.stdin.write('}\'\nexit\n');
|
||||||
child.waitExit();
|
child.waitExit();
|
||||||
return (parseInt(child.stdout.str.trim()));
|
return (parseInt(child.stdout.str.trim()));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
ret.isMe = function isMe()
|
ret.isMe = function isMe()
|
||||||
{
|
{
|
||||||
@@ -1256,10 +1273,22 @@ function serviceManager()
|
|||||||
throw ('Error Restarting via execve()');
|
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']);
|
var child = require('child_process').execFile('/bin/sh', ['sh']);
|
||||||
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
||||||
child.stdin.write("service " + this.name + " onerestart\nexit\n");
|
child.stdin.write("service " + this.name + " onerestart\nexit\n");
|
||||||
child.waitExit();
|
child.waitExit();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
ret.parameters = function parameters()
|
ret.parameters = function parameters()
|
||||||
{
|
{
|
||||||
@@ -3119,6 +3148,17 @@ function serviceManager()
|
|||||||
{
|
{
|
||||||
require('fs').unlinkSync(service.appLocation());
|
require('fs').unlinkSync(service.appLocation());
|
||||||
}
|
}
|
||||||
|
if (this.OpenBSD)
|
||||||
|
{
|
||||||
|
// OpenBSD specific
|
||||||
|
try
|
||||||
|
{
|
||||||
|
require('fs').unlinkSync(workingPath + name + '_loader');
|
||||||
|
}
|
||||||
|
catch(e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
if (this.pfSense)
|
if (this.pfSense)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
Reference in New Issue
Block a user