initial service integration
This commit is contained in:
11
services/package.json
Normal file
11
services/package.json
Normal 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
4
services/run-js-service
Executable 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
67
services/service.js
Executable 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
9
services/services.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"id": "org.webosbrew.hbchannel.service",
|
||||
"description": "Homebrew Channel Service",
|
||||
"services": [
|
||||
{
|
||||
"name": "org.webosbrew.hbchannel.service"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user