-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.coffee
38 lines (28 loc) · 904 Bytes
/
app.coffee
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
express = require 'express'
app = express()
app.use express.static(__dirname + '/public')
app.port = 9898
app.get '/webcam/:action', (req, res)->
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]
sshclient.session raspberryOpts, (error)->
if error is null
res.send "ok"
app.listen app.port
console.log "Node started on port "+app.port+" - yayy"