initial service integration

This commit is contained in:
2021-04-14 23:51:08 +02:00
parent 06c6d4540d
commit 63249de99c
12 changed files with 4121 additions and 8 deletions

11
services/package.json Normal file
View File

@@ -0,0 +1,11 @@
{
"name": "org.webosbrew.hbchannel.service",
"version": "1.0.0",
"description": "Homebrew Channel Service",
"main": "service.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "David Buchanan",
"license": "MIT"
}

4
services/run-js-service Executable file
View File

@@ -0,0 +1,4 @@
#! /bin/sh
# :^)
eval "$(cat /usr/bin/run-js-service | sed 's/^thirdparty_jail=.*/thirdparty_jail=off/')"

67
services/service.js Executable file
View File

@@ -0,0 +1,67 @@
var pkgInfo = require('./package.json');
var Service = require('webos-service');
var child_process = require('child_process')
// Register com.yourdomain.@DIR@.service, on both buses
var service = new Service(pkgInfo.name);
service.register("checkRoot", function (message) {
message.respond({
returnValue: process.getuid() === 0,
});
});
service.register("exec", function (message) {
child_process.exec(message.payload.command, {encoding: "buffer"}, function (error, stdout, stderr) {
message.respond({
returnValue: !error,
error: error,
stdoutString: stdout.toString(),
stdoutBytes: stdout.toString("base64"),
stderrString: stderr.toString(),
stderrBytes: stderr.toString("base64")
});
});
});
service.register("spawn", function (message) {
var proc = child_process.spawn("/bin/sh", ["-c", message.payload.command]);
proc.stdout.on('data', function (data) {
message.respond({
event: "stdoutData",
stdoutString: data.toString(),
stdoutBytes: data.toString("base64")
});
});
proc.stderr.on('data', function (data) {
message.respond({
event: "stderrData",
stderrString: data.toString(),
stderrBytes: data.toString("base64")
});
});
proc.on('close', function (code) {
message.respond({
event: "close",
closeCode: code
});
});
proc.on('exit', function (code) {
message.respond({
event: "exit",
exitCode: code
});
});
});
// stub service that emulates luna://com.webos.service.sm/license/apps/getDrmStatus
service.register("getDrmStatus", function (message) {
message.respond({
"appId": message.payload.appId,
"drmType": "NCG DRM",
"installBasePath": "/media/cryptofs",
"returnValue": true,
"isTimeLimited": false
});
});

9
services/services.json Normal file
View File

@@ -0,0 +1,9 @@
{
"id": "org.webosbrew.hbchannel.service",
"description": "Homebrew Channel Service",
"services": [
{
"name": "org.webosbrew.hbchannel.service"
}
]
}