-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
49 lines (42 loc) · 1.12 KB
/
app.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Generated by CoffeeScript 1.6.3
var app, express;
express = require('express');
app = express();
app.use(express["static"](__dirname + '/public'));
app.port = 9898;
app.get('/webcam/:action', function(req, res) {
var actions, exec, raspberryOpts, sshclient, sys;
sys = require('sys');
exec = require('child_process').exec;
sshclient = require("sshclient");
actions = {
start: {
op: 'exec',
command: 'ssh [email protected] killall webcam',
canFail: true,
op: 'exec',
command: 'ssh [email protected] nohup webcam /home/paolo/.webcamrc &'
},
stop: {
op: 'exec',
command: 'ssh [email protected] killall webcam'
}
};
raspberryOpts = {
host: 'bitter.kicks-ass.org',
port: 22,
username: 'xbian',
password: 'raspberry',
debug: true,
console: console,
session: []
};
raspberryOpts.session.push(actions[req.params.action]);
return sshclient.session(raspberryOpts, function(error) {
if (error === null) {
return res.send("ok");
}
});
});
app.listen(app.port);
console.log("Node started on port " + app.port + " - yayy");