1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-15 15:53:55 +00:00

Added work-around if linux-dbus isn't updated

This commit is contained in:
Bryan Roe
2019-08-22 17:26:52 -07:00
parent fbd67d2c9c
commit 5e006bc0a9
2 changed files with 19 additions and 1 deletions

View File

@@ -221,3 +221,15 @@ function Toaster()
}
module.exports = new Toaster();
if (process.platform == 'linux' && !require('linux-dbus').hasService)
{
require('linux-dbus').hasService = function hasService(name)
{
var child = require('child_process').execFile('/bin/sh', ['sh']);
child.stderr.str = ''; child.stderr.on('data', function (c) { this.str += c.toString(); });
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stdin.write('cat /usr/share/dbus-1/services/*.service | grep "' + name + '" | awk -F= \'{ if( $2=="' + name + '" ) { print $2; } }\'\nexit\n');
child.waitExit();
return (child.stdout.str.trim() != '');
};
}