diff options
Diffstat (limited to 'god')
-rwxr-xr-x | god/Reaktor/index | 39 | ||||
-rwxr-xr-x | god/Reaktor/lib/listener.py | 50 | ||||
-rwxr-xr-x | god/licht | 136 | ||||
-rw-r--r-- | god/overlord/announce.mp3 | bin | 0 -> 71496 bytes | |||
-rwxr-xr-x | god/overlord/index | 27 |
5 files changed, 252 insertions, 0 deletions
diff --git a/god/Reaktor/index b/god/Reaktor/index new file mode 100755 index 00000000..a7840bb2 --- /dev/null +++ b/god/Reaktor/index @@ -0,0 +1,39 @@ +#! /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-#tincspasm} + +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 +cache="`cat config/udp-send`" +echo "$cache" | +sed ' + 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/god/licht b/god/licht new file mode 100755 index 00000000..12e4555f --- /dev/null +++ b/god/licht @@ -0,0 +1,136 @@ +#!/bin/bash +# +#SYNOPSIS +# //god/licht [options] [0/1] +#OPTIONS +# all - toggles all lights +# links - toggles all lights on the left hand side while looking towards the Auditorium +# rechts - toggles all lights on the right hand side while looking towards the Auditorium +# kuschel - toggles the lights in the pwnie corner +# software - toggles the software corner +# tische - toggles the lights on the window side of the long table +# porsche - toggles the lights on the window side where the porsche cockpit is +# ghetto - toggles the lights in the hallway +# 0-7 - toggles individual lights + +TOGGLE=`echo "$2" | sed -n '/^[0-1]/p'` +shorthelp() { + echo "Usage: $0 [OPTIONS] [0|1]" + echo "Toggle the lights in the shack." + +} +longhelp(){ + shorthelp + +cat <<EOF + +OPTIONS + all - toggles all lights + links - toggles all lights on the left hand side while looking towards the Auditorium + rechts - toggles all lights on the right hand side while looking towards the Auditorium + kuschel - toggles the lights in the pwnie corner + software - toggles the software corner + tische - toggles the lights on the window side of the long table + porsche - toggles the lights on the window side where the porsche cockpit is + ghetto - toggles the lights in the hallway + 0-7 - toggles individual lights +EOF +} +toggle() { + LAMPE=`echo "$1" | sed -n '/^[1-2]*[0-9]*[0-9]$/p' | xargs echo "obase=16;" | bc` + if ! [ "$LAMPE" -a "$TOGGLE" ];then + longhelp + exit 1 + fi + STRING="\\xA5\\x5A\\x$LAMPE\\x$TOGGLE" + if [ $# != 2 ] + then + longhelp + exit 1 + else + echo "Toggle light $LAMPE ($TOGGLE)" + printf "$STRING" | nc -u -w1 licht.shack 1337 + fi +} + +toggle_all() { + for i in `seq 0 7` + do + toggle $i $TOGGLE + done + wait +} + +kuschel(){ + for i in 0 2 + do + toggle $i $TOGGLE + done + wait +} + +software(){ + for i in 1 3 + do + toggle $i $TOGGLE + done + wait +} + +tische(){ + for i in 4 6 + do + toggle $i $TOGGLE + done + wait +} + +ghetto(){ + i=7 + toggle $i $TOGGLE +} + +porsche(){ + i=5 + toggle $i $TOGGLE +} + +case "$1" in + (--help) + if [ "$2" == "--verbose" ] + then longhelp + else shorthelp + fi + ;; + all) + toggle_all + ;; + kuschel) + kuschel + ;; + software) + software + ;; + links) + kuschel + software + ;; + rechts) + tische + porsche + ghetto + ;; + tische) + tische + ;; + porsche) + porsche + ;; + ghetto) + ghetto + ;; + *) + toggle "$@" + ;; +esac + diff --git a/god/overlord/announce.mp3 b/god/overlord/announce.mp3 Binary files differnew file mode 100644 index 00000000..23bca769 --- /dev/null +++ b/god/overlord/announce.mp3 diff --git a/god/overlord/index b/god/overlord/index new file mode 100755 index 00000000..ef0aebb3 --- /dev/null +++ b/god/overlord/index @@ -0,0 +1,27 @@ +#! /bin/sh +set -euf + +# cd // +cd $(dirname $(readlink -f $0))/../.. + +max=70 +step=10 +min=0 + +# fade-out streams +for i in `seq $max -$step $min`; do + amixer -q -c 0 -D hw:0 sset Front $i% + sleep 0.1 +done +streams/streams stop + +amixer -q -c 0 -D hw:0 sset Front $max% +mplayer god/overlord/announce.mp3 >/dev/null +espeak -v de -s 120 -a 900 "$*" + +# fade-in streams +streams/streams start +for i in `seq $min $step $max`; do + sleep 0.1 + amixer -q -c 0 -D hw:0 sset Front $i% +done |