-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.js
executable file
·30 lines (23 loc) · 1.12 KB
/
commands.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"use strict";
(function (exports) {
exports.init = function init(api) {
const child_process = require('child_process');
const commandsById = {};
/** commands **/
const allCommands = [
{ id: 'kodi', name: 'Start Kodi', command: 'su -c startkodi - pi' },
{ id: 'chmusb', name: 'Chmod Usb', command: 'chmod -R a+w /mnt/usb/' },
{ id: 'chmpigod', name: 'Chmod PiGod src', command: 'chmod -R a+w /home/pi/pigod/src/' },
{ id: 'reboot', name: 'Reboot', command: 'sudo reboot -f' },
{ id: 'rescan_minidlna', name: 'Rescan MiniDLNA', command: 'sudo minidlna -R; sudo service minidlna restart' }
];
allCommands.$_idField = 'id';
allCommands.forEach(function (cmd) { commandsById[cmd.id] = cmd; });
api.pubsub.publish('commands', allCommands);
api.pubsub.subscribe('execCommand', function (data) {
if (data.id && commandsById[data.id]) {
child_process.exec(commandsById[data.id].command);
}
});
}
})(exports);