mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-23 03:33:35 +00:00
Added startType property to getService() for Linux/systemd and FreeBSD
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -814,6 +814,19 @@ function serviceManager()
|
|||||||
{
|
{
|
||||||
throw ('Service: ' + name + ' not found');
|
throw ('Service: ' + name + ' not found');
|
||||||
}
|
}
|
||||||
|
Object.defineProperty(ret, "startType",
|
||||||
|
{
|
||||||
|
get: function ()
|
||||||
|
{
|
||||||
|
var child = require('child_process').execFile('/bin/sh', ['sh']);
|
||||||
|
child.stderr.on('data', function (c) { });
|
||||||
|
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
||||||
|
child.stdin.write('service ' + this.name + ' rcvar | grep _enable= | awk \'{ a=split($0, b, "\\""); if(b[2]=="YES") { print "YES"; } }\'\nexit\n');
|
||||||
|
child.waitExit();
|
||||||
|
return (child.stdout.str.trim() == '' ? 'DEMAND_START' : 'AUTO_START');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
ret.description = function description()
|
ret.description = function description()
|
||||||
{
|
{
|
||||||
var child = require('child_process').execFile('/bin/sh', ['sh']);
|
var child = require('child_process').execFile('/bin/sh', ['sh']);
|
||||||
@@ -1107,9 +1120,28 @@ function serviceManager()
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'systemd':
|
case 'systemd':
|
||||||
if (require('fs').existsSync('/lib/systemd/system/' + name + '.service') ||
|
if (require('fs').existsSync('/lib/systemd/system/' + name + '.service'))
|
||||||
require('fs').existsSync('/usr/lib/systemd/system/' + name + '.service'))
|
|
||||||
{
|
{
|
||||||
|
ret.conf = '/lib/systemd/system/' + name + '.service';
|
||||||
|
}
|
||||||
|
else if (require('fs').existsSync('/usr/lib/systemd/system/' + name + '.service'))
|
||||||
|
{
|
||||||
|
ret.conf = '/usr/lib/systemd/system/' + name + '.service';
|
||||||
|
}
|
||||||
|
if (ret.conf)
|
||||||
|
{
|
||||||
|
Object.defineProperty(ret, "startType",
|
||||||
|
{
|
||||||
|
get: function ()
|
||||||
|
{
|
||||||
|
var child = require('child_process').execFile('/bin/sh', ['sh']);
|
||||||
|
child.stderr.on('data', function (c) { });
|
||||||
|
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
||||||
|
child.stdin.write('systemctl status ' + this.name + ' | grep Loaded: | awk \'{ a=split($0, b, ";"); for(c=1;c<=a;++c) { if(b[c]=="enabled" || b[c]==" enabled") { print "true"; } } }\'\nexit\n');
|
||||||
|
child.waitExit();
|
||||||
|
return (child.stdout.str.trim() == '' ? 'DEMAND_START' : 'AUTO_START');
|
||||||
|
}
|
||||||
|
});
|
||||||
ret.description = function description()
|
ret.description = function description()
|
||||||
{
|
{
|
||||||
var child = require('child_process').execFile('/bin/sh', ['sh']);
|
var child = require('child_process').execFile('/bin/sh', ['sh']);
|
||||||
|
|||||||
Reference in New Issue
Block a user