-
Notifications
You must be signed in to change notification settings - Fork 3
/
monitor.js
38 lines (29 loc) · 908 Bytes
/
monitor.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
var
exec = require('child_process').exec
, opts = { timout : 10000 }
, actions = {
"wifiScan" : require('./bin/wifi_scan')
, "ifaceUp" : require('./bin/iface_up')
, "syncDisk" : require('./bin/sync_disk')
, "ifaceDown" : require('./bin/iface_down')
, "ifaceCheck" : require('./bin/iface_check')
, "deviceCheck" : require('./bin/device_check')
, "writeConfig" : require('./bin/write_config')
, "restartBlock" : require('./bin/restart_block')
, "restartSupplicant" : require('./bin/restart_supplicant')
, "init" : function() {
actions.deviceCheck();
}
}
;
function handleMessage(dat) {
if(!dat) { return; }
var action = dat.action || undefined;
if((actions[action]) && typeof actions[action] == "function") {
actions[action](dat.data || null);
}
else {
process.send({ 'error' : 'unknownAction', 'action' : action });
}
};
process.on('message', handleMessage);