summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEUcancER <root@euer.krebsco.de>2011-09-01 11:02:40 +0200
committerEUcancER <root@euer.krebsco.de>2011-09-01 11:02:40 +0200
commit37491fdc8cdb5349ab0377d3e528231d0cffe07a (patch)
tree68d08e8151905d42fe273fa6991f086059f0ebe5
parent9a7a3afcb949ebe807965d154c00836c462177ff (diff)
parent9198f99c6640ffc2a8de752b456a9c91f03edbcd (diff)
Merge branch 'master' of github.com:krebscode/painload
-rw-r--r--.gitignore1
-rwxr-xr-xgod/Reaktor/index37
-rwxr-xr-xgod/Reaktor/lib/listener.py50
-rwxr-xr-xnode/tools/latest-version19
l---------oncology/dpfhack_display1
5 files changed, 107 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index ee908b65..2c765648 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,7 @@ a.out
*.o
*.a
.svn/
+/god/Reaktor/tmp/
/bin/
/node/src
/node/out
diff --git a/god/Reaktor/index b/god/Reaktor/index
new file mode 100755
index 00000000..a2e6fe61
--- /dev/null
+++ b/god/Reaktor/index
@@ -0,0 +1,37 @@
+#! /bin/sh
+#
+# //god/Reaktor - listen to UDP events and forward them to IRC
+#
+# export host passwd printto to configure jsb-udp
+#
+set -euf
+cd $(readlink -f $(dirname $0))
+
+listener=$(readlink -f lib/listener.py)
+
+jsb_version=0.7.1.2
+distdir=jsb-$jsb_version.tar.gz
+
+host=${host-91.206.142.247}
+passwd=${passwd-h4x0r}
+printto=${printto-#shackspace}
+
+if ! test -x tmp/jsb-$jsb_version; then
+ mkdir -p tmp
+ cd tmp
+ curl -f http://jsonbot.googlecode.com/files/jsb-$jsb_version.tar.gz | tar zx
+ cd jsb-$jsb_version
+ bin/jsb-udp -s </dev/null
+ cd ../..
+fi
+cd tmp/jsb-$jsb_version
+
+# TODO only if it is not already configured properly
+sed -i '
+ s/^host *=.*/host="'$host'"/
+ s/^passwd *=.*/passwd="'$passwd'"/
+ s/^printto *=.*/printto="'$printto'"/
+' config/udp-send
+
+# TODO output modules: stderr, jsb-udp, remount-ro, ...
+PYTHONUNBUFFERED=y $listener | tee /dev/stderr | bin/jsb-udp
diff --git a/god/Reaktor/lib/listener.py b/god/Reaktor/lib/listener.py
new file mode 100755
index 00000000..9708d9bc
--- /dev/null
+++ b/god/Reaktor/lib/listener.py
@@ -0,0 +1,50 @@
+#! /usr/bin/env python2
+# coding=UTF-8
+
+location = 'shackspace'
+host = '0.0.0.0'
+port = 2342
+
+map = {
+ 'shackspace': {
+ 'device': {
+ 0: 'Licht0, Zickenzone; Fenster',
+ 1: 'Licht1, Sofaecke; Fenster',
+ 2: 'Licht2, Zickenzone; Ghetto',
+ 3: 'Licht3, Sofaecke; Ghetto',
+ 4: 'Licht4, Richtung Getränkelager',
+ 5: 'Licht5, Porschekonsole',
+ 6: 'Licht6, Tomatenecke',
+ 7: 'Licht7, Ghetto',
+ 10: 'Hauptschalter'
+ },
+ 'state': {
+ 0: 'aus',
+ 1: 'an',
+ 2: 'aus in T-10s'
+ },
+ '->': 'ist'
+ }
+}
+
+import socket
+from string import join
+from struct import unpack
+
+# create udp socket
+mysocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+
+# allow send/recieve from broacast address
+mysocket.setsockopt(socket.SOL_SOCKET,socket.SO_BROADCAST,1)
+
+# allow the socket to be re-used
+mysocket.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
+mysocket.bind((host, port))
+
+map = map[location]
+
+while True:
+ did, sid = unpack('BB', mysocket.recv(2))
+ device, state = map['device'][did], map['state'][sid]
+ arrow = map['->']
+ print join([device, arrow, state], ' ')
diff --git a/node/tools/latest-version b/node/tools/latest-version
new file mode 100755
index 00000000..b99276d5
--- /dev/null
+++ b/node/tools/latest-version
@@ -0,0 +1,19 @@
+#! /bin/sh
+#
+# //node/tools/latest-version - retrieve the latest node version from the IN
+#
+set -euf
+
+# cd //node
+cd $(readlink -f $(dirname $0)/..)
+
+# PATH prepend //util/bin
+export PATH="$PWD/../util/bin${PATH+:$PATH}"
+
+# TODO punani install executable: curl
+
+curl -fsS http://nodejs.org/ |
+ hrefs |
+ sed -n 's:.*node-v\([0-9.]\+\)\.tar\.gz:\1:p' |
+ sort |
+ tail -n 1
diff --git a/oncology/dpfhack_display b/oncology/dpfhack_display
deleted file mode 120000
index 9666b7bc..00000000
--- a/oncology/dpfhack_display
+++ /dev/null
@@ -1 +0,0 @@
-../submodules/github/makefu/dpfhack_display \ No newline at end of file