From b2bdf4e508bd6c58445de4ad302c656a8cf2e983 Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 19 Nov 2013 08:38:38 +0100 Subject: cholerab-live -> graveyard --- .graveyard/cholerab-live/README | 6 ++ .graveyard/cholerab-live/chol_net.py | 82 ++++++++++++++++++++ .graveyard/cholerab-live/chol_net.pyc | Bin 0 -> 4361 bytes .graveyard/cholerab-live/cholerab.py | 36 +++++++++ .graveyard/cholerab-live/live.sh | 88 ++++++++++++++++++++++ .graveyard/cholerab-live/makefu/README | 6 ++ .graveyard/cholerab-live/makefu/chol_net.py | 82 ++++++++++++++++++++ .graveyard/cholerab-live/makefu/cholerab.py | 36 +++++++++ .graveyard/cholerab-live/makefu/view.py | 112 ++++++++++++++++++++++++++++ .graveyard/cholerab-live/ttycnser.sh | 27 +++++++ .graveyard/cholerab-live/view.py | 112 ++++++++++++++++++++++++++++ 11 files changed, 587 insertions(+) create mode 100644 .graveyard/cholerab-live/README create mode 100644 .graveyard/cholerab-live/chol_net.py create mode 100644 .graveyard/cholerab-live/chol_net.pyc create mode 100755 .graveyard/cholerab-live/cholerab.py create mode 100755 .graveyard/cholerab-live/live.sh create mode 100644 .graveyard/cholerab-live/makefu/README create mode 100644 .graveyard/cholerab-live/makefu/chol_net.py create mode 100755 .graveyard/cholerab-live/makefu/cholerab.py create mode 100644 .graveyard/cholerab-live/makefu/view.py create mode 100755 .graveyard/cholerab-live/ttycnser.sh create mode 100644 .graveyard/cholerab-live/view.py (limited to '.graveyard') diff --git a/.graveyard/cholerab-live/README b/.graveyard/cholerab-live/README new file mode 100644 index 00000000..b778b98c --- /dev/null +++ b/.graveyard/cholerab-live/README @@ -0,0 +1,6 @@ + +view.py: contains view classes for cholerab +cholerab.py: main file + +start with : +python cholerab.py diff --git a/.graveyard/cholerab-live/chol_net.py b/.graveyard/cholerab-live/chol_net.py new file mode 100644 index 00000000..ee0f5378 --- /dev/null +++ b/.graveyard/cholerab-live/chol_net.py @@ -0,0 +1,82 @@ +from socket import socket, AF_INET,SOCK_DGRAM,IPPROTO_UDP,SOL_SOCKET,SO_REUSEADDR,IP_MULTICAST_TTL,IP_MULTICAST_LOOP,INADDR_ANY,inet_aton,IP_ADD_MEMBERSHIP,IPPROTO_IP +import struct +import threading +import logging +log = None +from select import select +GROUP = '224.110.42.23' +PORT = 42023 +log = logging.getLogger('CholerabNet') +class CholerabMulicastNet(threading.Thread): + def __init__(self,cholerab,group=GROUP,port=PORT): + threading.Thread.__init__(self) + self.cholerab=cholerab + self.group=group + self.port=port + self.initSocket() + def send_char(self,x,y,char): + """ translates given params into network message """ + self.send_mc("%s %d %d" %(str(ord(char)),x,y)) + def send_mc(self,arg): + """ Sends message via multicast""" + try: + log.debug("Sending '%s' to %s:%d" % (arg,self.group,self.port)) + self.ignore_next += 1# we need this to work together correctly with reused sockets + self.s.sendto("%s" % arg,0,(self.group,self.port)) + except Exception ,e: + self.ignore_next -=1 + log.error("IN send_mc:%s"%str(e)) + + def initSocket (self,rcv=1): + ''' Initializes a Multicast socket ''' + host = '' + log.debug("Setting up Multicast Socket") + self.s = socket(AF_INET,SOCK_DGRAM, IPPROTO_UDP) + self.s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) + self.s.setsockopt(IPPROTO_IP, IP_MULTICAST_TTL, 32) + self.s.setsockopt(IPPROTO_IP,IP_MULTICAST_LOOP,1) # we do not want our own packets to be replayed + if rcv==1: + log.debug("Configuring for Read AND Write") + self.s.bind((host,PORT)) + mreq = struct.pack("4sl", inet_aton(GROUP), INADDR_ANY) + self.s.setsockopt(IPPROTO_IP,IP_ADD_MEMBERSHIP,mreq) + def run(self): + self.running = 1 + self.ignore_next = 0 + while self.running: + # break if we do not want to loop on + ready,output,exception = select([self.s],[],[],1) # try every second + for r in ready: + if r == self.s: + log.debug(str(self.ignore_next)) + (data,addr) = self.s.recvfrom(1024) + if not self.ignore_next: + log.debug("Received Data from %s, data %s"%(str(addr),str(data))) + self.receive_net(addr,data) + else: + self.ignore_next -= 1 + + def send_stupid(self,addr): + """ sends YOU ARE MADE OF STUPID to the right host """ + #TODO implement me + pass + + def receive_net(self,addr,data): + """ resolves which nick sent the message + TODO handle user resolution in mulicast """ + try: + address,port = addr + arr = str(data).split() + char = arr[0] + x = arr[1] + y = arr[2] + self.cholerab.write_char(int(x),int(y),chr(int(char))) + except Exception, e: + log.error("Triggered YOU ARE MADE OF STUPID: %s" % str(e)) + self.send_stupid(addr) + + def stop(self): + ''' + stops the whole treading stuff gracefully + ''' + self.running=0 diff --git a/.graveyard/cholerab-live/chol_net.pyc b/.graveyard/cholerab-live/chol_net.pyc new file mode 100644 index 00000000..0694ad6d Binary files /dev/null and b/.graveyard/cholerab-live/chol_net.pyc differ diff --git a/.graveyard/cholerab-live/cholerab.py b/.graveyard/cholerab-live/cholerab.py new file mode 100755 index 00000000..eb9e66df --- /dev/null +++ b/.graveyard/cholerab-live/cholerab.py @@ -0,0 +1,36 @@ +#!/usr/bin/python2 +# -*- coding: utf-8 -*- +import curses,time +from view import CursesView +from chol_net import CholerabMulicastNet +import logging +logging.basicConfig(filename='here.log',level=logging.DEBUG) +log = logging.getLogger('main') +class Cholerab: + def __init__(self): + self.view = CursesView(cholerab=self) + self.transport = CholerabMulicastNet(cholerab=self) + def send_char(self,x,y,char): + log.info("Sending %s at (%d,%d) to connected peers" %(char,x,y)) + self.transport.send_char(x,y,char) + + def write_char(self,x,y,char): + log.info("Writing %s at (%d,%d) to view" %(char,x,y)) + self.view.write_char(x,y,char,user=2) + def stop(self): + self.view.stop() + self.transport.stop() + def main(self): + self.view.start() + self.transport.start() + self.view.join() + #after view dies, kill the transport as well + self.transport.stop() + self.transport.join() +def main(): + log.debug('started main') + chol = Cholerab() + chol.main() + +if __name__ == "__main__": + main() diff --git a/.graveyard/cholerab-live/live.sh b/.graveyard/cholerab-live/live.sh new file mode 100755 index 00000000..62a2c3cf --- /dev/null +++ b/.graveyard/cholerab-live/live.sh @@ -0,0 +1,88 @@ +#! /bin/sh +set -euf +stty cbreak -echo + +go() { + state=$1 + wr 7 + wr " " >&2 + wr "state=$state" >&2 + wr 8 + $1 +} + +rd() { + dd bs=1 count=1 2>/dev/null +} + +bufrd() { + buf="`rd`" + bufinfowr +} + +bufrda() { + buf="$buf`rd`" + bufinfowr +} + +bufinfowr() { + wr 7 + wr " " >&2 + wr " " >&2 + case "$buf" in + () wr '^[' >&2;; + (*) wr "$buf" >&2;; + esac + wr "`wr "$buf" | xxd -p`" >&2 + wr 8 +} + +wr() { + echo -n "$1" +} + +C0="`echo C0 | xxd -r -p`"; DF="`echo DF | xxd -r -p`" +E0="`echo E0 | xxd -r -p`"; EF="`echo EF | xxd -r -p`" +F0="`echo F0 | xxd -r -p`"; F7="`echo F7 | xxd -r -p`" +S() { + bufrd + case "$buf" in + () go ESC;; + () wr ' '; go S;; + ([$C0-$DF]) go U1;; + ([$E0-$EF]) go U2;; + ([$F0-$F7]) go U3;; + (*) wr "$buf"; go S;; + esac +} + +U1() { buf="$buf`rd`"; wr "$buf"; go S; } +U2() { buf="$buf`rd`"; go U1; } +U3() { buf="$buf`rd`"; go U2; } + + +ESC() { + bufrda + case "$buf" in + ('[') go ESC_OSQRB;; + (*) + wr '^[' + go S + ;; + esac +} + +ESC_OSQRB() { + bufrda + case "$buf" in + (''|''|''|'') wr "$buf"; go S;; + (*) + wr '^[[' + go S + ;; + esac +} + + +wr 'c' +go S diff --git a/.graveyard/cholerab-live/makefu/README b/.graveyard/cholerab-live/makefu/README new file mode 100644 index 00000000..b778b98c --- /dev/null +++ b/.graveyard/cholerab-live/makefu/README @@ -0,0 +1,6 @@ + +view.py: contains view classes for cholerab +cholerab.py: main file + +start with : +python cholerab.py diff --git a/.graveyard/cholerab-live/makefu/chol_net.py b/.graveyard/cholerab-live/makefu/chol_net.py new file mode 100644 index 00000000..ee0f5378 --- /dev/null +++ b/.graveyard/cholerab-live/makefu/chol_net.py @@ -0,0 +1,82 @@ +from socket import socket, AF_INET,SOCK_DGRAM,IPPROTO_UDP,SOL_SOCKET,SO_REUSEADDR,IP_MULTICAST_TTL,IP_MULTICAST_LOOP,INADDR_ANY,inet_aton,IP_ADD_MEMBERSHIP,IPPROTO_IP +import struct +import threading +import logging +log = None +from select import select +GROUP = '224.110.42.23' +PORT = 42023 +log = logging.getLogger('CholerabNet') +class CholerabMulicastNet(threading.Thread): + def __init__(self,cholerab,group=GROUP,port=PORT): + threading.Thread.__init__(self) + self.cholerab=cholerab + self.group=group + self.port=port + self.initSocket() + def send_char(self,x,y,char): + """ translates given params into network message """ + self.send_mc("%s %d %d" %(str(ord(char)),x,y)) + def send_mc(self,arg): + """ Sends message via multicast""" + try: + log.debug("Sending '%s' to %s:%d" % (arg,self.group,self.port)) + self.ignore_next += 1# we need this to work together correctly with reused sockets + self.s.sendto("%s" % arg,0,(self.group,self.port)) + except Exception ,e: + self.ignore_next -=1 + log.error("IN send_mc:%s"%str(e)) + + def initSocket (self,rcv=1): + ''' Initializes a Multicast socket ''' + host = '' + log.debug("Setting up Multicast Socket") + self.s = socket(AF_INET,SOCK_DGRAM, IPPROTO_UDP) + self.s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) + self.s.setsockopt(IPPROTO_IP, IP_MULTICAST_TTL, 32) + self.s.setsockopt(IPPROTO_IP,IP_MULTICAST_LOOP,1) # we do not want our own packets to be replayed + if rcv==1: + log.debug("Configuring for Read AND Write") + self.s.bind((host,PORT)) + mreq = struct.pack("4sl", inet_aton(GROUP), INADDR_ANY) + self.s.setsockopt(IPPROTO_IP,IP_ADD_MEMBERSHIP,mreq) + def run(self): + self.running = 1 + self.ignore_next = 0 + while self.running: + # break if we do not want to loop on + ready,output,exception = select([self.s],[],[],1) # try every second + for r in ready: + if r == self.s: + log.debug(str(self.ignore_next)) + (data,addr) = self.s.recvfrom(1024) + if not self.ignore_next: + log.debug("Received Data from %s, data %s"%(str(addr),str(data))) + self.receive_net(addr,data) + else: + self.ignore_next -= 1 + + def send_stupid(self,addr): + """ sends YOU ARE MADE OF STUPID to the right host """ + #TODO implement me + pass + + def receive_net(self,addr,data): + """ resolves which nick sent the message + TODO handle user resolution in mulicast """ + try: + address,port = addr + arr = str(data).split() + char = arr[0] + x = arr[1] + y = arr[2] + self.cholerab.write_char(int(x),int(y),chr(int(char))) + except Exception, e: + log.error("Triggered YOU ARE MADE OF STUPID: %s" % str(e)) + self.send_stupid(addr) + + def stop(self): + ''' + stops the whole treading stuff gracefully + ''' + self.running=0 diff --git a/.graveyard/cholerab-live/makefu/cholerab.py b/.graveyard/cholerab-live/makefu/cholerab.py new file mode 100755 index 00000000..eb9e66df --- /dev/null +++ b/.graveyard/cholerab-live/makefu/cholerab.py @@ -0,0 +1,36 @@ +#!/usr/bin/python2 +# -*- coding: utf-8 -*- +import curses,time +from view import CursesView +from chol_net import CholerabMulicastNet +import logging +logging.basicConfig(filename='here.log',level=logging.DEBUG) +log = logging.getLogger('main') +class Cholerab: + def __init__(self): + self.view = CursesView(cholerab=self) + self.transport = CholerabMulicastNet(cholerab=self) + def send_char(self,x,y,char): + log.info("Sending %s at (%d,%d) to connected peers" %(char,x,y)) + self.transport.send_char(x,y,char) + + def write_char(self,x,y,char): + log.info("Writing %s at (%d,%d) to view" %(char,x,y)) + self.view.write_char(x,y,char,user=2) + def stop(self): + self.view.stop() + self.transport.stop() + def main(self): + self.view.start() + self.transport.start() + self.view.join() + #after view dies, kill the transport as well + self.transport.stop() + self.transport.join() +def main(): + log.debug('started main') + chol = Cholerab() + chol.main() + +if __name__ == "__main__": + main() diff --git a/.graveyard/cholerab-live/makefu/view.py b/.graveyard/cholerab-live/makefu/view.py new file mode 100644 index 00000000..6a75f655 --- /dev/null +++ b/.graveyard/cholerab-live/makefu/view.py @@ -0,0 +1,112 @@ +#!/usr/bin/python2 + +from curses import * +import socket +import threading +import logging +log = logging.getLogger('cholerab-curses') + +class CursesView(threading.Thread): + def addch(self,char): + """ + adds a char at the current cursor position + abstraction to the curses win.addch() + """ + try: self.win.addch(char) + except: pass + self.cholerab.send_char(self.x,self.y,chr(char)) + def stop(self): + #TODO setting back the whole terminal currently does not work correctly, fix me harder + self.running = False + self.clear() + self.win.refresh() + nocbreak(); self.scr.keypad(0); echo() + #endwin() + + def run(self): + """ + input loop + + TODO add Unicode Input Support + """ + self.running = True + def try_move(x,y): + if x >= self.width: x = 0;y = y+1 + if x < 0 : x = self.width-1; y= y-1 + if y >= self.height : x = x+1;y = 0 + if y < 0 : x = x-1; y = self.height-1 + self.win.move(y,x); return x,y + + while self.running: + c = self.scr.getch() #get_char(self.scr) + #TODO UTF8 here, get_wch not yet implemented + log.debug("Pressed : %d" % c) + if c == KEY_LEFT : self.x -=1 + elif c == KEY_RIGHT : self.x +=1 + elif c == KEY_UP : self.y -=1 + elif c == KEY_DOWN : self.y +=1 + elif c == ord('q') : self.stop() + elif c == 127 or c == KEY_BACKSPACE: + log.info('backspace pressed') + self.x -=1; + self.x,self.y = try_move(self.x,self.y) + self.addch(ord(' ')) + elif c == ord('\n'): + log.info('enter pressed') + self.y +=1; + self.x,self.y = try_move(self.x,self.y) + else : + self.addch(c) + self.x +=1 + self.x,self.y = try_move(self.x,self.y) + self.refresh() + + def write_char(self,x,y,char,user=1): + user = user % 3 + 1 + self.win.addch(y,x,char,color_pair(user)) + self.win.move(self.y,self.x) + self.refresh() + def write_str(self,x,y,string,user=1): + self.win.addstr(y,x,string,color_pair(user)) + self.win.move(self.y,self.x) + self.refresh() + def refresh(self): + self.scr.refresh() + self.win.refresh() + def clear(self): + self.win.clear() + pass + def write_field(self,ar): + """ + writes the whole field with given 2-dimensional array + """ + self.clear() + pass + + def __init__(self,height=24,width=80,cholerab=None,scr=None): + # TODO handle sessions somehow + if scr: + self.scr = scr + else: + self.scr = initscr() + start_color() + init_pair(1,COLOR_WHITE,COLOR_BLACK) + init_pair(2,COLOR_RED,COLOR_BLACK) + init_pair(3,COLOR_GREEN,COLOR_BLACK) + init_pair(3,COLOR_CYAN,COLOR_BLACK) + threading.Thread.__init__(self) + self.cholerab = cholerab + + noecho() + cbreak() + self.scr.keypad(1) + try: curs_set(2) + except: pass # go home with your non-standard terminals! + + begin_x = 0;begin_y = 0 + self.height = height + self.width = width + self.x = 0 ; self.y = 0 + + self.win = newwin(height,width,begin_y,begin_x) + self.clear() diff --git a/.graveyard/cholerab-live/ttycnser.sh b/.graveyard/cholerab-live/ttycnser.sh new file mode 100755 index 00000000..0972dbbb --- /dev/null +++ b/.graveyard/cholerab-live/ttycnser.sh @@ -0,0 +1,27 @@ +#! /bin/sh +set -euf + +tty="${TMPDIR-/tmp}/ttycnser.$LOGNAME.tty" + +case "${mode-server}" in + (server) + host=0.0.0.0 + port=8080 + export mode=client + echo "ttycnser @ $host $port" >&2 + exec tcpserver $host $port "$0" + ;; + (client) + line="`read line && echo "$line"`" + echo -n '7>>>> '"$line"'8' > "$tty" + ;; + (install) + # TODO tell the user to do something like + # PROMPT_COMMAND="`mode=install ~/p/krebscode/painload/cholerab/ttycnser`" + echo "ln -snf '`tty`' '$tty'" + ;; + (*) + echo 'Error 1: You are made of stupid!' >&2 + exit 23 + ;; +esac diff --git a/.graveyard/cholerab-live/view.py b/.graveyard/cholerab-live/view.py new file mode 100644 index 00000000..6a75f655 --- /dev/null +++ b/.graveyard/cholerab-live/view.py @@ -0,0 +1,112 @@ +#!/usr/bin/python2 + +from curses import * +import socket +import threading +import logging +log = logging.getLogger('cholerab-curses') + +class CursesView(threading.Thread): + def addch(self,char): + """ + adds a char at the current cursor position + abstraction to the curses win.addch() + """ + try: self.win.addch(char) + except: pass + self.cholerab.send_char(self.x,self.y,chr(char)) + def stop(self): + #TODO setting back the whole terminal currently does not work correctly, fix me harder + self.running = False + self.clear() + self.win.refresh() + nocbreak(); self.scr.keypad(0); echo() + #endwin() + + def run(self): + """ + input loop + + TODO add Unicode Input Support + """ + self.running = True + def try_move(x,y): + if x >= self.width: x = 0;y = y+1 + if x < 0 : x = self.width-1; y= y-1 + if y >= self.height : x = x+1;y = 0 + if y < 0 : x = x-1; y = self.height-1 + self.win.move(y,x); return x,y + + while self.running: + c = self.scr.getch() #get_char(self.scr) + #TODO UTF8 here, get_wch not yet implemented + log.debug("Pressed : %d" % c) + if c == KEY_LEFT : self.x -=1 + elif c == KEY_RIGHT : self.x +=1 + elif c == KEY_UP : self.y -=1 + elif c == KEY_DOWN : self.y +=1 + elif c == ord('q') : self.stop() + elif c == 127 or c == KEY_BACKSPACE: + log.info('backspace pressed') + self.x -=1; + self.x,self.y = try_move(self.x,self.y) + self.addch(ord(' ')) + elif c == ord('\n'): + log.info('enter pressed') + self.y +=1; + self.x,self.y = try_move(self.x,self.y) + else : + self.addch(c) + self.x +=1 + self.x,self.y = try_move(self.x,self.y) + self.refresh() + + def write_char(self,x,y,char,user=1): + user = user % 3 + 1 + self.win.addch(y,x,char,color_pair(user)) + self.win.move(self.y,self.x) + self.refresh() + def write_str(self,x,y,string,user=1): + self.win.addstr(y,x,string,color_pair(user)) + self.win.move(self.y,self.x) + self.refresh() + def refresh(self): + self.scr.refresh() + self.win.refresh() + def clear(self): + self.win.clear() + pass + def write_field(self,ar): + """ + writes the whole field with given 2-dimensional array + """ + self.clear() + pass + + def __init__(self,height=24,width=80,cholerab=None,scr=None): + # TODO handle sessions somehow + if scr: + self.scr = scr + else: + self.scr = initscr() + start_color() + init_pair(1,COLOR_WHITE,COLOR_BLACK) + init_pair(2,COLOR_RED,COLOR_BLACK) + init_pair(3,COLOR_GREEN,COLOR_BLACK) + init_pair(3,COLOR_CYAN,COLOR_BLACK) + threading.Thread.__init__(self) + self.cholerab = cholerab + + noecho() + cbreak() + self.scr.keypad(1) + try: curs_set(2) + except: pass # go home with your non-standard terminals! + + begin_x = 0;begin_y = 0 + self.height = height + self.width = width + self.x = 0 ; self.y = 0 + + self.win = newwin(height,width,begin_y,begin_x) + self.clear() -- cgit v1.2.3 From 022d115bdae70e588b4639da5b3037845fab9fe6 Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 19 Nov 2013 08:41:07 +0100 Subject: temper -> graveyard --- .graveyard/temper/.gitignore | 1 + .graveyard/temper/99-tempsensor.rules | 1 + .graveyard/temper/Makefile | 20 +++ .graveyard/temper/collectd-temper.sh | 9 ++ .graveyard/temper/temper.c | 277 ++++++++++++++++++++++++++++++++++ .graveyard/temper/temper.h | 39 +++++ 6 files changed, 347 insertions(+) create mode 100644 .graveyard/temper/.gitignore create mode 100644 .graveyard/temper/99-tempsensor.rules create mode 100644 .graveyard/temper/Makefile create mode 100755 .graveyard/temper/collectd-temper.sh create mode 100644 .graveyard/temper/temper.c create mode 100644 .graveyard/temper/temper.h (limited to '.graveyard') diff --git a/.graveyard/temper/.gitignore b/.graveyard/temper/.gitignore new file mode 100644 index 00000000..7e50641a --- /dev/null +++ b/.graveyard/temper/.gitignore @@ -0,0 +1 @@ +temper diff --git a/.graveyard/temper/99-tempsensor.rules b/.graveyard/temper/99-tempsensor.rules new file mode 100644 index 00000000..441a469e --- /dev/null +++ b/.graveyard/temper/99-tempsensor.rules @@ -0,0 +1 @@ +SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="1130", ATTRS{idProduct}=="660c", MODE="666" diff --git a/.graveyard/temper/Makefile b/.graveyard/temper/Makefile new file mode 100644 index 00000000..d18ad710 --- /dev/null +++ b/.graveyard/temper/Makefile @@ -0,0 +1,20 @@ + +all: infest +infest: temper rules-install +CFLAGS = -O2 -Wall -DDEBUG + +temper: temper.c + ${CC} -DUNIT_TEST -o $@ $^ -lusb + chmod +s temper + #cp -a temper /usr/bin +clean: + rm -f temper *.o + +rules-install: /etc/udev/rules.d/99-tempsensor.rules +/etc/udev/rules.d/99-tempsensor.rules: + cp 99-tempsensor.rules /etc/udev/rules.d +debian-prereq: + apt-get install libusb-dev +uninstall: + rm -f /etc/udev/rules.d/99-tempsensor.rules /usr/bin/temper + diff --git a/.graveyard/temper/collectd-temper.sh b/.graveyard/temper/collectd-temper.sh new file mode 100755 index 00000000..f66e9acc --- /dev/null +++ b/.graveyard/temper/collectd-temper.sh @@ -0,0 +1,9 @@ +HOSTNAME="${COLLECTD_HOSTNAME:-localhost}" +INTERVAL="${COLLECTD_INTERVAL:-30}" +TEMPERNAME="${TEMPERNAME:-external}" +TEMPERBIN="${TEMPERBIN:-/krebs/temper/temper}" +#while sleep "$INTERVAL"; do + VALUE=`$TEMPERBIN` + echo "PUTVAL \"$HOSTNAME/sensors-temper/temperature-$TEMPERNAME\" N:$VALUE" #interval=$INTERVAL + logger "PUTVAL \"$HOSTNAME/sensors-temper/temperature-$TEMPERNAME\" N:$VALUE" #interval=$INTERVAL +#done diff --git a/.graveyard/temper/temper.c b/.graveyard/temper/temper.c new file mode 100644 index 00000000..f0730ab3 --- /dev/null +++ b/.graveyard/temper/temper.c @@ -0,0 +1,277 @@ +#include +#include +#include +#include + +/* + * Temper.c by Robert Kavaler (c) 2009 (relavak.com) + * All rights reserved. + * + * Temper driver for linux. This program can be compiled either as a library + * or as a standalone program (-DUNIT_TEST). The driver will work with some + * TEMPer usb devices from RDing (www.PCsensor.com). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * THIS SOFTWARE IS PROVIDED BY Robert Kavaler ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL Robert kavaler BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "temper.h" + +#define VENDOR_ID 0x1130 +#define PRODUCT_ID 0x660c + +struct Temper { + struct usb_device *device; + usb_dev_handle *handle; + int debug; + int timeout; +}; + + Temper * +TemperCreate(struct usb_device *dev, int timeout, int debug) +{ + Temper *t; + int ret; + + t = calloc(1, sizeof(*t)); + t->device = dev; + t->debug = debug; + t->timeout = timeout; + t->handle = usb_open(t->device); + if(!t->handle) { + free(t); + return NULL; + } + if(t->debug) { + printf("Trying to detach kernel driver\n"); + } + + ret = usb_detach_kernel_driver_np(t->handle, 0); + if(ret) { + if(errno == ENODATA) { + if(t->debug) { + printf("Device already detached\n"); + } + } else { + if(t->debug) { + printf("Detach failed: %s[%d]\n", + strerror(errno), errno); + printf("Continuing anyway\n"); + } + } + } else { + if(t->debug) { + printf("detach successful\n"); + } + } + ret = usb_detach_kernel_driver_np(t->handle, 1); + if(ret) { + if(errno == ENODATA) { + if(t->debug) + printf("Device already detached\n"); + } else { + if(t->debug) { + printf("Detach failed: %s[%d]\n", + strerror(errno), errno); + printf("Continuing anyway\n"); + } + } + } else { + if(t->debug) { + printf("detach successful\n"); + } + } + + if(usb_set_configuration(t->handle, 1) < 0 || + usb_claim_interface(t->handle, 0) < 0 || + usb_claim_interface(t->handle, 1)) { + usb_close(t->handle); + free(t); + return NULL; + } + return t; +} + + Temper * +TemperCreateFromDeviceNumber(int deviceNum, int timeout, int debug) +{ + struct usb_bus *bus; + int n; + + n = 0; + for(bus=usb_get_busses(); bus; bus=bus->next) { + struct usb_device *dev; + + for(dev=bus->devices; dev; dev=dev->next) { + if(debug) { + printf("Found device: %04x:%04x\n", + dev->descriptor.idVendor, + dev->descriptor.idProduct); + } + if(dev->descriptor.idVendor == VENDOR_ID && + dev->descriptor.idProduct == PRODUCT_ID) { + if(debug) { + printf("Found deviceNum %d\n", n); + } + if(n == deviceNum) { + return TemperCreate(dev, timeout, debug); + } + n++; + } + } + } + return NULL; +} + + void +TemperFree(Temper *t) +{ + if(t) { + if(t->handle) { + usb_close(t->handle); + } + free(t); + } +} + + static int +TemperSendCommand(Temper *t, int a, int b, int c, int d, int e, int f, int g, int h) +{ + unsigned char buf[32]; + int ret; + + bzero(buf, 32); + buf[0] = a; + buf[1] = b; + buf[2] = c; + buf[3] = d; + buf[4] = e; + buf[5] = f; + buf[6] = g; + buf[7] = h; + + if(t->debug) { + printf("sending bytes %d, %d, %d, %d, %d, %d, %d, %d\n", + a, b, c, d, e, f, g, h); + } + + ret = usb_control_msg(t->handle, 0x21, 9, 0x200, 0x01, + (char *) buf, 32, t->timeout); + if(ret != 32) { + perror("usb_control_msg failed"); + return -1; + } + return 0; +} + + static int +TemperGetData(Temper *t, char *buf, int len) +{ + int ret; + + return usb_control_msg(t->handle, 0xa1, 1, 0x300, 0x01, + (char *) buf, len, t->timeout); +} + + int +TemperGetTemperatureInC(Temper *t, float *tempC) +{ + char buf[256]; + int ret, temperature, i; + + TemperSendCommand(t, 10, 11, 12, 13, 0, 0, 2, 0); + TemperSendCommand(t, 0x54, 0, 0, 0, 0, 0, 0, 0); + for(i = 0; i < 7; i++) { + TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); + } + TemperSendCommand(t, 10, 11, 12, 13, 0, 0, 1, 0); + ret = TemperGetData(t, buf, 256); + if(ret < 2) { + return -1; + } + + temperature = (buf[1] & 0xFF) + (buf[0] << 8); + temperature += 1152; // calibration value + *tempC = temperature * (125.0 / 32000.0); + return 0; +} + + int +TemperGetOtherStuff(Temper *t, char *buf, int length) +{ + TemperSendCommand(t, 10, 11, 12, 13, 0, 0, 2, 0); + TemperSendCommand(t, 0x52, 0, 0, 0, 0, 0, 0, 0); + TemperSendCommand(t, 10, 11, 12, 13, 0, 0, 1, 0); + return TemperGetData(t, buf, length); +} + + +#define USB_TIMEOUT 1000 /* milliseconds */ +#define DEBUG_MODE 1 +#define SLEEP_TIMEOUT 10 + + int +main(int argv,char** args) +{ + + + Temper *t; + char buf[256]; + int i, ret,oneshot=0; + if (argv == 2 && (args[1][1] == 'h' || args[1][0] == 'h')) + { + printf("Temper, does the right thing in C\n"); + printf("recompile with DEBUG_MODE = 1 for all the debug printing\n"); + printf("recompile with SLEEP_TIMEOUT = XX for a different polling interval\n"); + exit(0); + } + + usb_set_debug(DEBUG_MODE); + usb_init(); + usb_find_busses(); + usb_find_devices(); + + t = TemperCreateFromDeviceNumber(0, USB_TIMEOUT, DEBUG_MODE); + if(!t) { + perror("TemperCreate"); + exit(-1); + } + + /* + TemperSendCommand(t, 10, 11, 12, 13, 0, 0, 2, 0); + TemperSendCommand(t, 0x43, 0, 0, 0, 0, 0, 0, 0); + TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); + TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); + TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); + TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); + TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); + TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); + */ + + bzero(buf, 256); + ret = TemperGetOtherStuff(t, buf, 256); + + float tempc; + + if(TemperGetTemperatureInC(t, &tempc) < 0) { + perror("TemperGetTemperatureInC"); + exit(1); + } + + printf("%.2f\n", tempc); + return 0; +} diff --git a/.graveyard/temper/temper.h b/.graveyard/temper/temper.h new file mode 100644 index 00000000..7ea6280a --- /dev/null +++ b/.graveyard/temper/temper.h @@ -0,0 +1,39 @@ +#ifndef TEMPER_H +#define TEMPER_H + +/* + * Temper.h by Robert Kavaler (c) 2009 (relavak.com) + * All rights reserved. + * + * Temper driver for linux. This program can be compiled either as a library + * or as a standalone program (-DUNIT_TEST). The driver will work with some + * TEMPer usb devices from RDing (www.PCsensor.com). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * THIS SOFTWARE IS PROVIDED BY Robert Kavaler ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL Robert kavaler BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +typedef struct Temper Temper; + + +Temper *TemperCreateFromDeviceNumber(int deviceNum, int timeout, int debug); +void TemperFree(Temper *t); + +int TemperGetTemperatureInC(Temper *t, float *tempC); +int TempterGetOtherStuff(Temper *t, char *buf, int length); + +#endif -- cgit v1.2.3 From 1a49b2e844a733812be1de8fc76af1a4c2ec5f0e Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 19 Nov 2013 08:51:24 +0100 Subject: autowifi -> graveyard autowifi source is superserseeded by github.com/krebscode/autowifi --- .graveyard/autowifi/autowifi | 212 +++++++++++++++++++++ .graveyard/autowifi/confdir/blacklist | 2 + .graveyard/autowifi/confdir/cracks/00profile | 11 ++ .graveyard/autowifi/confdir/cracks/01open | 6 + .../autowifi/confdir/hooks/wlan0/post/00tinc-up | 2 + .../autowifi/confdir/hooks/wlan0/pre/00changemac | 5 + 6 files changed, 238 insertions(+) create mode 100755 .graveyard/autowifi/autowifi create mode 100644 .graveyard/autowifi/confdir/blacklist create mode 100755 .graveyard/autowifi/confdir/cracks/00profile create mode 100755 .graveyard/autowifi/confdir/cracks/01open create mode 100755 .graveyard/autowifi/confdir/hooks/wlan0/post/00tinc-up create mode 100755 .graveyard/autowifi/confdir/hooks/wlan0/pre/00changemac (limited to '.graveyard') diff --git a/.graveyard/autowifi/autowifi b/.graveyard/autowifi/autowifi new file mode 100755 index 00000000..5bdbde22 --- /dev/null +++ b/.graveyard/autowifi/autowifi @@ -0,0 +1,212 @@ +#!/bin/sh -x + +confdir=${confdir:-"$(dirname $0)/confdir"} +interface="wlan0" + +exists() { type "$1" >/dev/null 2>/dev/null; } + +start_wpa_supplicant(){ + killall wpa_supplicant + sleep 1 +cat>wpa.conf< $confdir/wifi_stats2 + mv $confdir/wifi_stats2 $confdir/wifi_stats + return 0 + fi + return 1 + +} +print_iwlist_env(){ + # takes environment: + # MAC + # FREQ + # QUALITY + # ENCRYPTION + # ESSID + for i in MAC FREQ QUALITY ENCRYPTION ESSID;do + eval echo ${i}_${count}=\\\"\$"${i}"\\\" + done +} + +iwlist_scan(){ + # usage: iwlist_scan $wifi-itf + + count=0 + wpa_cli scan >/dev/null + sleep 10 + + wpa_cli scan_results 2>/dev/null | grep -E "^??:" | sed 's/ / /g' | (while IFS=' ' read MAC FREQ QUALITY ENCRYPTION ESSID + do + : $((count+=1)) + print_iwlist_env + + done; echo WIFI_COUNT=$count) +} + +find_count_of_ssid(){ + c=0 + for i in `seq 1 $WIFI_COUNT`; do + eval SSID=\${ESSID_${i}} + if [ "$SSID" = $1 ]; then + c+=1 + echo $i + fi + done + if [ $c -eq 0 ];then + exit 1 + fi + exit 0 +} + +find_unscanned_networks(){ + for i in `seq 1 $WIFI_COUNT`; do + eval SSID=\${ESSID_${i}} + eval MAC=\${MAC_${i}} + cat $confdir/wifi_stats 2>/dev/null | (while IFS='|' read SSID MAC BANDW KEY; do + if [ "$1" = "$SSID" -a "$2" = "$MAC" ]; then + continue + fi + done; echo $i) + done + exit 0 +} + +connect_to_network_by_ssid(){ + find_count_of_ssid "$1" | (while read i + do + loop_over_cracks $i + done;exit 1) + if [ $? -eq 0 ]; then + exit 0 + fi + echo "no network found :(" + exit 1 +} + +connect_with_pw(){ + find_count_of_ssid "$1" | (while read i + do + KEY="$2" + eval connect \"\${MAC_${i}}\" \"\${ESSID_${i}}\" \${ENCRYPTION_${i}} \"\${KEY}\" + if [ $? -eq 0 ]; then + exit 0 + fi + done;exit 1) +} + +loop_over_networks(){ + for i in `seq 1 $WIFI_COUNT`; do + loop_over_cracks $i + if [ $? -eq 0 ]; then + exit 0 + fi + done +} + +loop_over_cracks(){ + i=$1 + KEY='' + for crack in $(find $confdir/cracks -type f | sort -u); do + KEY="$(eval root=$confdir \$crack \"\${ESSID_${i}}\" \"\${MAC_${i}}\" \${FREQ_${i}} \${ENCRYPTION_${i}})" + if [ $? -eq 0 ]; then + eval connect \"\${MAC_${i}}\" \"\${ESSID_${i}}\" \${ENCRYPTION_${i}} \"\${KEY}\" + if [ $? -eq 0 ]; then + return 0 + fi + fi + done + return 1 +} + +scan_all(){ + for i in `seq 1 $WIFI_COUNT`; do + loop_over_cracks $i + done +} + +scan_unscanned(){ + find_unscanned_networks | (while read i + do + loop_over_cracks $i + done) +} + + +check_gateway(){ + echo ping -c 1 -w 5 $(ip route | grep $interface | awk '/default/{print $3}') +} + +check_internet(){ + ping -c 1 -w 5 8.8.8.8 +} + +check_bandwidth(){ + echo $(printf "%.16d\n" $(curl ftp://ftp.microsoft.com/Products/mspress/library/ANIMAT.ZIP -w "%{speed_download}" -o /dev/null 2>/dev/null | sed 's/\..*//')) +} + +start_wpa_supplicant +iwlist_scan > /tmp/$interface.scan +. /tmp/$interface.scan +if [ -n "$2" ]; then + echo connecting to $1 with pw $2 + connect_with_pw "$1" "$2" +elif [ -n "$1" ]; then + echo connecting to $1 + connect_to_network_by_ssid "$1" +else + echo looping network now + loop_over_networks +fi diff --git a/.graveyard/autowifi/confdir/blacklist b/.graveyard/autowifi/confdir/blacklist new file mode 100644 index 00000000..f0e5c6a1 --- /dev/null +++ b/.graveyard/autowifi/confdir/blacklist @@ -0,0 +1,2 @@ +02:25:9c:41:c6:89 +02:25:9c:41:c4:cc diff --git a/.graveyard/autowifi/confdir/cracks/00profile b/.graveyard/autowifi/confdir/cracks/00profile new file mode 100755 index 00000000..c2ad6ec7 --- /dev/null +++ b/.graveyard/autowifi/confdir/cracks/00profile @@ -0,0 +1,11 @@ +#!/bin/sh -x +#ESSID MAC CHANNEL ENCRYPTION WPA WPA2 +# ENV: +# root (default: /) +root=${root:-/} +cat $root/wifi_stats 2>/dev/null | (while IFS='|' read SSID MAC BANDW KEY; do + if [ "$1" = "$SSID" -a "$2" = "$MAC" ]; then + echo $KEY + exit 0 + fi +done; exit 1) diff --git a/.graveyard/autowifi/confdir/cracks/01open b/.graveyard/autowifi/confdir/cracks/01open new file mode 100755 index 00000000..7bd98e20 --- /dev/null +++ b/.graveyard/autowifi/confdir/cracks/01open @@ -0,0 +1,6 @@ +#!/bin/sh -x +#ESSID MAC CHANNEL ENCRYPTION WPA WPA2 +if [ "$4" = "[ESS]" ]; then + exit 0 +fi +exit 1 diff --git a/.graveyard/autowifi/confdir/hooks/wlan0/post/00tinc-up b/.graveyard/autowifi/confdir/hooks/wlan0/post/00tinc-up new file mode 100755 index 00000000..3fd786e4 --- /dev/null +++ b/.graveyard/autowifi/confdir/hooks/wlan0/post/00tinc-up @@ -0,0 +1,2 @@ +#!/bin/sh +tincd -n retiolum -kALRM diff --git a/.graveyard/autowifi/confdir/hooks/wlan0/pre/00changemac b/.graveyard/autowifi/confdir/hooks/wlan0/pre/00changemac new file mode 100755 index 00000000..c3e0632f --- /dev/null +++ b/.graveyard/autowifi/confdir/hooks/wlan0/pre/00changemac @@ -0,0 +1,5 @@ +#!/bin/sh +ifconfig wlan0 down +sleep 1 +macchanger -r wlan0 +ifconfig wlan0 up -- cgit v1.2.3 From f4f5b3b7aff2ac45ee035f54d6e8899ff963d133 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 9 Dec 2013 20:07:19 +0100 Subject: noise: RIP --- .graveyard/noise/Makefile | 18 +++ .graveyard/noise/TODO | 60 ++++++++++ .graveyard/noise/cron/bin/zeit | 18 +++ .graveyard/noise/init.d/noise | 48 ++++++++ .graveyard/noise/modules/cat | 14 +++ .graveyard/noise/modules/chat | 33 ++++++ .graveyard/noise/modules/date | 6 + .graveyard/noise/modules/echo | 6 + .graveyard/noise/modules/ein_mal_eins | 37 ++++++ .graveyard/noise/modules/espeak | 34 ++++++ .graveyard/noise/modules/help | 24 ++++ .graveyard/noise/modules/join | 15 +++ .graveyard/noise/modules/lang | 22 ++++ .graveyard/noise/modules/licht | 1 + .graveyard/noise/modules/mpc | 14 +++ .graveyard/noise/modules/names | 22 ++++ .graveyard/noise/modules/nick | 10 ++ .graveyard/noise/modules/overlord | 14 +++ .graveyard/noise/modules/part | 15 +++ .graveyard/noise/modules/ping | 24 ++++ .graveyard/noise/modules/play | 36 ++++++ .graveyard/noise/modules/pong | 26 +++++ .graveyard/noise/modules/query | 23 ++++ .graveyard/noise/modules/send_to_channel | 17 +++ .graveyard/noise/modules/sendmail | 55 +++++++++ .graveyard/noise/modules/shackstatus | 104 +++++++++++++++++ .graveyard/noise/modules/sleep | 10 ++ .graveyard/noise/modules/stream | 2 + .graveyard/noise/modules/temp | 50 +++++++++ .graveyard/noise/modules/test | 13 +++ .graveyard/noise/modules/twitter | 125 +++++++++++++++++++++ .graveyard/noise/modules/vvs | 17 +++ .graveyard/noise/modules/wall | 8 ++ .graveyard/noise/modules/zeit | 19 ++++ .graveyard/noise/noise | 186 +++++++++++++++++++++++++++++++ .graveyard/noise/noise-as-user | 4 + .graveyard/noise/noise-server | 4 + 37 files changed, 1134 insertions(+) create mode 100644 .graveyard/noise/Makefile create mode 100644 .graveyard/noise/TODO create mode 100755 .graveyard/noise/cron/bin/zeit create mode 100755 .graveyard/noise/init.d/noise create mode 100755 .graveyard/noise/modules/cat create mode 100755 .graveyard/noise/modules/chat create mode 100755 .graveyard/noise/modules/date create mode 100755 .graveyard/noise/modules/echo create mode 100755 .graveyard/noise/modules/ein_mal_eins create mode 100755 .graveyard/noise/modules/espeak create mode 100755 .graveyard/noise/modules/help create mode 100755 .graveyard/noise/modules/join create mode 100755 .graveyard/noise/modules/lang create mode 120000 .graveyard/noise/modules/licht create mode 100755 .graveyard/noise/modules/mpc create mode 100755 .graveyard/noise/modules/names create mode 100755 .graveyard/noise/modules/nick create mode 100755 .graveyard/noise/modules/overlord create mode 100755 .graveyard/noise/modules/part create mode 100755 .graveyard/noise/modules/ping create mode 100755 .graveyard/noise/modules/play create mode 100755 .graveyard/noise/modules/pong create mode 100755 .graveyard/noise/modules/query create mode 100755 .graveyard/noise/modules/send_to_channel create mode 100755 .graveyard/noise/modules/sendmail create mode 100755 .graveyard/noise/modules/shackstatus create mode 100755 .graveyard/noise/modules/sleep create mode 100755 .graveyard/noise/modules/stream create mode 100755 .graveyard/noise/modules/temp create mode 100755 .graveyard/noise/modules/test create mode 100755 .graveyard/noise/modules/twitter create mode 100755 .graveyard/noise/modules/vvs create mode 100755 .graveyard/noise/modules/wall create mode 100755 .graveyard/noise/modules/zeit create mode 100755 .graveyard/noise/noise create mode 100755 .graveyard/noise/noise-as-user create mode 100755 .graveyard/noise/noise-server (limited to '.graveyard') diff --git a/.graveyard/noise/Makefile b/.graveyard/noise/Makefile new file mode 100644 index 00000000..0d72b2e9 --- /dev/null +++ b/.graveyard/noise/Makefile @@ -0,0 +1,18 @@ + +.PHONY: all +all: select-target + +.PHONY: infest +infest: + apt-get install --yes expect beep alsa-utils ucspi-tcp espeak + f=/usr/bin/beep; chown krebs:krebs $$f && chmod 4755 $$f + getent passwd noise || useradd noise + echo 'noise ALL=(ALL) NOPASSWD: /krebs/streams/streams' | magic create noise /etc/sudoers + ln -vsnf /krebs/noise/init.d/noise /etc/init.d/noise + ## tv: TODO update-rc.d is DEBIAN ONLY, fix this + update-rc.d -f noise defaults + amixer sset 'Master' 100 unmute || true + amixer sset 'PCM' 100 unmute || true + amixer sset 'PC Speaker' 100 unmute || \ + amixer sset 'Beep' 100 unmute || true + diff --git a/.graveyard/noise/TODO b/.graveyard/noise/TODO new file mode 100644 index 00000000..a20f74e9 --- /dev/null +++ b/.graveyard/noise/TODO @@ -0,0 +1,60 @@ +#### file:noise/TODO + +- /channels +- /hist N -- zum anzeigen von N letzten Nachrichten + - Log? Es werden maximal chat_histsize Zeilen gespeichert. +- Anbindung ans MoinMoin +- IRC <-> 23.shack - Brücke +- when nick changes say "You're now known as XXX" to yourself +- twitter: push new tweets as they arrive to all connected clients with + the variable tweet_me set to ON + +- Author, Maintainer etc. direkt in die Module in der erweiterten Hilfe, also + in /help MODULENAME -> man sollte sich auf ein einheitliches Dokmentierungs- + Format einigen. + - All modules should contain: + - Author(s) w/ e-mail, Copyright, License + - Maintainer(s) w/ e-mail + - Module-Version + - last tested System-Version + - we need to export the system version +- GIT commits tweeten (shack und root) +- /kick [CHANNEL] # from channel / telnet +- /ban # :-) +- /op +- USER-A: /ping USER-B + - USER-B: /pong + - write time to USER-{A,B} +- style-sheets for everything MOAR!!1 +- libraries +- HTTP-interface +- /whois, /whoami, /whowas +- join,part&co. should support multiple channels +- /TODO,/bug,/issue or something should be added as tracking-system +- /part should say something like "X has left." +- /join should say something like "X has joined." + # it's obvious that the channels is meant... + - or else say: "X has joined channel Y." when we can join more than one + channel +- /part should unset chat_channel (somehow) else keeping /part'ing will + broadcast to chat_channel that X has quit... +- split /twitter into /tweet and X, to make it clear when tweets are fired +- POP3 mail off googlemail and show them to curious telnetters +- /set x 23 -> blah $x + +- /rewrite -- e.g. /rewrite "!%s" "/play %s" oder sowasi +- Zugriff per ssh +- module to standard unix-commands (name like /system) + - unix-commands should simply link to system +- /save TOKEN, /load TOKEN +- /op # NUR VIA SSH! (s.o.) +- MODULE-TEST-SUITE [blackbox] +- sub-modules like /chat-join which may be abbreviated as /join when + $default_command is set to /chat, YAY + - unclutter /help: + - /help -> show all (main) modules + - /help MODULE -> show help of MODULE and show all sub-modules + - /help MODULE SUB-MODULE -> show help of SUB-MODULE and show all sub^2... +- watchdog + +#### end of file. diff --git a/.graveyard/noise/cron/bin/zeit b/.graveyard/noise/cron/bin/zeit new file mode 100755 index 00000000..168a7b7b --- /dev/null +++ b/.graveyard/noise/cron/bin/zeit @@ -0,0 +1,18 @@ +#! /bin/sh + +beep -l 1000 -f 4000 +sleep 1 +/krebs/morse/morse.sh -l 100 -f 700 `date +%k` +sleep 1 +expect >/dev/null <$NOISE_linefeed;; + (/names) + cd /tmp/noise + . $NOISE_pid/environment + nick="${chat_nick-$NOISE_pid}" + channel="$chat_channel" + echo "Users in channel $channel" + for client in * ; do + . $client/environment + chat_nick="${chat_nick-$client}" + if test "$channel" = "$chat_channel" && test "$default_command" = chat ; then + echo "$chat_nick" + fi + unset chat_nick + unset chat_channel + unset default_command + done ;; + (*) + cd /tmp/noise + . $NOISE_pid/environment + nick="${chat_nick-$NOISE_pid}" + + echo "/send_to_channel $chat_channel $nick: $*" > $NOISE_linefeed + + + #echo /wall @@ $* >$NOISE_linefeed +esac diff --git a/.graveyard/noise/modules/date b/.graveyard/noise/modules/date new file mode 100755 index 00000000..8cd1b0c1 --- /dev/null +++ b/.graveyard/noise/modules/date @@ -0,0 +1,6 @@ +#! /bin/sh +case "$1" in + (--help) : ;; + (*) + date --rfc-3339=s +esac diff --git a/.graveyard/noise/modules/echo b/.graveyard/noise/modules/echo new file mode 100755 index 00000000..344dd963 --- /dev/null +++ b/.graveyard/noise/modules/echo @@ -0,0 +1,6 @@ +#! /bin/sh +case "$1" in + (--help) : ;; + (*) + echo "$*" +esac diff --git a/.graveyard/noise/modules/ein_mal_eins b/.graveyard/noise/modules/ein_mal_eins new file mode 100755 index 00000000..e21612a5 --- /dev/null +++ b/.graveyard/noise/modules/ein_mal_eins @@ -0,0 +1,37 @@ +#! /bin/bash + +R() { + echo "`od -t d -N 1 /dev/urandom | sed -n '1s/^[0-9]\+ \+//p'` % $@" | bc +} + + + + +case "$1" in + (--help) echo Stellt eine einfache Aufgabe ;; + (*) + a="`R 69`" + b="`R 69`" + op="`echo "\ +Was ist, A hoch B +Was ist, A plus B +Was ist, A minus B +Was ist, A mal B +Was ist, sinus von 0 +Was ist, Pi halbe mal 2 +Was ist, 2 hoch 8 +Was ist, 2 hoch 16 +Was ist, 2 hoch 32 +Was ist, 42 geteilt durch Pi mal 100 +Was ist, l n von 1 +Was ist, 42 +Was ist, 23 +Starte den Server neu +Löte ein Kabel an einen Kompjuter +Was ist, A geteilt durch B"`" + o="$(R `echo "$op" | wc -l` + 1)" + + aufgabe=`echo "$op" | sed -n "$o{s/A/$a/;s/B/$b/;p}"` + + echo "/espeak -v Löse die Aufgabe: $aufgabe?" >$NOISE_linefeed +esac diff --git a/.graveyard/noise/modules/espeak b/.graveyard/noise/modules/espeak new file mode 100755 index 00000000..815d9d99 --- /dev/null +++ b/.graveyard/noise/modules/espeak @@ -0,0 +1,34 @@ +#! /bin/sh + +print_var() { + echo "$1 = $2" +} + +speak() { + p="${noise_pitch-100}" + v="${noise_lang-de}" + k="${noise_capital-0}" + a="${noise_amplitude-600}" + g="${noise_gap-1}" + if test "$debug" = true; then + print_var pitch $p + print_var lang $v + print_var capital $k + print_var amplitude $a + print_var gap $g + fi + if test "$verbose" = true; then + echo "espeak: $@" + fi + #echo "espeak -p \"$pitch\" -v \"$lang\" \"$*\"" >&2 + (espeak --stdout -a $a -k $k -p $p -v $v -g $g | aplay)</dev/null + done + ## print all documented built-in commands + sed -n 's:^noise_\([a-z]\+\)() { # \(.\+\)\?$:\1 \2:p' "$NOISE" + } | sort | uniq | sed -n ' + $s/$// + s:^\([a-z]\+\) \(.\+\):type /\1 to \2:p' ;; + (*) + ## call + for directory in `echo "$NOISE_PATH" | tr : \ ` ; do + for module in "$directory/$1" ; do + if test -e $module ; then + shift + exec $module --help --verbose "$@" 2>&1 + fi + done + done +esac diff --git a/.graveyard/noise/modules/join b/.graveyard/noise/modules/join new file mode 100755 index 00000000..68afcb66 --- /dev/null +++ b/.graveyard/noise/modules/join @@ -0,0 +1,15 @@ +#! /bin/sh + +case "$1" in + (--help) echo set default_command to chat and join channel ;; + (*) + . /tmp/noise/$NOISE_pid/environment + nick="${chat_nick-$NOISE_pid}" + echo /send_to_channel "${1-#23}" "$nick" joined the channel >$NOISE_linefeed + echo /set default_command chat >$NOISE_linefeed + echo /set chat_channel "${1-#23}" >$NOISE_linefeed + echo " joined channel ${1-#23}" + echo /part to go back to espeak ;; + + +esac diff --git a/.graveyard/noise/modules/lang b/.graveyard/noise/modules/lang new file mode 100755 index 00000000..07b6802e --- /dev/null +++ b/.graveyard/noise/modules/lang @@ -0,0 +1,22 @@ +#! /bin/sh + +case "$1" in + (--help) + echo "set language or list available languages" ;; + (list) + espeak --voices | sed -n '1!p' | awk '{\ + printf"/lang %s set lang to %s\n",$2,$4 + }' ;; + ('') + echo /set lang >$NOISE_linefeed ;; + (*) + if test -z "$2" ; then + echo /set lang "$1" + else + echo /set lang "$1" + shift + echo "$*" + echo /set lang "${noise_lang-de}" + fi >$NOISE_linefeed +esac + diff --git a/.graveyard/noise/modules/licht b/.graveyard/noise/modules/licht new file mode 120000 index 00000000..7f170fe2 --- /dev/null +++ b/.graveyard/noise/modules/licht @@ -0,0 +1 @@ +/krebs/god/licht \ No newline at end of file diff --git a/.graveyard/noise/modules/mpc b/.graveyard/noise/modules/mpc new file mode 100755 index 00000000..20abf19b --- /dev/null +++ b/.graveyard/noise/modules/mpc @@ -0,0 +1,14 @@ +#! /bin/sh + +case "$1" in + (--help) + case "$2" in + (--verbose) mpc --help ;; + (*) echo access mpd + esac ;; + (*) + ##echo test-module called with following arguments: "$@" + ## send command for re-evaluation: + ##echo /espeak test >$NOISE_linefeed + MPD_HOST=filebitch.shack mpc $@ +esac diff --git a/.graveyard/noise/modules/names b/.graveyard/noise/modules/names new file mode 100755 index 00000000..f5922064 --- /dev/null +++ b/.graveyard/noise/modules/names @@ -0,0 +1,22 @@ +#! /bin/sh + +case "$1" in + (--help) echo send text to everyone with @@ prepended ;; + (*) + cd /tmp/noise + . $NOISE_pid/environment + if test "$default_command" != chat ; then exit ; fi + nick="${chat_nick-$NOISE_pid}" + channel="${1-$chat_channel}" + echo "Users in channel $channel" + for client in * ; do + . $client/environment + chat_nick="${chat_nick-$client}" + if test "$channel" = "$chat_channel" && test "$default_command" = chat ; then + echo "$chat_nick" + fi + unset chat_nick + unset chat_channel + unset default_command + done +esac diff --git a/.graveyard/noise/modules/nick b/.graveyard/noise/modules/nick new file mode 100755 index 00000000..5ed1e9d9 --- /dev/null +++ b/.graveyard/noise/modules/nick @@ -0,0 +1,10 @@ +#! /bin/sh + +case "$1" in + (--help) echo send text to everyone with @@ prepended ;; + (*) + . /tmp/noise/$NOISE_pid/environment + nick="${chat_nick-$NOISE_pid}" + echo /send_to_channel $chat_channel $nick is now known as $1 > $NOISE_linefeed + echo /set chat_nick $1 >$NOISE_linefeed;; +esac diff --git a/.graveyard/noise/modules/overlord b/.graveyard/noise/modules/overlord new file mode 100755 index 00000000..ded8627a --- /dev/null +++ b/.graveyard/noise/modules/overlord @@ -0,0 +1,14 @@ +#! /bin/sh +set -euf + +# cd // +cd $(dirname $(readlink -f $0))/../.. + +case "${1---help}" in + --help) + echo "Make an announcement! Usage: /overlord " + ;; + *) + exec god/overlord/index "$@" + ;; +esac diff --git a/.graveyard/noise/modules/part b/.graveyard/noise/modules/part new file mode 100755 index 00000000..d35ac501 --- /dev/null +++ b/.graveyard/noise/modules/part @@ -0,0 +1,15 @@ +#! /bin/sh + +case "$1" in + (--help) echo leave chat mode ;; + (*) + . /tmp/noise/$NOISE_pid/environment + nick="${chat_nick-$NOISE_pid}" + + echo "/send_to_channel $chat_channel $nick has quit ${*-no reason}" > $NOISE_linefeed + + echo /set default_command espeak >$NOISE_linefeed + echo "disabled chat mode (set back to espeak)" ;; + + +esac diff --git a/.graveyard/noise/modules/ping b/.graveyard/noise/modules/ping new file mode 100755 index 00000000..acf2529f --- /dev/null +++ b/.graveyard/noise/modules/ping @@ -0,0 +1,24 @@ +#! /bin/sh +cd /tmp/noise +case "$1" in + (--help) : ;; + ('') + . $NOISE_pid/environment + ping_timestamp=${ping_timestamp-0} + ping_challenger=${ping_challenger-0} + if test $ping_challenger != 0 ; then + echo There is already a ping challange running + else + timestamp=`date +%s%N` + for client in * ; do + echo /ping $NOISE_pid $timestamp >$client/linefeed & + done + fi + ;; + (*) + echo "/set -q ping_timestamp $2" >$NOISE_pid/linefeed + if test $NOISE_pid != $1 ; then + echo "/set -q ping_challenger $1" >$NOISE_pid/linefeed + echo "PING?" + fi +esac diff --git a/.graveyard/noise/modules/play b/.graveyard/noise/modules/play new file mode 100755 index 00000000..180c1e0c --- /dev/null +++ b/.graveyard/noise/modules/play @@ -0,0 +1,36 @@ +#! /bin/sh +case "$1" in + (--help) + echo "play an audio file" ;; + (*) + exec 2>&1 + ffs='wav mp3 ogg asf flac' + + if test -z "$*" ; then + ls $HOME/noise/samples | sed ' + s:\.\('"`echo "$ffs" | tr \ \|`"'\)$: \1: + s:^:/play : + s:.*:&: + ' + else + for i in $ffs ; do + f=$HOME/noise/samples/$1.$i + test -f "$f" && + case "$i" in + wav) aplay "$f" & ;; + *) mplayer "$f" & ;; + esac && break + done || cat<$ping_challenger/linefeed + ## reset ping TODO /unset + echo /set -q ping_timestamp 0 >$NOISE_pid/linefeed + echo /set -q ping_challenger 0 >$NOISE_pid/linefeed + fi + ;; + (*) + . $1/environment + # XXX is attendee the right counterpart to 'challenger'? + attendee_nick=$chat_nick + . $NOISE_pid/environment + time=`echo "scale=3; ($2 - $ping_timestamp)/10^9" | bc` + echo "PONG! $attendee_nick ${time}s" +esac diff --git a/.graveyard/noise/modules/query b/.graveyard/noise/modules/query new file mode 100755 index 00000000..ceeff8a5 --- /dev/null +++ b/.graveyard/noise/modules/query @@ -0,0 +1,23 @@ +#! /bin/sh + +case "$1" in + (--help) echo send a message to a specific user ;; + (*) + cd /tmp/noise + . $NOISE_pid/environment + nick="${chat_nick-$NOISE_pid}" + target="$1" + shift + for client in * ; do + . $client/environment + if test "$target" = "${chat_nick-$client}" ; then + echo "/echo <-- $nick: $*" > $client/linefeed + echo "--> $target: $*" + exit + fi + unset chat_channel + + done + + echo "$nick not found" +esac diff --git a/.graveyard/noise/modules/send_to_channel b/.graveyard/noise/modules/send_to_channel new file mode 100755 index 00000000..4a0470af --- /dev/null +++ b/.graveyard/noise/modules/send_to_channel @@ -0,0 +1,17 @@ +#! /bin/sh + +case "$1" in + (--help) : ;; + (*) + cd /tmp/noise + channel="$1" + shift + for client in * ; do + . $client/environment + if test "$channel" = "$chat_channel" && test "$default_command" = chat ; then + echo "/echo $*" > $client/linefeed + fi + unset chat_channel + + done +esac diff --git a/.graveyard/noise/modules/sendmail b/.graveyard/noise/modules/sendmail new file mode 100755 index 00000000..182d96e3 --- /dev/null +++ b/.graveyard/noise/modules/sendmail @@ -0,0 +1,55 @@ +#!/usr/bin/python +import os,sys,smtplib,string +''' + Mail Plugin for the noise telnet suite + See: http://docs.python.org/library/smtplib.html + Author: Felix +''' + +# help +if len(sys.argv) == 2: + if sys.argv[1] == "--help": + print "send an e-mail ( \"TO(s)\" \"SUBJECT\" [string instead of EOF])" + sys.exit(0) + +# sanity +if len(sys.argv) <= 2: + print "wrong number of parameters, see help" + sys.exit(1) + +# write variables +# check of EOF +if len(sys.argv) == 4 : + EOFstring="%s\n"% sys.argv[3] +else: + EOFstring="EOF\n" + +fromaddr=u"Karl Koch" +toaddrs=sys.argv[1] +subject=sys.argv[2] + + +#write header: +msg = u"From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % (fromaddr, toaddrs,subject) +print "Write your text now, finish with %s" % EOFstring +sys.stdout.flush() # flushing is important to make sure the line is written + +while 1: + try: + line = sys.stdin.readline() + if line == EOFstring: + break + msg = msg + line + except EOFError: + break + +msg = msg + "[!] Written with NOISE telnet" + +print "Thank you for your message! Delivering it now..." +sys.stdout.flush() +server = smtplib.SMTP('localhost') +#server.set_debuglevel(1) +server.sendmail(fromaddr,toaddrs.split(','),msg) +server.quit() +print "mail send successfully" +sys.exit(0) diff --git a/.graveyard/noise/modules/shackstatus b/.graveyard/noise/modules/shackstatus new file mode 100755 index 00000000..a5058f0a --- /dev/null +++ b/.graveyard/noise/modules/shackstatus @@ -0,0 +1,104 @@ +#! /bin/bash + +main() { + case "$1" in + (--help) + echo "report status of all shack services." + ;; + (*) + test "$(dig +short localhost @10.42.0.10 )" = "127.0.0.1" && + STAT_DNS_I="läuft" || STAT_DNS_I="antwortet nicht" + test "$(dig +short shackspace.de @10.42.0.10 )" = "141.31.176.214" && + STAT_DNS_E="läuft" || STAT_DNS_E="antwortet nicht" + test "$(dig +short shackspace.de @141.31.176.214 )" = "141.31.176.214" && + STAT_DNS_X="läuft"|| STAT_DNS_X="antwortet nicht" + + STAT_LINE=$(ping -c 5 -i 0.2 -q 141.31.176.214 | + awk '/packet loss/ { print 100-$6}' ) + + cat <<-EOF >$NOISE_linefeed + /set pitch 10 + /espeak -v Hallo - Ich bin Krebs. + /espeak -v Heute ist `wochentag`, der `tag` --- `monat` -- `date +%Y` + /zeit + /espeak -v tcheck der systeme: + /espeak -v Energie versorgung -- aktiv + /espeak -v shackhost -- läuft + /espeak -v telnet -- läuft + /espeak -v interner - D N S --