summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/Monitoring/Makefile8
-rw-r--r--modules/Monitoring/TODO5
-rw-r--r--modules/Monitoring/conf/hostgroups_nagios2.cfg31
-rw-r--r--modules/Monitoring/conf/krebs_hosts.cfg78
-rw-r--r--modules/Monitoring/conf/krebsnet.cfg20
-rw-r--r--modules/Monitoring/conf/localhost.cfg60
-rw-r--r--modules/Monitoring/conf/other_hosts.cfg23
-rw-r--r--modules/Monitoring/conf/shack_infrastructure.cfg231
-rw-r--r--modules/Monitoring/conf/shacknet.cfg34
-rw-r--r--modules/Monitoring/conf/tinc_hosts.cfg45
-rw-r--r--modules/Monitoring/conf/tincnet.cfg31
-rw-r--r--modules/Monitoring/htdocs/images/logos/krebs/favicon.icobin0 -> 822 bytes
-rw-r--r--modules/Monitoring/htdocs/images/logos/krebs/krebs.gd2bin0 -> 1047 bytes
-rw-r--r--modules/Monitoring/htdocs/images/logos/krebs/krebs.pngbin0 -> 323 bytes
-rw-r--r--modules/Monitoring/htdocs/images/logos/krebs/shack.gd2bin0 -> 1047 bytes
-rw-r--r--modules/Monitoring/htdocs/images/logos/krebs/shack.pngbin0 -> 316 bytes
-rw-r--r--modules/Monitoring/htdocs/images/logos/krebs/tinc.gd2bin0 -> 1305 bytes
-rw-r--r--modules/Monitoring/htdocs/images/logos/krebs/tinc.pngbin0 -> 361 bytes
-rw-r--r--modules/Monitoring/htdocs/images/logos/krebs/wireless_access_point.gd2bin0 -> 1047 bytes
-rw-r--r--modules/Monitoring/htdocs/images/logos/krebs/wireless_access_point.pngbin0 -> 883 bytes
-rw-r--r--modules/Monitoring/htdocs/images/logos/krebs/wireless_access_point_64.pngbin0 -> 5364 bytes
-rwxr-xr-xmodules/Monitoring/plugins/check_sip252
-rwxr-xr-xmodules/bigeye/bigeyed70
-rw-r--r--modules/infest/Makefile18
-rwxr-xr-xmodules/infest/bin/make-patch57
-rw-r--r--modules/infest/bootstrap.sh23
-rwxr-xr-xmodules/infest/core/angstrom4
-rwxr-xr-xmodules/infest/core/debian6
-rw-r--r--modules/infest/host-patch/beagleboard/Makefile9
-rw-r--r--modules/infest/host-patch/beagleboard/profile.patch42
-rw-r--r--modules/infest/skel/etc/motd.tail10
-rwxr-xr-xmodules/infest/skel/etc/profile58
-rwxr-xr-xmodules/infest/skel/etc/rc.local10
-rw-r--r--modules/infest/skel/home/.ssh/authorized_keys6
-rw-r--r--modules/infest/skel/home/.vimrc31
-rw-r--r--modules/morse/COPYING14
-rw-r--r--modules/morse/README32
-rwxr-xr-xmodules/morse/morse.sh160
-rw-r--r--modules/noise/Makefile16
-rw-r--r--modules/noise/TODO60
-rwxr-xr-xmodules/noise/cron/bin/zeit18
-rwxr-xr-xmodules/noise/init.d/noise48
-rwxr-xr-xmodules/noise/modules/cat14
-rwxr-xr-xmodules/noise/modules/chat33
-rwxr-xr-xmodules/noise/modules/date6
-rwxr-xr-xmodules/noise/modules/echo6
-rwxr-xr-xmodules/noise/modules/ein_mal_eins37
-rwxr-xr-xmodules/noise/modules/espeak34
-rwxr-xr-xmodules/noise/modules/help24
-rwxr-xr-xmodules/noise/modules/join15
-rwxr-xr-xmodules/noise/modules/lang22
-rwxr-xr-xmodules/noise/modules/mpc14
-rwxr-xr-xmodules/noise/modules/names22
-rwxr-xr-xmodules/noise/modules/nick10
-rwxr-xr-xmodules/noise/modules/part15
-rwxr-xr-xmodules/noise/modules/ping24
-rwxr-xr-xmodules/noise/modules/play36
-rwxr-xr-xmodules/noise/modules/pong26
-rwxr-xr-xmodules/noise/modules/query23
-rwxr-xr-xmodules/noise/modules/send_to_channel17
-rwxr-xr-xmodules/noise/modules/sendmail55
-rwxr-xr-xmodules/noise/modules/shackstatus104
-rwxr-xr-xmodules/noise/modules/sleep10
-rwxr-xr-xmodules/noise/modules/stream64
-rwxr-xr-xmodules/noise/modules/temp56
-rwxr-xr-xmodules/noise/modules/test13
-rwxr-xr-xmodules/noise/modules/twitter125
-rwxr-xr-xmodules/noise/modules/vvs17
-rwxr-xr-xmodules/noise/modules/wall8
-rwxr-xr-xmodules/noise/modules/zeit19
-rwxr-xr-xmodules/noise/noise182
-rwxr-xr-xmodules/noise/noise-as-user4
-rwxr-xr-xmodules/noise/noise-server4
-rw-r--r--modules/people/Makefile6
-rw-r--r--modules/people/README.md13
-rw-r--r--modules/people/TODO.md3
-rw-r--r--modules/people/VERSION1
-rwxr-xr-xmodules/people/arping.py37
-rwxr-xr-xmodules/people/arping_users.py54
-rw-r--r--modules/people/mac_names.lst1
-rw-r--r--modules/retiolum/Makefile15
-rw-r--r--modules/retiolum/README29
-rwxr-xr-xmodules/retiolum/bin/fillxx6
-rwxr-xr-xmodules/retiolum/bin/hosts11
-rwxr-xr-xmodules/retiolum/bin/ipv635
-rwxr-xr-xmodules/retiolum/bin/tinc18
-rwxr-xr-xmodules/retiolum/bin/update_tinc_hosts33
-rw-r--r--modules/retiolum/scripts/README16
-rw-r--r--modules/retiolum/scripts/adv_graphgen/README28
-rwxr-xr-xmodules/retiolum/scripts/adv_graphgen/parse.py91
-rwxr-xr-xmodules/retiolum/scripts/adv_graphgen/sanitize.sh13
-rw-r--r--modules/retiolum/scripts/autostart/Makefile8
-rwxr-xr-xmodules/retiolum/scripts/autostart/tinc94
-rwxr-xr-xmodules/retiolum/scripts/tinc_multicast/retiolum34
-rwxr-xr-xmodules/retiolum/scripts/tinc_multicast/retiolum.py349
-rw-r--r--modules/retiolum/scripts/tinc_setup/README18
-rw-r--r--modules/retiolum/scripts/tinc_setup/bootstrap.sh11
-rwxr-xr-xmodules/retiolum/scripts/tinc_setup/build_arch.sh14
-rwxr-xr-xmodules/retiolum/scripts/tinc_setup/build_debian.sh32
-rwxr-xr-xmodules/retiolum/scripts/tinc_setup/build_debian_clean.sh31
-rwxr-xr-xmodules/retiolum/scripts/tinc_setup/build_ec2.sh16
-rw-r--r--modules/retiolum/scripts/tinc_setup/build_no.de.sh1
-rwxr-xr-xmodules/retiolum/scripts/tinc_setup/install.sh72
-rwxr-xr-xmodules/retiolum/scripts/tinc_setup/tinc-up20
-rw-r--r--modules/retiolum/scripts/tinc_setup/write_channel.py26
-rw-r--r--modules/streams/Makefile10
-rw-r--r--modules/streams/README10
-rwxr-xr-xmodules/streams/deepmix27
-rwxr-xr-xmodules/streams/groove29
-rwxr-xr-xmodules/streams/radiotux29
-rw-r--r--modules/temper/.gitignore1
-rw-r--r--modules/temper/99-tempsensor.rules1
-rw-r--r--modules/temper/Makefile14
-rw-r--r--modules/temper/temper.c277
-rw-r--r--modules/temper/temper.h39
-rwxr-xr-xmodules/webcams/cam1.sh2
-rw-r--r--modules/zoneminder/Makefile14
-rw-r--r--modules/zoneminder/zmdc.pl-LD_PRELOAD.patch10
-rw-r--r--modules/zoneminder/zoneminder.conf2
119 files changed, 4150 insertions, 0 deletions
diff --git a/modules/Monitoring/Makefile b/modules/Monitoring/Makefile
new file mode 100644
index 00000000..cc1d8903
--- /dev/null
+++ b/modules/Monitoring/Makefile
@@ -0,0 +1,8 @@
+.phony: debian
+debian:
+ [ `which nagios3` ] || apt-get install nagios3
+ rm /etc/nagios3/conf.d/localhost_nagios2.cfg || true
+ cp -r conf/* /etc/nagios3/conf.d/
+ cp -R htdocs/* /usr/share/nagios3/htdocs/
+ cp -r plugins /usr/lib/nagios
+ /etc/init.d/nagios3 reload
diff --git a/modules/Monitoring/TODO b/modules/Monitoring/TODO
new file mode 100644
index 00000000..6d74fdcd
--- /dev/null
+++ b/modules/Monitoring/TODO
@@ -0,0 +1,5 @@
+add guest user
+add guest user to
+> * authorized_for_all_services=usernagios,guest
+> * authorized_for_all_hosts=usernagios,guest
+in /etc/nagios3/somewhere
diff --git a/modules/Monitoring/conf/hostgroups_nagios2.cfg b/modules/Monitoring/conf/hostgroups_nagios2.cfg
new file mode 100644
index 00000000..63acbf50
--- /dev/null
+++ b/modules/Monitoring/conf/hostgroups_nagios2.cfg
@@ -0,0 +1,31 @@
+# Some generic hostgroup definitions
+
+# A simple wildcard hostgroup
+define hostgroup {
+ hostgroup_name all
+ alias All Servers
+ members *
+ }
+
+# A list of your Debian GNU/Linux servers
+define hostgroup {
+ hostgroup_name debian-servers
+ alias Debian GNU/Linux Servers
+ members localhost
+ }
+
+# A list of your web servers
+define hostgroup {
+ hostgroup_name http-servers
+ alias HTTP servers
+ members localhost
+ }
+
+# A list of your ssh-accessible servers
+define hostgroup {
+ hostgroup_name ssh-servers
+ alias SSH servers
+ members localhost
+ }
+
+
diff --git a/modules/Monitoring/conf/krebs_hosts.cfg b/modules/Monitoring/conf/krebs_hosts.cfg
new file mode 100644
index 00000000..a929fa19
--- /dev/null
+++ b/modules/Monitoring/conf/krebs_hosts.cfg
@@ -0,0 +1,78 @@
+
+#
+# Ur-Krebs
+#
+define host{
+ use generic-host
+ host_name krebs.shack
+ alias krebs
+ _tinc_address 10.7.7.156
+ address 10.42.23.5
+ parents shack-coreswitch
+ hostgroups krebs-machines,tinc-nodes,ssh-servers
+ }
+#
+# UTART
+#
+define host{
+ use generic-host
+ host_name utart
+ alias UTART
+ _tinc_address 10.7.7.66
+ address 10.42.23.23
+ parents shack-coreswitch
+ hostgroups krebs-machines,tinc-nodes,ssh-servers
+ }
+#
+# ytart
+# will use tinc ip as long as no static ip is supplied
+#
+define host{
+ use generic-host
+ host_name ytart
+ alias ytart
+ _tinc_address 10.7.7.201
+ parents shack-wlan-ap5
+ address 10.7.7.201
+ hostgroups krebs-machines,tinc-nodes,ssh-servers
+ }
+#
+# uPM
+#
+define host{
+ use generic-host
+ host_name upm
+ alias uPM Virtual Machine
+ _tinc_address 10.7.7.99
+ address upm.shack
+ parents shack-node1
+ hostgroups krebs-machines,ssh-servers,shack-rz
+ #,tinc-nodes
+ }
+
+# TODO add upm and genericore as tinc-nodes
+# TODO check MONGODB on uPM
+
+
+
+#TODO verkrebse genericore/get password
+define host{
+ use generic-host
+ host_name genericore
+ alias genericore Virtual Machine
+ #_tinc_address 10.7.7.XX
+ address genericore.shack
+ parents shack-node1
+ hostgroups ssh-servers,shack-rz
+ #,tinc-nodes,krebs-machines
+ }
+
+define host{
+ use generic-host
+ host_name shepherd
+ alias Shepherd Krebs
+ _tinc_address 10.7.7.29
+ address 10.42.23.42
+ parents shack-coreswitch
+ hostgroups krebs-machines,tinc-nodes,ssh-servers
+ }
diff --git a/modules/Monitoring/conf/krebsnet.cfg b/modules/Monitoring/conf/krebsnet.cfg
new file mode 100644
index 00000000..ae5b898e
--- /dev/null
+++ b/modules/Monitoring/conf/krebsnet.cfg
@@ -0,0 +1,20 @@
+## extended infos for krebsnet
+define hostgroup {
+ hostgroup_name krebs-machines
+ alias Krebs Machines
+ }
+define hostextinfo{
+ hostgroup_name krebs-machines
+ notes Deployed Krebse
+# notes_url http://webserver.localhost.localdomain/hostinfo.pl?host=netware1
+ icon_image krebs/krebs.png
+ icon_image_alt Krebs
+ vrml_image krebs.png
+ statusmap_image krebs/krebs.gd2
+ }
+#define host{
+# use generic-host
+# register 0
+# name tinc-only-host
+# check_command check_internal_tinc_up!100.0,20%!500.0,60%
+# }
diff --git a/modules/Monitoring/conf/localhost.cfg b/modules/Monitoring/conf/localhost.cfg
new file mode 100644
index 00000000..3b098195
--- /dev/null
+++ b/modules/Monitoring/conf/localhost.cfg
@@ -0,0 +1,60 @@
+# A simple configuration file for monitoring the local host
+# This can serve as an example for configuring other servers;
+# Custom services specific to this host are added here, but services
+# defined in nagios2-common_services.cfg may also apply.
+#
+
+define host{
+ use generic-host ; Name of host template to use
+ host_name localhost
+ alias localhost
+ address 127.0.0.1
+ hostgroups krebs-machines
+ }
+
+# Define a service to check the disk space of the root partition
+# on the local machine. Warning if < 20% free, critical if
+# < 10% free space on partition.
+
+define service{
+ use generic-service ; Name of service template to use
+ host_name localhost
+ service_description Disk Space
+ check_command check_all_disks!20%!10%
+ }
+
+
+
+# Define a service to check the number of currently logged in
+# users on the local machine. Warning if > 20 users, critical
+# if > 50 users.
+
+define service{
+ use generic-service ; Name of service template to use
+ host_name localhost
+ service_description Current Users
+ check_command check_users!20!50
+ }
+
+
+# Define a service to check the number of currently running procs
+# on the local machine. Warning if > 250 processes, critical if
+# > 400 processes.
+
+define service{
+ use generic-service ; Name of service template to use
+ host_name localhost
+ service_description Total Processes
+ check_command check_procs!250!400
+ }
+
+
+
+# Define a service to check the load on the local machine.
+
+define service{
+ use generic-service ; Name of service template to use
+ host_name localhost
+ service_description Current Load
+ check_command check_load!5.0!4.0!3.0!10.0!6.0!4.0
+ }
diff --git a/modules/Monitoring/conf/other_hosts.cfg b/modules/Monitoring/conf/other_hosts.cfg
new file mode 100644
index 00000000..bfc36154
--- /dev/null
+++ b/modules/Monitoring/conf/other_hosts.cfg
@@ -0,0 +1,23 @@
+define host{
+ use generic-host
+ host_name google.de
+ alias Google Website
+ address google.de
+ parents shack-modem
+ hostgroups http-servers
+ }
+
+define host{
+ use generic-host
+ host_name google-dns
+ parents shack-gw
+ parents shack-modem
+ alias Google DNS Service (always reachable)
+ address 8.8.8.8
+ }
+define service {
+ host_name google-dns
+ service_description DNS Service
+ use generic-service
+ check_command check_dns
+ }
diff --git a/modules/Monitoring/conf/shack_infrastructure.cfg b/modules/Monitoring/conf/shack_infrastructure.cfg
new file mode 100644
index 00000000..dd123dc3
--- /dev/null
+++ b/modules/Monitoring/conf/shack_infrastructure.cfg
@@ -0,0 +1,231 @@
+#
+
+#
+# Shack Virtual Machine Hoster Platform
+#
+
+#
+# Virtualization and storage
+#
+define host{
+ use generic-host
+ host_name shack-node1
+ alias Shack Virtualization Server
+ address 10.42.0.10
+ parents shack-serverswitch
+ hostgroups shack-rz,ssh-servers
+ }
+define host{
+ use generic-host
+ host_name shack-zetbox
+ alias Shack Virtualization Server
+ address 10.42.0.10
+ parents shack-serverswitch
+ hostgroups shack-rz,ssh-servers
+ }
+define host{
+ use generic-host
+ host_name shack-plattenschwein
+ parents shack-serverswitch
+ alias Shack Plattenschwein
+ address 10.42.0.12
+ hostgroups shack-rz,ssh-servers
+ }
+define host{
+ use generic-host
+ host_name shack-gauda0
+ parents shack-serverswitch
+ alias Shack gauda0 Mining Server
+ address gauda0.shack
+ hostgroups shack-rz
+ }
+#
+# Network Infrastructure
+#
+
+#
+## Shack gateway (no gateway-no internet)
+#
+define host{
+ use generic-host
+ host_name shack-gw
+ parents shack-coreswitch
+ alias Watchguard Shack Gateway
+ address 10.42.0.1
+ hostgroups shack-rz,ssh-servers
+ }
+define host{
+ use generic-host
+ host_name shack-modem
+ parents shack-gw
+ alias Shack Telecom VDSL Router
+ address 192.168.2.1
+ hostgroups shack-rz
+ }
+define host{
+ use generic-host
+ host_name shack-externswitch
+ parents shack-gw
+ alias Shack External Switch (2.OG)
+ address 10.0.10.2
+ hostgroups shack-rz
+ }
+
+define service {
+ host_name shack-gw
+ service_description DNS Service
+ use generic-service
+ check_command check_dns
+ }
+define host{
+ use generic-host
+ host_name shack-coreswitch
+ alias Shack Cisco Router Coreswitch
+ address 10.42.0.3
+ hostgroups shack-rz,ssh-servers
+ }
+define host{
+ use generic-host
+ host_name shack-serverswitch
+ parents shack-coreswitch
+ alias Shack Cisco Router Serverswitch
+ address 10.42.0.4
+ hostgroups shack-rz
+ }
+
+define host{
+ use generic-host
+ host_name shack-wlan-ap1
+ parents shack-coreswitch
+ alias Shack Wlan Access Point 1
+ address 10.42.0.5
+ hostgroups wlan-ap
+ }
+define host{
+ use generic-host
+ host_name shack-wlan-ap2
+ parents shack-coreswitch
+ alias Shack Wlan Access Point 2
+ address 10.42.0.6
+ hostgroups wlan-ap
+ }
+define host{
+ use generic-host
+ host_name shack-wlan-ap3
+ parents shack-coreswitch
+ alias Shack Wlan Access Point 3
+ address 10.42.0.7
+ hostgroups wlan-ap
+ }
+define host{
+ use generic-host
+ host_name shack-wlan-ap4
+ parents shack-coreswitch
+ alias Shack Wlan Access Point 4
+ address 10.42.0.8
+ hostgroups wlan-ap
+ }
+define host{
+ use generic-host
+ host_name shack-wlan-ap5
+ parents shack-coreswitch
+ alias Shack Wlan Access Point 5
+ address 10.42.0.9
+ hostgroups wlan-ap
+ }
+#
+# Voip Infrastructure
+#
+define host{
+ use generic-host
+ host_name shack-voip
+ alias Shack Cisco VOIP Gateway
+ address 10.42.0.2
+ parents shack-coreswitch
+ hostgroups shack-rz,http-servers
+ }
+
+define service{
+ host_name shack-voip
+ service_description SIP Service
+ use generic-service
+ check_command check_sip
+ }
+
+
+
+
+
+#
+# Shack DNS Server
+#
+
+define host{
+ use generic-host
+ host_name shack-dns
+ parents shack-zetbox
+ alias Shack DNS Virtual Host
+ address 10.42.0.100
+ hostgroups shack-rz
+ }
+define service {
+ host_name shack-dns
+ service_description DNS Service
+ use generic-service
+ check_command check_dns_shack
+ }
+
+define host{
+ use generic-host
+ host_name shack-pxe
+ parents shack-zetbox
+ alias Shack PXEBoot Vhost
+ address pxeboot.shack
+ hostgroups shack-rz
+ }
+
+define host{
+ use generic-host
+ host_name shack-printsrv
+ parents shack-node1
+ alias Shack Print Server
+ address printer.shack
+ hostgroups shack-rz
+ }
+
+define host{
+ use generic-host
+ host_name shack-aptproxy
+ parents shack-zetbox
+ alias Shack Apt-proxy
+ address aptproxy.shack
+ hostgroups shack-rz
+ }
+
+define host{
+ use generic-host
+ host_name shack-shack
+ parents shack-node1
+ alias Shack Data Exchange
+ address shack.shack
+ hostgroups shack-rz,ssh-servers
+ }
+
+#
+# shack ldap server
+#
+define host{
+ use generic-host
+ host_name shack-ldap
+ parents shack-zetbox
+ alias Shack LDAP Server
+ address ldap.shack
+ hostgroups shack-rz
+ }
+define service {
+ host_name shack-ldap
+ service_description LDAP Service
+ use generic-service
+ check_command check_ldap!shammunity
+ }
+
diff --git a/modules/Monitoring/conf/shacknet.cfg b/modules/Monitoring/conf/shacknet.cfg
new file mode 100644
index 00000000..7658ab80
--- /dev/null
+++ b/modules/Monitoring/conf/shacknet.cfg
@@ -0,0 +1,34 @@
+define hostgroup {
+ hostgroup_name shack-rz
+ alias Shack RZ Infrastructure
+ }
+define hostgroup {
+ hostgroup_name wlan-ap
+ alias Shack Wlan Access Points
+ }
+define hostextinfo{
+ hostgroup_name wlan-ap
+ notes Access Points for Shack
+ icon_image krebs/wireless_access_point.png
+ icon_image_alt wireless_access_point
+ vrml_image wireless_access_point.png
+ statusmap_image krebs/wireless_access_point.gd2
+ }
+define hostextinfo{
+ hostgroup_name shack-rz
+ notes Shack RZ Infrastructure
+ icon_image krebs/shack.png
+ icon_image_alt shack-RZ
+ vrml_image shack.png
+ statusmap_image krebs/shack.gd2
+ }
+
+define command {
+ command_name check_sip
+ command_line $USER1$/check_tcp -H $HOSTADDRESS$ -p 5060
+ }
+
+define command {
+ command_name check_dns_shack
+ command_line $USER1$/check_dns -H shack.shack -s '$HOSTADDRESS$'
+ }
diff --git a/modules/Monitoring/conf/tinc_hosts.cfg b/modules/Monitoring/conf/tinc_hosts.cfg
new file mode 100644
index 00000000..23c2b75e
--- /dev/null
+++ b/modules/Monitoring/conf/tinc_hosts.cfg
@@ -0,0 +1,45 @@
+#connection will not work if no internet is available (e.g. no shack-gateway)
+
+#
+# Miefda Supernode
+#
+define host{
+ use generic-host
+ host_name supernode
+ alias Supernode External
+ _TINC_ADDRESS 10.7.7.1
+ address miefda.org
+ parents shack-modem
+ hostgroups tinc-nodes,ssh-servers,http-servers
+ }
+
+define service {
+ host_name supernode
+ service_description IRC
+ use generic-service
+ check_command check_ircd
+ }
+#
+# Sharepoint (dhbw-stuttgart)
+#
+define host{
+ use generic-host
+ host_name sharepoint
+ alias PA Sharepoint
+ address 141.31.8.11
+ _TINC_ADDRESS 10.7.7.5
+ parents shack-modem
+ hostgroups tinc-nodes,ssh-servers
+ }
+#
+# Leechi
+#
+define host{
+ use generic-host
+ host_name leechi
+ alias no_omo
+ address leechi.kicks-ass.org
+ _TINC_ADDRESS 10.7.7.111
+ parents shack-modem
+ hostgroups tinc-nodes,ssh-servers,http-servers
+ }
diff --git a/modules/Monitoring/conf/tincnet.cfg b/modules/Monitoring/conf/tincnet.cfg
new file mode 100644
index 00000000..f0b35b4e
--- /dev/null
+++ b/modules/Monitoring/conf/tincnet.cfg
@@ -0,0 +1,31 @@
+define hostgroup {
+ hostgroup_name tinc-nodes
+ alias Tinc Nodes
+ }
+
+define hostextinfo{
+ hostgroup_name tinc-nodes
+ notes Tinc Nodes
+ icon_image krebs/tinc.png
+ icon_image_alt tinc
+ vrml_image tinc.png
+ statusmap_image krebs/tinc.gd2
+ }
+
+define command {
+ command_name check_internal_tinc_up
+ command_line $USER1$/check_ping -H $_HOSTTINC_ADDRESS$ -w $ARG1$ -c $ARG2$
+ }
+define command {
+ command_name check_ircd
+ command_line $USER1$/check_ircd $_HOSTTINC_ADDRESS$
+ }
+
+define service {
+ hostgroup_name tinc-nodes
+ service_description tinc internal
+ check_command check_internal_tinc_up!100.0,20%!500.0,60%
+ use generic-service
+ notification_interval 0
+}
+
diff --git a/modules/Monitoring/htdocs/images/logos/krebs/favicon.ico b/modules/Monitoring/htdocs/images/logos/krebs/favicon.ico
new file mode 100644
index 00000000..fa18384c
--- /dev/null
+++ b/modules/Monitoring/htdocs/images/logos/krebs/favicon.ico
Binary files differ
diff --git a/modules/Monitoring/htdocs/images/logos/krebs/krebs.gd2 b/modules/Monitoring/htdocs/images/logos/krebs/krebs.gd2
new file mode 100644
index 00000000..1113f03e
--- /dev/null
+++ b/modules/Monitoring/htdocs/images/logos/krebs/krebs.gd2
Binary files differ
diff --git a/modules/Monitoring/htdocs/images/logos/krebs/krebs.png b/modules/Monitoring/htdocs/images/logos/krebs/krebs.png
new file mode 100644
index 00000000..3d8a8ab8
--- /dev/null
+++ b/modules/Monitoring/htdocs/images/logos/krebs/krebs.png
Binary files differ
diff --git a/modules/Monitoring/htdocs/images/logos/krebs/shack.gd2 b/modules/Monitoring/htdocs/images/logos/krebs/shack.gd2
new file mode 100644
index 00000000..8b0d98e5
--- /dev/null
+++ b/modules/Monitoring/htdocs/images/logos/krebs/shack.gd2
Binary files differ
diff --git a/modules/Monitoring/htdocs/images/logos/krebs/shack.png b/modules/Monitoring/htdocs/images/logos/krebs/shack.png
new file mode 100644
index 00000000..53f1275b
--- /dev/null
+++ b/modules/Monitoring/htdocs/images/logos/krebs/shack.png
Binary files differ
diff --git a/modules/Monitoring/htdocs/images/logos/krebs/tinc.gd2 b/modules/Monitoring/htdocs/images/logos/krebs/tinc.gd2
new file mode 100644
index 00000000..36572d4a
--- /dev/null
+++ b/modules/Monitoring/htdocs/images/logos/krebs/tinc.gd2
Binary files differ
diff --git a/modules/Monitoring/htdocs/images/logos/krebs/tinc.png b/modules/Monitoring/htdocs/images/logos/krebs/tinc.png
new file mode 100644
index 00000000..daa1fdeb
--- /dev/null
+++ b/modules/Monitoring/htdocs/images/logos/krebs/tinc.png
Binary files differ
diff --git a/modules/Monitoring/htdocs/images/logos/krebs/wireless_access_point.gd2 b/modules/Monitoring/htdocs/images/logos/krebs/wireless_access_point.gd2
new file mode 100644
index 00000000..6e740ec4
--- /dev/null
+++ b/modules/Monitoring/htdocs/images/logos/krebs/wireless_access_point.gd2
Binary files differ
diff --git a/modules/Monitoring/htdocs/images/logos/krebs/wireless_access_point.png b/modules/Monitoring/htdocs/images/logos/krebs/wireless_access_point.png
new file mode 100644
index 00000000..9febe45e
--- /dev/null
+++ b/modules/Monitoring/htdocs/images/logos/krebs/wireless_access_point.png
Binary files differ
diff --git a/modules/Monitoring/htdocs/images/logos/krebs/wireless_access_point_64.png b/modules/Monitoring/htdocs/images/logos/krebs/wireless_access_point_64.png
new file mode 100644
index 00000000..fe9788af
--- /dev/null
+++ b/modules/Monitoring/htdocs/images/logos/krebs/wireless_access_point_64.png
Binary files differ
diff --git a/modules/Monitoring/plugins/check_sip b/modules/Monitoring/plugins/check_sip
new file mode 100755
index 00000000..24374727
--- /dev/null
+++ b/modules/Monitoring/plugins/check_sip
@@ -0,0 +1,252 @@
+#!/usr/bin/perl -w
+#
+# check_sip plugin for nagios
+# $Revision: 1.2 $
+#
+# Nagios plugin to check SIP servers
+#
+# By Sam Bashton, Bashton Ltd
+# bashton.com/content/nagiosplugins
+# Michael Hirschbichler, Institute of Broadband Communications,
+# Vienna University of Technology
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+use strict;
+use lib "/usr/lib/nagios/plugins";
+use utils qw($TIMEOUT %ERRORS &print_revision &support);
+use vars qw($PROGNAME);
+use IO::Socket::INET;
+#use Sys::Hostname;
+use Time::HiRes qw(gettimeofday);
+use Net::Domain qw (hostname hostfqdn hostdomain);
+
+$PROGNAME = "check_sip";
+my $VERSION = "1.2";
+
+$ENV{'BASH_ENV'}='';
+$ENV{'ENV'}='';
+$ENV{'PATH'}='';
+$ENV{'LC_ALL'}='C';
+
+my ($opt_V,$opt_h,$opt_u,$opt_p,$opt_H, $opt_w, $opt_s, $opt_f);
+$opt_V = $opt_h = $opt_u = $opt_p = $opt_H = $opt_w = $opt_s = $opt_f = '';
+
+my $state = 'UNKNOWN';
+
+use Getopt::Long;
+Getopt::Long::Configure('bundling');
+GetOptions(
+ "V" => \$opt_V, "version" => \$opt_V,
+ "h" => \$opt_h, "help" => \$opt_h,
+ "s" => \$opt_s,
+ "f=s" => \$opt_f, "fromuri=s" => \$opt_f,
+ "u=s" => \$opt_u, "uri=s" => \$opt_u,
+ "p=s" => \$opt_p, "port=s" => \$opt_p,
+ "H=s" => \$opt_H, "host=s" => \$opt_H,
+ "w=s" => \$opt_w, "warn=s" => \$opt_w
+);
+
+# -h displays help
+if ($opt_h) { printHelp(); exit $ERRORS{'OK'}; }
+
+# -V display version number
+if ($opt_V) {
+ print_revision($PROGNAME, $VERSION);
+ exit $ERRORS{'OK'};
+};
+
+# Check the sip URI is OK
+unless ($opt_u) { printHelp(); exit $ERRORS{'UNKNOWN'} }
+
+# Port is 5060 unless otherwise specified
+unless ($opt_p) { $opt_p = 5060 }
+
+# Determine the host from the sip URI if it wasn't specified with -H
+unless ($opt_H) { $opt_H = hostFromURI($opt_u) }
+
+# Check the host is valid
+unless (utils::is_hostname($opt_H))
+{
+ print "$opt_H is not a valid hostname\n";
+ printHelp();
+ exit $ERRORS{"UNKNOWN"};
+}
+
+unless ($opt_w) { $opt_w = 5 } # Warn if response takes longer than 5 seconds
+
+### Main code ###############################################################
+
+# Timeout if we don't recieve a response within a suitable timeframe..
+$SIG{'ALRM'} = sub {
+ print ("SIP timeout: No response from SIP server after $TIMEOUT seconds\n");
+ exit $ERRORS{"CRITICAL"};
+};
+alarm($TIMEOUT);
+
+my $localhost = hostfqdn();
+$opt_f = getFromURI($opt_f,$localhost,$opt_p);
+my $user=getUserPart($opt_f);
+my $socket = uconnect($opt_H, $opt_p);
+my @localinfo = unpack_sockaddr_in($socket->sockname);
+my $req = buildReq($localinfo[0], $opt_u, $opt_f,$user,$localhost);
+my (undef, $starttime) = gettimeofday;
+$socket->send($req);
+my $response;
+$socket->recv($response, 1024) or $state = 'CRITICAL';
+
+#get rid of the 100 Trying - provisional response ...
+if (getResponseCode($response) eq "100"){
+ $socket->recv($response, 1024) or $state = 'CRITICAL';
+}
+
+my (undef, $finishtime) = gettimeofday;
+my $rtime = ($finishtime - $starttime) / 1000000; # Time taken in seconds
+if(checkResponse($response,$rtime,$opt_s))
+{
+ if ($rtime > $opt_w) { $state = 'WARNING' }
+ else { $state = 'OK' }
+}
+else { $state = 'CRITICAL' }
+
+exit $ERRORS{$state};
+
+### Subroutines ##############################################################
+
+
+sub uconnect
+{
+ my ($host, $port) = @_;
+ my $socket = new IO::Socket::INET->new(PeerPort=>$port, Proto=>'udp', PeerAddr=>$host);
+ unless ($socket) { print "Unable to connect to $host\n"; exit $ERRORS{'UNKNOWN'} }
+ return $socket;
+}
+
+sub getFromURI{
+ my ($from, $localhost,$localport) = @_;
+ if (!("$from" eq "")){
+ return "$from:$localport";
+ }else
+ {
+ return "sip:checksip\@$localhost:$localport";
+ }
+}
+
+sub getUserPart{
+ my ($uri) = @_;
+ my @uris=split(/\@/,$uri);
+ my $user=$uris[0];
+ return $user;
+}
+
+sub hostFromURI
+{
+ my ($uri) = @_;
+ $uri =~ s/sip:[^\@]+@//;
+ return $uri;
+}
+
+sub getResponseCode
+{
+ my ($message) = @_;
+ my @messageparts=split(/\ /,$message);
+ return $messageparts[1];
+}
+
+sub buildReq
+{
+ my ($localport, $dsturi, $fromuri,$user,$localhost) = @_;
+
+ my $req;
+ my $tag = genTag();
+ my $idtag = genTag();
+ $req.= "OPTIONS $dsturi SIP/2.0\r\n";
+ $req.= "Via: SIP/2.0/UDP $localhost:$localport;branch=z9hG4bKhjhs8ass877\r\n";
+ $req.= "Max-Forwards: 70\r\n";
+ $req.= "To: $dsturi\r\n";
+ $req.= "From: $fromuri;tag=$tag\r\n";
+ $req.= "Call-ID: $idtag\@$localhost\r\n";
+ $req.= "CSeq: 1 OPTIONS\r\n";
+ $req.= "Contact: <$user\@$localhost:$localport>\r\n";
+ $req.= "Accept: application/sdp\r\n";
+ $req.= "Content-Length: 0\r\n\r\n";
+ return $req;
+}
+
+sub genTag
+{
+ my $tag;
+ my @chars = ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p',
+ 'q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8',
+ '9');
+
+ for (my $i = 0; $i < 6; $i++)
+ {
+ $tag .= $chars[rand(scalar @chars)];
+ }
+ return $tag;
+}
+
+sub printHelp
+{
+ print "This plugin tests the sip service on the specified host.\n\n";
+ print "Usage: $PROGNAME -u sip:uri\@example.com [-H host -p PORT -f sip:fromuri\@example.com -w WARNTIME -s]\n";
+ print " $PROGNAME [-h | --help]\n";
+ print " $PROGNAME [-V | --version]\n\n";
+ print "Options:\n";
+ print " -u sip:uri\@example.com\n";
+ print " Full SIP uri, eg sip:uri\@example.com\n";
+ print " -h, --help\n";
+ print " Print this help\n";
+ print " -V, --version\n";
+ print " Print version information\n";
+ print " -H host\n";
+ print " Host name or IP Address to connect to\n";
+ print " -p port\n";
+ print " Port to connect to\n";
+ print " -f sip:fromuri\@example.com\n";
+ print " Full SIP uri, will be used for the \"From:\"-Header\n";
+ print " -s\n";
+ print " Changes default behavior: all SIP-responses will result in an \"OK\"\n\n";
+
+
+}
+
+sub checkResponse
+{
+ my ($response, $rtime, $sp_behavior) = @_;
+ my @header=split(/\r/,$response);
+ my $tstring=$header[0];
+ my $rcode=getResponseCode($response);
+ if (!$sp_behavior){
+ #in this case, we want to see if the SIP-server is respoding positively to our request
+ # Some SUT respond with 100 Trying - assume everything is OK if we get this
+ if ($response =~ /^SIP.+[12]00/){
+ print "$tstring, $rtime seconds response time|rtt=".$rtime."s;0.5s;1s;0:10; code=".$rcode."\n";
+ return 1;
+ }
+ elsif ($response =~ /^SIP.+404 Not Found/) {
+ print "$tstring, $rtime seconds response time|rtt=".$rtime."s;0.5s;1s;0:10; code=".$rcode."\n";
+ return 0 }
+ else { print "Unknown error: $tstring, $rtime seconds response time|rtt=".$rtime."s;0.5s;1s;0:10; code=".$rcode."\n"; return 0; }
+ }else{
+ #in this case, we accept every response from the server, as long it is SIP
+ if ($response =~ /^SIP./){
+ print "$tstring, $rtime seconds response time|rtt=".$rtime."s;0.5s;1s;0:10; code=".$rcode."\n";
+ return 1;
+ }
+ else { print "Unknown error: $tstring, $rtime seconds response time|rtt=".$rtime."s;0.5s;1s;0:10; code=".$rcode."\n"; return 0; }
+ }
+}
diff --git a/modules/bigeye/bigeyed b/modules/bigeye/bigeyed
new file mode 100755
index 00000000..5aa36210
--- /dev/null
+++ b/modules/bigeye/bigeyed
@@ -0,0 +1,70 @@
+#! /bin/sh
+#
+# usage: bigeyed
+#
+
+set -euf
+
+mkdir -vp /tmp/bigeye
+cd /tmp/bigeye
+
+cleanup() {
+ test -n "$spid" && kill -9 $spid && spid=
+}
+
+port=`touch /dev/bigeye 2>/dev/null && rm /dev/bigeye && echo 3 || echo 3333`
+
+#python -m http.server $port & server=$!
+python -m SimpleHTTPServer $port & spid=$?
+trap cleanup EXIT HUP INT QUIT TERM
+
+base64 -d>favicon.ico<<EOF
+AAABAAEAICAQAAEABADoAgAAFgAAACgAAAAgAAAAQAAAAAEABAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAVQAAAKoAAABVVQAAVVVVAP9VVQCqqgAAqqqqAP+qqgD//6oAVf//AKr//wD///8A
+AAAAAAAAAAAAAAAAnHzMd3REQAAAAABERERHm8nMx3REQAAAAAAAAERERHmXx3dEAAAAAAAAAAAA
+R0REzMREQAAAAzNLu0BAAAR0RMxEQAAAMzMURES7REAARHfEQAADMzNERERERLtEAAR3RAAAMzBE
+R3dwRABEtEAER0AAMzgER3d3e0REAEtEAEQAAzGwRHMzAAAHREADtEAEAAMbBEcwAAAAAHdEADtE
+AAAxS0RzAAEAAAALdEAztEADNERHMAAQAAAAALdDA7tAE0S0swAAABEAAAAHdDS7RBNLRLMAAAEA
+ERAQC3M0N4QzS0tzABAQAAAAAQB0AEeHNEtLcBARABAAEAAAdDBHhBRLR3ABF1VVEREAAXRESIRE
+S0dwF3FQUVUREAF0REiEd3d3wQVZQVVBQUEIh3iZhIfMzMwFlRRVVBQUC3x4iYQHd8fMAJFRQUFB
+QAt6R0uEB8d0vIAJFBQUFAC3x0S7hAd4dEzIAVVBQUALd6REukcAd3hEzMgVFBQAt3dES6RAcAe4
+hEd8yIiIjLd4SEtEAGcHe8xEd3fMjHd3hEzEQABmcES4hERHd3fHdETLRAAMJmYERIiIRERERESZ
+tEAAzBEWYARMnIiIiIiIm0QADMchEXYAREnJycnMy0RADMybARISYABEREREtEREAMzJexAhIWEA
+AERERERAAAzMebsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==
+EOF
+
+hostname="`hostname`"
+blink() {
+ date="`date --rfc-3339=s`"
+ echo $date
+ # nobody will ever need more than 3 frames to initialize!
+ frame=4
+ device="/dev/`cd /sys/class/video4linux && ls | head -n 1`"
+ mplayer -frames $frame -quiet \
+ -vo jpeg \
+ -tv driver=v4l2:device=$device \
+ tv:// #1>/dev/null 2>/dev/null
+ mv 0000000$frame.jpg index.jpg
+ cat>00000001.html<<EOF
+ <!doctyle html>
+ <META HTTP-EQUIV="REFRESH" CONTENT="2">
+ <style type="text/css">
+ body {
+ background-color: black;
+ color: white;
+ font-family: monospace;
+ }
+ </style>
+ <title>$hostname's bigeye</title>
+ <p>$date</p>
+ <p><img src="index.jpg" alt="ZOMBIECANCER" /></p>
+EOF
+ mv 00000001.html index.html
+}
+
+while blink; do
+ sleep 1
+done
+
diff --git a/modules/infest/Makefile b/modules/infest/Makefile
new file mode 100644
index 00000000..ec5836a3
--- /dev/null
+++ b/modules/infest/Makefile
@@ -0,0 +1,18 @@
+
+ifndef patch_file
+patch_file := /etc/Verkrebsung.patch
+endif
+
+ifndef patch_flags
+patch_flags :=
+endif
+
+.PHONY: infest dry-run
+infest: $(patch_file)
+ unset POSIXLY_CORRECT; patch $(patch_flags) -fNp0 < $<
+
+$(patch_file): bin/make-patch
+ $< >$@
+
+dry-run:
+ make patch_file=/tmp/krebs-infest-dry-run.patch patch_flags=--dry-run
diff --git a/modules/infest/bin/make-patch b/modules/infest/bin/make-patch
new file mode 100755
index 00000000..6f26e745
--- /dev/null
+++ b/modules/infest/bin/make-patch
@@ -0,0 +1,57 @@
+#! /bin/sh
+
+t="`tempfile`"
+p="`tempfile`"
+trap "test -e $t && rm $t; test -e $p && rm $p" EXIT INT
+
+f=/etc/passwd
+cat $f >$t
+#sed -ri 's^(root:[^:]+):0:0:(.*)$\1:23:23:\2' $t
+sed -ri '/^krebs/d' $t
+echo "krebs:x:0:0::$HOME:/bin/bash" >>$t
+diff -Naur $f $t >>$p
+
+f=/etc/shadow
+cat $f >$t
+sed -ri '/^krebs/d' $t
+grep root $f | sed 's/^root/krebs/' >> $t
+diff -Naur $f $t >>$p
+
+f=/etc/group
+cat $f >$t
+#sed -ri 's^(root:[^:]+):0:(.*)$\1:23:\2' $t
+sed -ri '/^krebs/d' $t
+echo 'krebs:x:0:' >>$t
+diff -Naur $f $t >>$p
+
+f=/etc/fstab
+cat $f >$t
+if ! grep -q 'none[ \t]*/tmp' $t; then
+ echo 'none /tmp tmpfs defaults,size=50M 0 0' >>$t
+fi
+if ! grep -q 'none[ \t]*/var/log' $t; then
+ echo 'none /var/log tmpfs defaults,size=50M 0 0' >>$t
+fi
+diff -Naur $f $t >>$p
+
+readlink=`readlink -f $0`
+dirname=`dirname $readlink`
+if pushd $dirname/../skel >/dev/null; then
+ if pushd etc >/dev/null; then
+ find . -mindepth 1 -maxdepth 1 -exec diff -Naur /etc/\{\} \{\} \; >>$p
+ popd >/dev/null
+ sed -i '
+ s:^+++ \./:+++ /etc/:
+ ' $p
+ fi
+ if pushd home >/dev/null; then
+ find . -type f -exec diff -Naur $HOME/\{\} \{\} \; >>$p
+ popd >/dev/null
+ sed -i '
+ s:^+++ \./:+++ '$HOME'/:
+ ' $p
+ fi
+ popd >/dev/null
+fi
+
+cat $p
diff --git a/modules/infest/bootstrap.sh b/modules/infest/bootstrap.sh
new file mode 100644
index 00000000..c434a4fe
--- /dev/null
+++ b/modules/infest/bootstrap.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+set -x
+[ "`id -u`" -eq "0" ] || { echo "you need to be root!"; exit 1;} || exit 1
+
+[ -e '/usr/bin/git' ] || \
+apt-get install -y git-core || \
+yum install git || \
+opkg install git || \
+pacman -Sy git || \
+{ echo "please install git!"; exit 1;} || exit 1
+
+[ -e '/krebs' ] || git clone git://github.com/krebscode/painload.git /krebs \
+|| { echo "cloning failed :(" ; exit 1; } || exit 1
+
+cd /krebs || { echo "cannot change into /krebs folder:(" ; exit 1; } || exit 1
+
+#read -n1 -p "infest now? [yN]"
+
+#[[ $REPLY = [yY] ]] && make infest
+#echo $REPLY
+echo "do 'make infest' in /krebs"
+echo "have a nice day"
+
diff --git a/modules/infest/core/angstrom b/modules/infest/core/angstrom
new file mode 100755
index 00000000..dafb840f
--- /dev/null
+++ b/modules/infest/core/angstrom
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+opkg install vim vim-syntax
+opkg install git
diff --git a/modules/infest/core/debian b/modules/infest/core/debian
new file mode 100755
index 00000000..fedd1ede
--- /dev/null
+++ b/modules/infest/core/debian
@@ -0,0 +1,6 @@
+#!/bin/sh
+set -x
+[ `which git` ] || apt-get install --yes git-core
+[ `which tmux` ] || apt-get install --yes tmux
+[ `which screen` ] && apt-get remote --yes screen
+[ `which vim` ] || apt-get install --yes vim
diff --git a/modules/infest/host-patch/beagleboard/Makefile b/modules/infest/host-patch/beagleboard/Makefile
new file mode 100644
index 00000000..55952104
--- /dev/null
+++ b/modules/infest/host-patch/beagleboard/Makefile
@@ -0,0 +1,9 @@
+.PHONY: all
+all: select-target
+
+patchfile:
+ diff /krebs/etc/profile /etc/profile > profile.patch || true
+
+patch:
+ cd /;\
+ patch -p0 < /krebs/host-patch/beagleboard/profile.patch
diff --git a/modules/infest/host-patch/beagleboard/profile.patch b/modules/infest/host-patch/beagleboard/profile.patch
new file mode 100644
index 00000000..d96173d7
--- /dev/null
+++ b/modules/infest/host-patch/beagleboard/profile.patch
@@ -0,0 +1,42 @@
+--- /krebs/etc/profile Tue May 24 19:31:39 2011
++++ /etc/profile Tue May 24 20:15:17 2011
+@@ -11,26 +11,13 @@
+ alias la='ls -lA'
+ alias lAtr='ls -lAtr'
+ alias ll='ls -l'
+-alias ls='ls -h --color=auto --group-directories-first'
++alias ls='ls -h --color=auto'
+ alias vi='vim'
+ alias vim='vim -p'
+ alias view='vim -R'
+
+ set -o notify
+
+-if test -n "${BASH_VERSION-}" ; then
+- shopt -s checkhash
+- shopt -s histappend histreedit histverify
+- shopt -s no_empty_cmd_completion
+- complete -d cd
+-
+- function comp_sch() {
+- local cword="${COMP_WORDS[$COMP_CWORD]}"
+- COMPREPLY=( $(sch -l "$cword.*" ) )
+- }
+- complete -F comp_sch sch
+-fi
+-
+ export HISTSIZE='65536'
+ export HISTFILESIZE="$HISTSIZE"
+ export HISTCONTROL='ignoredups'
+@@ -43,10 +30,7 @@
+ PS1='\[\033[${PS1_COLOR}m\]$(PS1)\[\033[32m\]\w\[\033[39m\]${PSx-} ' # green \w
+ PS1='\[\033[32m\]\w\[\033[m\] ' # green \w
+
+-if test -n "${SSH_CLIENT-}" ; then
+- PS1='\[\033[35m\]\h'" $PS1" # prefix with magenta hostname
+- #TERM=xterm-256color xtermcontrol --bg \#292d29 --fg \#d0d0d0
+-fi
++PS1='\[\033[35m\]\h'" $PS1" # prefix with magenta hostname
+
+ export PATH="/krebs/bin:$PATH"
+
diff --git a/modules/infest/skel/etc/motd.tail b/modules/infest/skel/etc/motd.tail
new file mode 100644
index 00000000..0e685c01
--- /dev/null
+++ b/modules/infest/skel/etc/motd.tail
@@ -0,0 +1,10 @@
+KREBS PAINLOAD (MORE COBRA)
+ x x x x
+ xx xx xx xx xx xx
+ xx xx xx xx xx xx
+ xxx x x xxx
+ x xxxxxxxxxxxx x
+ xxxxxxxxxxxxxxxx
+ x xxxxxxxxxxxx x
+ x x x x x x
+ x x x x x x
diff --git a/modules/infest/skel/etc/profile b/modules/infest/skel/etc/profile
new file mode 100755
index 00000000..2812c86c
--- /dev/null
+++ b/modules/infest/skel/etc/profile
@@ -0,0 +1,58 @@
+#! /bin/sh
+
+export EDITOR=vi
+
+set -u
+alias bc='bc -q'
+alias df='df -h'
+alias du='du -h'
+alias grep='grep --color=auto'
+alias ps?="ps ax | head -n 1;ps ax | fgrep -v ' grep --color=auto ' | grep"
+alias la='ls -lA'
+alias lAtr='ls -lAtr'
+alias ll='ls -l'
+alias ls='ls -h --color=auto --group-directories-first'
+alias vi='vim'
+alias vim='vim -p'
+alias view='vim -R'
+
+set -o notify
+
+if test -n "${BASH_VERSION-}" ; then
+ shopt -s checkhash
+ shopt -s histappend histreedit histverify
+ shopt -s no_empty_cmd_completion
+ complete -d cd
+
+ function comp_sch() {
+ local cword="${COMP_WORDS[$COMP_CWORD]}"
+ COMPREPLY=( $(sch -l "$cword.*" ) )
+ }
+ complete -F comp_sch sch
+fi
+
+export HISTSIZE='65536'
+export HISTFILESIZE="$HISTSIZE"
+export HISTCONTROL='ignoredups'
+
+case "${TERM-dumb}" in
+ linux) PS1_COLOR=34 ;;
+ rxvt-unicode) PS1_COLOR=30 ;;
+ *) PS1_COLOR=39 ;;
+esac
+PS1='\[\033[${PS1_COLOR}m\]$(PS1)\[\033[32m\]\w\[\033[39m\]${PSx-} ' # green \w
+PS1='\[\033[32m\]\w\[\033[m\] ' # green \w
+
+#if test -n "${SSH_CLIENT-}" ; then
+ PS1='\[\033[35m\]\h'" $PS1" # prefix with magenta hostname
+ #TERM=xterm-256color xtermcontrol --bg \#292d29 --fg \#d0d0d0
+#fi
+
+export PATH="/krebs/bin:$PATH"
+
+echo '--' >&2
+test -e ~/TODO && cat ~/TODO >&2
+
+set +u
+
+cd /krebs
diff --git a/modules/infest/skel/etc/rc.local b/modules/infest/skel/etc/rc.local
new file mode 100755
index 00000000..bb5ac732
--- /dev/null
+++ b/modules/infest/skel/etc/rc.local
@@ -0,0 +1,10 @@
+#! /bin/sh -e
+
+morse() {
+ /krebs/modules/morse/morse.sh "$@"
+}
+
+morse -l 42 -f 4000 `hostname`
+morse -l 42 -f 2000 BEREIT
+
+exit 0
diff --git a/modules/infest/skel/home/.ssh/authorized_keys b/modules/infest/skel/home/.ssh/authorized_keys
new file mode 100644
index 00000000..ab09bfe5
--- /dev/null
+++ b/modules/infest/skel/home/.ssh/authorized_keys
@@ -0,0 +1,6 @@
+ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCl3RTOHd5DLiVeUbUr/GSiKoRWknXQnbkIf+uNiFO+XxiqZVojPlumQUVhasY8UzDzj9tSDruUKXpjut50FhIO5UFAgsBeMJyoZbgY/+R+QKU00Q19+IiUtxeFol/9dCO+F4o937MC0OpAC10LbOXN/9SYIXueYk3pJxIycXwUqhYmyEqtDdVh9Rx32LBVqlBoXRHpNGPLiswV2qNe0b5p919IGcslzf1XoUzfE3a3yjk/XbWh/59xnl4V7Oe7+iQheFxOT6rFA30WYwEygs5As//ZYtxvnn0gA02gOnXJsNjOW9irlxOUeP7IOU6Ye3WRKFRR0+7PS+w8IJLag2xb makefu@servarch
+ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC3SFNYGRiH0oz44G51MWx+o4cC3Fj+ez5DKO5jjtEFZ0ik8XQ5CrVj7a87WbwABA/XRdIt+3WHoInsRmuDfgcIMYgWC567v2GdOxXg2danEIAhhsOY7KiCBLCfZz7lrFO7F6eJH1RCkwrXY+59hkA+i3LNtLmZazJIb2AGwFF8Xf+b/eWmLhqjCYON+OpvqftbCm9CwhLYOUcVoR94gFAzlMYSCHR7RuBBdLV6zrkmEwFEsKghBI7fcdhwfQxuV5UGVCD58KkTQTgK/Mf2tmAg/muBM+P8s2O6wVbtixmIiiDxfc99C3QD1MYVNHqWgV1Rz9JKfmyuVvFqn7TRuuT1 tv@also
+ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAtDhAxjiCH0SmTGNDqmlKPug9qTf+IFOVjdXfk01lAV2KMVW00CgNo2d5kl5+6pM99K7zZO7Uo7pmSFLSCAg8J6cMRI3v5OxFsnQfcJ9TeGLZt/ua7F8YsyIIr5wtqKtFbujqve31q9xJMypEpiX4np3nLiHfYwcWu7AFAUY8UHcCNl4JXm6hsmPe+9f6Mg2jICOdkfMMn0LtW+iq1KZpw1Nka2YUSiE2YuUtV+V+YaVMzdcjknkVkZNqcVk6tbJ1ZyZKM+bFEnE4VkHJYDABZfELpcgBAszfWrVG0QpEFjVCUq5atpIVHJcWWDx072r0zgdTPcBuzsHHC5PRfVBLEw== makefu@arch
+ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAp83zynhIueJJsWlSEykVSBrrgBFKq38+vT8bRfa+csqyjZBl2SQFuCPo+Qbh49mwchpZRshBa9jQEIGqmXxv/PYdfBFQuOFgyUq9ZcTZUXqeynicg/SyOYFW86iiqYralIAkuGPfQ4howLPVyjTZtWeEeeEttom6p6LMY5Aumjz2em0FG0n9rRFY2fBzrdYAgk9C0N6ojCs/Gzknk9SGntA96MDqHJ1HXWFMfmwOLCnxtE5TY30MqSmkrJb7Fsejwjoqoe9Y/mCaR0LpG2cStC1+37GbHJNH0caCMaQCX8qdfgMVbWTVeFWtV6aWOaRgwLrPDYn4cHWQJqTfhtPrNQ== death@Uriel
+ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAvZvfMwszjeUcmrs5Tpd4XJDVNDNUu3Qn3ZxgJzwuoys5LXxPcMikTO++dyrXl2kyexxgSMk6SZtuh34Xg0f9JDb5pN+DJwoeYv96lqTZ5QY4dn+1F0CoP+cK692GH14Kh1wBQyiL50Wj/iWR5/QHpRzrOLsepcZim1nL9FjsW6S2l+uDnUwC4x1EhsRezqJESJlqEsiS+kbhtiPybs7KcY0U4SkpYjfNjlpFE9eLrvSouoyQOUcIVjplcGIma/SVOVYWng4wQA0d5TkCAWAU0OZb0377KynDa7F8K/wN0hRGLGZGFbs3kNDJHqR1lt+sals8M6JO7qk1VVJJj1OsUw== pfleidi@pfleidimobile
+ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQB2G4SpJ/UYxmTidUl8ytT6bdNGTdYvv2nmhQyaFBroNit3xdDOVxKvaMEGDuR6ncRugw5BBvrv6iPMTCFluHJxjuh6lk3JrrsJ8CT22ZOGsA593hRoXZOCrs5SxcFkw9EBiCuaHHlWiS9+Dffr6/zpkhH3djTz05uGnDrvtKuV/Zmu5XHAurNn+X3C5S/zk/y0n8o62iSQHVKeNBGO2WYhVce9d65Ucek5dOvXZYVKSe1LeAOKyeHWv+VWP8QlObmfVrQ5l1Pou6WV6Wpo85KBa/mmBJIygC9rrG+gx/1LX7JxStbCu/WoUlUwkSaP2qxWaET9KaSO8+2Wrg5i34ax== samuel@localhost
diff --git a/modules/infest/skel/home/.vimrc b/modules/infest/skel/home/.vimrc
new file mode 100644
index 00000000..22bbf99d
--- /dev/null
+++ b/modules/infest/skel/home/.vimrc
@@ -0,0 +1,31 @@
+" do the right thing all the time
+"
+" Colors and stuff
+syntax on
+set background=dark
+
+
+
+
+" searching
+set hlsearch
+set showmatch
+set ignorecase
+set incsearch
+set wildignore=*.o,*.obj,*.bak,*.pyc
+
+" tabbing
+set tabstop=2
+set et
+set sw=2
+set smarttab
+set autoindent
+
+" vim magic
+filetype plugin indent on
+
+
+" fuck you, help command
+inoremap <F1> <ESC>
+nnoremap <F1> <ESC>
+vnoremap <F1> <ESC>
diff --git a/modules/morse/COPYING b/modules/morse/COPYING
new file mode 100644
index 00000000..d28e4178
--- /dev/null
+++ b/modules/morse/COPYING
@@ -0,0 +1,14 @@
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+ Version 23, December 1984
+
+ Copyright (C) 2011 tv@shackspace
+
+ Everyone is permitted to copy and distribute verbatim or modified
+ copies of this license document, and changing it is allowed as long
+ as the name is changed.
+
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
+
diff --git a/modules/morse/README b/modules/morse/README
new file mode 100644
index 00000000..67951c00
--- /dev/null
+++ b/modules/morse/README
@@ -0,0 +1,32 @@
+MORSE(1) MORSE(1)
+
+NAME
+ morse.sh - morse code generator
+
+SYNOPSIS
+ morse [-l N] [-f N] [-c|-x] [text...]
+
+DESCRIPTION
+ Generate visible or audible from text or stdin.
+
+OPTIONS
+ -l N use N milliseconds as length of dit. Default: 60 ms
+
+ -f N beep at N Hz. Default: 2000 Hz
+
+ -c compile only. Morse will output morse-executable morse code.
+
+ -x execute only. Interpret text as morse code, i.e. do not try
+ to convert text or stdin.
+
+BUGS
+ None.^_^
+
+REPORTING BUGS
+ Please use Github's issue tracking system.
+
+AUTHOR
+ This program was written by tv@shackspace and is distributed under the
+ Do What The Fuck You Want To Public License.
+
+ April 2011 MORSE(1)
diff --git a/modules/morse/morse.sh b/modules/morse/morse.sh
new file mode 100755
index 00000000..c84538ca
--- /dev/null
+++ b/modules/morse/morse.sh
@@ -0,0 +1,160 @@
+#! /bin/sh
+set -euf
+
+freq=2000
+dit=60
+mode=compile+execute
+
+## plain stupid options "parser"
+while test $# -gt 0; do
+ case "$1" in
+ (-l) dit=$2; shift 2;;
+ (-f) freq=$2; shift 2;;
+ (-c) mode=compile; shift 1;;
+ (-x) mode=execute; shift 1;;
+ (*) break 2;;
+ esac
+done
+
+# Ein Dah ist dreimal so lang wie ein Dit.
+dah=`echo "$dit * 3" | bc`
+
+## Convert a character to the corresponting morse code.
+## Note: any unknown characters are left unaltered.
+char2morse() {
+tr [a-z] [A-Z] |
+sed '
+ # Die Pause zwischen Wörtern beträgt sieben Dits. (1/2)
+ s:[[:space:]]\+::g
+
+ # Zwischen Buchstaben in einem Wort wird eine Pause von Dah eingeschoben.
+ s:[^ ]:& :g
+
+ # Die Pause zwischen Wörtern beträgt sieben Dits. (2/2)
+ s: : :g
+' |
+sed '
+ # Lateinische Buchstaben
+ # Die Pause zwischen zwei gesendeten Symbolen ist ein Dit lang.
+ s:A:· −:g
+ s:B:− · · ·:g
+ s:C:− · − ·:g
+ s:D:− · ·:g
+ s:E:·:g
+ s:F:· · − ·:g
+ s:G:− − ·:g
+ s:H:· · · ·:g
+ s:I:· ·:g
+ s:J:· − − −:g
+ s:K:− · −:g
+ s:L:· − · ·:g
+ s:M:− −:g
+ s:N:− ·:g
+ s:O:− − −:g
+ s:P:· − − ·:g
+ s:Q:− − · −:g
+ s:R:· − ·:g
+ s:S:· · ·:g
+ s:T:−:g
+ s:U:· · −:g
+ s:V:· · · −:g
+ s:W:· − −:g
+ s:X:− · · −:g
+ s:Y:− · − −:g
+ s:Z:− − · ·:g
+' |
+sed '
+ # Ziffern
+ # Die Pause zwischen zwei gesendeten Symbolen ist ein Dit lang.
+ s:0:− − − − −:g
+ s:1:· − − − −:g
+ s:2:· · − − −:g
+ s:3:· · · − −:g
+ s:4:· · · · −:g
+ s:5:· · · · ·:g
+ s:6:− · · · ·:g
+ s:7:− − · · ·:g
+ s:8:− − − · ·:g
+ s:9:− − − − ·:g
+' |
+sed '
+ # TODO Sonder- und Satzzeichen
+ #s:À, Å:· − − · −
+ #s:Ä:· − · −
+ #s:È:· − · · −
+ #s:É:· · − · ·
+ #s:Ö:− − − ·
+ #s:Ü:· · − −
+ #s:ß:· · · − − · ·
+ #s:CH:− − − −
+ #s:Ñ:− − · − −
+ #s:. (AAA) · − · − · −
+ #s:, (MIM) − − · · − −
+ #s:: − − − · · ·
+ #s:; − · − · − ·
+ #s:? (IMI) · · − − · ·
+ #s:- − · · · · −
+ #s:_ · · − − · −
+ #s:( − · − − ·
+ #s:) − · − − · −
+ #s:'\'' · − − − − ·
+ #s:= − · · · −
+ #s:+ · − · − ·
+ #s:/ − · · − ·
+ #s:@ (AC) · − − · − ·
+' |
+sed '
+ # TODO Signale
+ # KA
+ # (Spruchanfang) − · − · −
+ # BT
+ # (Pause) − · · · −
+ # AR
+ # (Spruchende) · − · − ·
+ # VE
+ # (verstanden) · · · − ·
+ # SK
+ # (Verkehrsende) · · · − · −
+ # SOS
+ # (internationaler
+ # (See-)Notruf) · · · − − − · · ·
+ # HH
+ # (Fehler; Irrung;
+ # Wiederholung
+ # ab letztem
+ # vollständigen Wort) · · · · · · · ·
+'
+}
+
+## Convert morse code to beep(1) arguments.
+morse2beeparg() {
+sed "
+ s: : -n -f 1 -l $dit:g
+ s:·: -n -f $freq -l $dit:g
+ s:−: -n -f $freq -l $dah:g
+" |
+ sed '
+ 1s:^:beep -f 1 -l 1:
+'
+}
+
+compile() {
+ char2morse
+}
+
+execute() {
+ `morse2beeparg`
+}
+
+## main - process either [any non-option] arguments or stdin.
+if test $# -gt 0; then
+ echo "$*"
+else
+ cat
+fi |
+case "$mode" in
+ (compile) compile;;
+ (execute) execute;;
+ (compile+execute) compile | execute;;
+ (*) echo bad mode: $mode >&2; exit 23;;
+esac
diff --git a/modules/noise/Makefile b/modules/noise/Makefile
new file mode 100644
index 00000000..ea677185
--- /dev/null
+++ b/modules/noise/Makefile
@@ -0,0 +1,16 @@
+
+.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
+ ln -vsnf /krebs/modules/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/modules/noise/TODO b/modules/noise/TODO
new file mode 100644
index 00000000..a20f74e9
--- /dev/null
+++ b/modules/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/modules/noise/cron/bin/zeit b/modules/noise/cron/bin/zeit
new file mode 100755
index 00000000..7282c409
--- /dev/null
+++ b/modules/noise/cron/bin/zeit
@@ -0,0 +1,18 @@
+#! /bin/sh
+
+beep -l 1000 -f 4000
+sleep 1
+/krebs/modules/morse/morse.sh -l 100 -f 700 `date +%k`
+sleep 1
+expect >/dev/null <<EOF
+spawn nc localhost telnet
+expect READY.
+send "/zeit\r"
+expect READY.
+# pitch set to 10
+expect READY.
+# Playing WAVE 'stdin' : Signed 16 bit Little Endian, Rate 22050 Hz, Mono
+expect READY.
+# pitch changed from 10 to 100
+expect READY.
+EOF
diff --git a/modules/noise/init.d/noise b/modules/noise/init.d/noise
new file mode 100755
index 00000000..66be9bd9
--- /dev/null
+++ b/modules/noise/init.d/noise
@@ -0,0 +1,48 @@
+#!/bin/sh -e
+### BEGIN INIT INFO
+# Provides: noise
+# Required-Start: $remote_fs $syslog dbus
+# Required-Stop: $remote_fs $syslog dbus
+# Default-Start: 2 3 4 5
+# Default-Stop: 1
+# Short-Description: Start the noise "Telnet" server
+# Description: System mode startup script for
+# the noise "Telnet" server.
+### END INIT INFO
+
+DAEMON=/krebs/modules/noise/noise-server
+
+test -x $DAEMON || exit 1
+
+noise_pid() {
+ ps aux | grep tcpserver | grep noise-as-user | awk '{print$2}'
+}
+
+noise_start() {
+ "$DAEMON" &
+}
+
+noise_stop() {
+ kill "`noise_pid`"
+}
+
+case "$1" in
+ start|stop)
+ noise_${1}
+ ;;
+ restart|reload|force-reload)
+ noise_stop
+ noise_start
+ ;;
+ #force-stop) ;;
+ status)
+ kill -s 0 "`noise_pid`"
+ exit $?
+ ;;
+ *)
+ echo "Usage: /etc/init.d/noise {start|stop|force-stop|restart|reload|force-reload|status}"
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/modules/noise/modules/cat b/modules/noise/modules/cat
new file mode 100755
index 00000000..e090acba
--- /dev/null
+++ b/modules/noise/modules/cat
@@ -0,0 +1,14 @@
+#! /bin/sh
+case "$1" in
+ (--help) : ;;
+ (*)
+ while read line ; do
+ case "$line" in
+ (/quit)
+ break 2
+ ;;
+ (*)
+ echo "[$line]"
+ esac
+ done
+esac
diff --git a/modules/noise/modules/chat b/modules/noise/modules/chat
new file mode 100755
index 00000000..e5badc36
--- /dev/null
+++ b/modules/noise/modules/chat
@@ -0,0 +1,33 @@
+#! /bin/sh
+
+case "$1" in
+ (--help) echo send text to everyone with @@ prepended ;;
+ (/nick)
+ echo set nick to $2
+ echo /set chat_nick $2 >$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/modules/noise/modules/date b/modules/noise/modules/date
new file mode 100755
index 00000000..8cd1b0c1
--- /dev/null
+++ b/modules/noise/modules/date
@@ -0,0 +1,6 @@
+#! /bin/sh
+case "$1" in
+ (--help) : ;;
+ (*)
+ date --rfc-3339=s
+esac
diff --git a/modules/noise/modules/echo b/modules/noise/modules/echo
new file mode 100755
index 00000000..344dd963
--- /dev/null
+++ b/modules/noise/modules/echo
@@ -0,0 +1,6 @@
+#! /bin/sh
+case "$1" in
+ (--help) : ;;
+ (*)
+ echo "$*"
+esac
diff --git a/modules/noise/modules/ein_mal_eins b/modules/noise/modules/ein_mal_eins
new file mode 100755
index 00000000..fb385b31
--- /dev/null
+++ b/modules/noise/modules/ein_mal_eins
@@ -0,0 +1,37 @@
+#! /bin/bash
+
+R() {
+ echo "`od -t d -N 1 /dev/urandom | sed -rn '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/modules/noise/modules/espeak b/modules/noise/modules/espeak
new file mode 100755
index 00000000..97305b5e
--- /dev/null
+++ b/modules/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-100}"
+ 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 -Dplug:dmix)<<EOF
+$*
+EOF
+}
+
+case "$1" in
+ (--help) echo say something with espeak ;;
+ (-d|--debug) shift; debug=true speak "$@";;
+ (-v|--verbose) shift; verbose=true speak "$@";;
+ (*) speak "$@";;
+esac
diff --git a/modules/noise/modules/help b/modules/noise/modules/help
new file mode 100755
index 00000000..bc4c2931
--- /dev/null
+++ b/modules/noise/modules/help
@@ -0,0 +1,24 @@
+#! /bin/sh
+case "$1" in
+ (-*) : ;; # ignore all options
+ ('') { for directory in `echo "$NOISE_PATH" | tr : \ ` ; do
+ for module in "$directory"/* ; do
+ echo `basename "$module"` `$module --help`
+ done 2>/dev/null
+ done
+ ## print all documented built-in commands
+ sed -rn 's:^noise_([a-z]+)\(\) \{ # (.+)?$:\1 \2:p' "$NOISE"
+ } | sort | uniq | sed -rn '
+ $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/modules/noise/modules/join b/modules/noise/modules/join
new file mode 100755
index 00000000..68afcb66
--- /dev/null
+++ b/modules/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/modules/noise/modules/lang b/modules/noise/modules/lang
new file mode 100755
index 00000000..07b6802e
--- /dev/null
+++ b/modules/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/modules/noise/modules/mpc b/modules/noise/modules/mpc
new file mode 100755
index 00000000..0ab72058
--- /dev/null
+++ b/modules/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=mpd.shack mpc $@
+esac
diff --git a/modules/noise/modules/names b/modules/noise/modules/names
new file mode 100755
index 00000000..f5922064
--- /dev/null
+++ b/modules/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/modules/noise/modules/nick b/modules/noise/modules/nick
new file mode 100755
index 00000000..5ed1e9d9
--- /dev/null
+++ b/modules/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/modules/noise/modules/part b/modules/noise/modules/part
new file mode 100755
index 00000000..d35ac501
--- /dev/null
+++ b/modules/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/modules/noise/modules/ping b/modules/noise/modules/ping
new file mode 100755
index 00000000..acf2529f
--- /dev/null
+++ b/modules/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/modules/noise/modules/play b/modules/noise/modules/play
new file mode 100755
index 00000000..749b450a
--- /dev/null
+++ b/modules/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 -r '
+ 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<<EOF
+\
+Keine Audiodatei mit dem Namen
+
+ $1.EXT
+
+gefunden... am besten gleich uploaden:
+
+ scp NAME shack@shack.shack:noise/samples/
+
+folgende Dateiendungen werden erkannt: $ffs
+EOF
+ fi
+esac
diff --git a/modules/noise/modules/pong b/modules/noise/modules/pong
new file mode 100755
index 00000000..eb2df46d
--- /dev/null
+++ b/modules/noise/modules/pong
@@ -0,0 +1,26 @@
+#! /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 no ping challange running
+ else
+ timestamp=`date +%s%N`
+ echo /pong $NOISE_pid $timestamp >$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/modules/noise/modules/query b/modules/noise/modules/query
new file mode 100755
index 00000000..ceeff8a5
--- /dev/null
+++ b/modules/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/modules/noise/modules/send_to_channel b/modules/noise/modules/send_to_channel
new file mode 100755
index 00000000..4a0470af
--- /dev/null
+++ b/modules/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/modules/noise/modules/sendmail b/modules/noise/modules/sendmail
new file mode 100755
index 00000000..182d96e3
--- /dev/null
+++ b/modules/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<shockspasm@googlemail.com>"
+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/modules/noise/modules/shackstatus b/modules/noise/modules/shackstatus
new file mode 100755
index 00000000..a5058f0a
--- /dev/null
+++ b/modules/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 -- interne - do-mejn -- $STAT_DNS_I
+ /espeak -v interner - D N S -- externe - do-mejn -- $STAT_DNS_E
+ /espeak -v externer - D N S - $STAT_DNS_X
+ /espeak -v Leitungsqualität - $STAT_LINE prozent.
+ /temp
+ /espeak -v krebs kompjuting bereit
+ EOF
+ ;;
+ esac 2>&1
+}
+
+wochentag() {
+ case $(date +%a) in
+ (Mon) echo Montag ;;
+ (Tue) echo Dienstag ;;
+ (Wed) echo Mittwoch ;;
+ (Thu) echo Donnerstag ;;
+ (Fri) echo Freitag ;;
+ (Sat) echo Samstag ;;
+ (Sun) echo Sonntag ;;
+ esac
+}
+
+tag() {
+ case $(date +%d) in
+ (1) echo erste ;;
+ (2) echo zweite ;;
+ (3) echo dritte ;;
+ (4) echo vierte ;;
+ (5) echo fünfte ;;
+ (6) echo sechste ;;
+ (7) echo siebte ;;
+ (8) echo achte ;;
+ (9) echo neunte ;;
+ (10) echo zehnte ;;
+ (11) echo elfte ;;
+ (12) echo zwölfte ;;
+ (13) echo dreizehnte ;;
+ (14) echo vierzehnte ;;
+ (15) echo fünfzehnte ;;
+ (16) echo sechzehnte ;;
+ (17) echo siebzehnte ;;
+ (18) echo achtzehnte ;;
+ (19) echo neunzehnte ;;
+ (20) echo zwanzigste ;;
+ (21) echo einundzwanzigste ;;
+ (22) echo zweiundzwanzigste ;;
+ (23) echo dreiundzwanzigste ;;
+ (24) echo vierundzwanzigste ;;
+ (25) echo füfundzwanzigste ;;
+ (26) echo sechsundzwanzigste ;;
+ (27) echo siebenundzwanzigste ;;
+ (28) echo achtundzwanzigste ;;
+ (29) echo neunundzwanzigste ;;
+ (30) echo dreissigste ;;
+ (31) echo einunddreissigste ;;
+ esac
+}
+
+monat() {
+ case $(date +%b) in
+ (Jan) echo Januar ;;
+ (Feb) echo Februar ;;
+ (Mar) echo März ;;
+ (Apr) echo April ;;
+ (May) echo Mai ;;
+ (Jun) echo Juni ;;
+ (Jul) echo Juli ;;
+ (Aug) echo August ;;
+ (Sep) echo September ;;
+ (Oct) echo Oktober ;;
+ (Nov) echo November ;;
+ (Dec) echo Dezember ;;
+ esac
+}
+
+main "$@"
diff --git a/modules/noise/modules/sleep b/modules/noise/modules/sleep
new file mode 100755
index 00000000..89712cac
--- /dev/null
+++ b/modules/noise/modules/sleep
@@ -0,0 +1,10 @@
+#! /bin/sh
+case "$1" in
+ (--help) echo "pause for NUMBER seconds" ;;
+ (*)
+ if echo "$1" | grep -Eq '^([0-9]+(\.[0-9]*)?|[0-9]*\.[0-9]+)$' ; then
+ sleep "$1"
+ else
+ echo 'FAIL: $1 is not a number'
+ fi
+esac
diff --git a/modules/noise/modules/stream b/modules/noise/modules/stream
new file mode 100755
index 00000000..1e6fd0c5
--- /dev/null
+++ b/modules/noise/modules/stream
@@ -0,0 +1,64 @@
+#! /bin/sh
+inputdir=$HOME/noise/streams
+basename="`basename "$0"`"
+case "$1" in
+ (--help)
+ if echo "$0 $*" | grep -q '[[:space:]]--verbose\>'; then
+ echo -e "\x1B[35mtype \x1B[32m/$basename off \x1B[35mto turn stream off\x1B[m"
+ for i in `ls $inputdir` ; do
+ filename="$inputdir/$i"
+ shortcut=`xmlstarlet sel -t -v /station/@shortcut "$inputdir/$i"`
+ title=`xmlstarlet sel -t -v /station/@title "$inputdir/$i"`
+ topic=`xmlstarlet sel -t -v /station/@topic "$inputdir/$i"`
+ stream=`xmlstarlet sel -t -v /station/@stream "$inputdir/$i"`
+ echo -e "\x1B[35mtype \x1B[32m/$basename $shortcut \x1B[35mfor $topic\x1B[m"
+ done
+ else
+ echo "play an audio stream"
+ fi
+ ;;
+ (*)
+ exec 2>&1
+ ffs='xml'
+
+ if test -z "$*" ; then
+ echo -e "\x1B[32m/stream off \x1B[33m- turn stream off\x1B[m"
+ for i in `ls $inputdir` ; do
+ filename="$inputdir/$i"
+ shortcut=`xmlstarlet sel -t -v /station/@shortcut "$inputdir/$i"`
+ title=`xmlstarlet sel -t -v /station/@title "$inputdir/$i"`
+ topic=`xmlstarlet sel -t -v /station/@topic "$inputdir/$i"`
+ stream=`xmlstarlet sel -t -v /station/@stream "$inputdir/$i"`
+ echo -e "\x1B[32m/stream $shortcut \x1B[33m- $title \x1B[35m$topic\x1B[m"
+ done
+ else if [ "$1" = "off" ]; then
+ [ ! -d /tmp/noise ] || ( echo "no directory /tmp/noise; aborting" ; exit 1 )
+ [ -f /tmp/noise/stream.pid ] && ( kill ` cat /tmp/noise/stream.pid ` )
+ [ -e /tmp/noise/stream.pid ] && rm /tmp/noise/stream.pid || ( echo "can't remove /tmp/noise/stream.pid; aborting" ; exit 1 )
+ else
+ for i in `ls $inputdir` ; do
+ filename="$inputdir/$i"
+ shortcut=`xmlstarlet sel -t -v /station/@shortcut "$inputdir/$i"`
+ stream=`xmlstarlet sel -t -v /station/@stream "$inputdir/$i"`
+ if [ "$shortcut" == "$1" ]; then
+ [ ! -d /tmp/noise ] || ( umask 077 ; mkdir /tmp/noise ) || ( echo "can't create /tmp/noise; aborting" ; exit 1 )
+ [ -f /tmp/noise/stream.pid ] && ( kill ` cat /tmp/noise/stream.pid ` )
+ [ -e /tmp/noise/stream.pid ] && rm /tmp/noise/stream.pid || ( echo "can't remove /tmp/noise/stream.pid; aborting" ; exit 1 )
+ mplayer -cache 2048 -quiet "$stream" &
+ ( umask 077 ; echo $! > /tmp/noise/stream.pid )
+ break
+ fi
+ done || cat<<EOF
+\
+Keine Audiostreambeschreibung mit dem Namen
+
+ $1.EXT
+
+gefunden... am besten gleich anlegen:
+
+ ssh shack@shack.shack:noise/streams/
+
+folgende Dateiendungen werden erkannt: $ffs
+EOF
+ fi fi
+esac
diff --git a/modules/noise/modules/temp b/modules/noise/modules/temp
new file mode 100755
index 00000000..4e0c47a2
--- /dev/null
+++ b/modules/noise/modules/temp
@@ -0,0 +1,56 @@
+#! /bin/bash
+
+main() {
+ case "$1" in
+ (--help)
+ echo "report temperature in K, °C, °R, or °F."
+ ;;
+ (-C|--celsius)
+ espeak_inside `inside_temp 'x - 273.15'` Grad Zelsius
+ espeak_outside `outside_temp 'x - 273.15'` Grad Zelsius
+ ;;
+ (-F|--fahrenheit)
+ espeak_inside `inside_temp 'x * 9/5 - 459.67'` Grad Fahrenheit
+ espeak_outside `outside_temp 'x * 9/5 - 459.67'` Grad Fahrenheit
+ ;;
+ (-R|--rankine)
+ espeak_inside `inside_temp 'x * 9/5'` Grad Renkin
+ espeak_outside `outside_temp 'x * 9/5'` Grad Renkin
+ ;;
+ (-K|--kelvin|*)
+ espeak_inside `inside_temp` Kelvin
+ espeak_outside `outside_temp` Kelvin
+ ;;
+ esac
+}
+
+## temp [<formula with temperature as x>]
+## Echo temperature in K. If formula is given then return that result instead.
+inside_temp() {
+ echo "scale=2; x=`/krebs/modules/temper/temper` + 273.15; ${1-x}" | bc
+}
+
+outside_temp() {
+ echo "scale=2; x=`dig +short txt outside.elwood.temp.citecs.de |
+ sed 's/^"DEG \([0-9]\+\.[0-9]\+\)"$/\1/'
+ ` + 273.15; ${1-x}" | bc
+}
+
+espeak_inside() {
+ echo Die Krebs-tempera-tur beträgt $@ | to_espeak
+}
+
+espeak_outside() {
+ echo Die Außen-tempera-tur beträgt $@ | to_espeak
+}
+
+to_espeak() {
+ sed '
+ s/\(\.[0-9]\)0\+/\1/g
+ s/\(\.[0-9]\)\([0-9]\)[0-9]*/ \1 \2 /;
+ s/^-/minus /;
+ s/\./ komma /;
+ ' | tee $NOISE_linefeed
+}
+
+main "$@"
diff --git a/modules/noise/modules/test b/modules/noise/modules/test
new file mode 100755
index 00000000..2c0b8e0d
--- /dev/null
+++ b/modules/noise/modules/test
@@ -0,0 +1,13 @@
+#! /bin/sh
+
+case "$1" in
+ (--help) echo do some test-module related stuff ;;
+ (*)
+
+ echo -n ">> "
+ read TEST
+ if [ $TEST == 'q' ]; then exit; fi
+ echo /wall @@ $TEST >$NOISE_linefeed
+ #sleep 1
+ #sleep 1; echo /test >$NOISE_linefeed &
+esac
diff --git a/modules/noise/modules/twitter b/modules/noise/modules/twitter
new file mode 100755
index 00000000..26982525
--- /dev/null
+++ b/modules/noise/modules/twitter
@@ -0,0 +1,125 @@
+#!/usr/bin/python
+#encode=utf8
+
+#print "TODO Bug Robert to implement Twitter-OAuth!"
+#exit(1)
+import sys
+
+#sys.path.append("/usr/local/lib/")
+
+import twitter, os, pwd
+
+#os.getlogin = lambda: pwd.getpwuid(os.getuid())[0]
+
+sys.stderr = sys.stdout
+
+def shorten(text):
+
+ text = text.replace("about ", "~")
+ text = text.replace("an", "1")
+ text = text.replace(" minutes", "m")
+ text = text.replace(" minute", "m")
+ text = text.replace(" hours", "h")
+ text = text.replace(" hour", "h")
+ text = text.replace(" seconds", "s")
+ text = text.replace(" second", "s")
+ text = text.replace(" days", "d")
+ text = text.replace(" day", "d")
+ text = text.replace(" weeks", "w")
+ text = text.replace(" week", "w")
+ text = text.replace(" years", "y")
+ text = text.replace(" year", "y")
+ text = text.replace(" ago", "")
+ text = text.replace("a", "1")
+ return text
+
+
+def parse(text):
+ text = text.replace("\n","")
+ t = text.split(" ")
+ new = ""
+ for piece in t:
+ escape = ""
+ if piece.startswith("@"):
+ escape = ""
+ if piece[1:].lower() == "shackspam" or piece[1:].lower() == "shackspace":
+ escape = ""
+
+ elif piece.startswith("#"):
+ escape = ""
+ elif piece.startswith("http://"):
+ escape = ""
+ if escape:
+ new += escape + piece + " "
+ else:
+ new += piece + " "
+
+ return new
+
+if len(sys.argv) > 1 and sys.argv[1] == "--help":
+ print "read or post to the shackspam twitter timeline"
+ if len(sys.argv) == 3 and sys.argv[2] == "--verbose":
+ print "call without parameters to read"
+ print "use /twitter [your tweet] to tweet something to the shackspam twitter timeline"
+ exit()
+
+
+
+api = twitter.Api("Z7f9npE5ixvZ0lMCHDZBOg", "8z0gyfOABar1HxKvqL6fYXLqRFUPLQ9OOzDFt7Q4F4", "139766258-94TGPvNsJ8tYVv68eZewfXOIyDvRCWdycNlUgHrs", "NRnDQZPCoLrDizFvakZkSWgoG4vgGuT3OOMChSfiI")
+
+#api.SetXTwitterHeaders("Shackspace UTTERANCE","","0.00.0.01.42")
+
+if len(sys.argv) > 1:
+
+
+ tweet = u""
+
+ for t in sys.argv[1:]:
+ tweet += t.decode("utf8") + u" "
+ tweet = tweet[:-1]
+
+ print u"Length: " + str(len(tweet)) + u""
+
+ if len(tweet) > 140:
+ print u"Your Tweet must be shorter than 140 characters.\n"
+ exit()
+
+ status = api.PostUpdate(tweet)
+
+
+
+
+else:
+ """print "\tshackspace tweets:"
+ for i in api.GetUserTimeline():
+ i.text = parse(i.text)
+ print ("" + i.user.screen_name + " " + i.GetRelativeCreatedAt() + " " + i.text).encode("utf8").replace("\n"," ")
+
+ print "\n\tfriends tweets"
+ """
+ a = api.GetFriendsTimeline()
+ a.reverse()
+ for i in a:
+ text = i.text
+ ilen = len(i.user.screen_name) + len(shorten(i.GetRelativeCreatedAt())) + 2
+ if i.user.screen_name.lower() == "shackspace" or i.user.screen_name.lower() == "shackspam":
+ info = "" + i.user.screen_name + " " + shorten(i.GetRelativeCreatedAt()) + ""
+ else:
+ info = "" + i.user.screen_name + " " + shorten(i.GetRelativeCreatedAt()) + ""
+ text = info + " " + parse(text)
+
+ t = text.split(" ")
+ tmp = ""
+ for n in t:
+ if ((len(tmp) + len(n)) >= 80):
+ print parse(tmp).encode("utf8")
+ tmp = " " * ilen
+
+ tmp += " " + n
+ if len(tmp) > ilen:
+ print parse(tmp).encode("utf8")
+
+
+
+
+
diff --git a/modules/noise/modules/vvs b/modules/noise/modules/vvs
new file mode 100755
index 00000000..fc23375f
--- /dev/null
+++ b/modules/noise/modules/vvs
@@ -0,0 +1,17 @@
+#! /bin/sh
+
+wrapper() {
+ exec 2>&1
+ echo date: `date +%H:%M`
+ "$@"
+}
+
+case "$1" in
+ (--help) echo query VVS ;;
+ (*)
+ case $# in
+ (2) wrapper vvs.de "$@" ;;
+ (0) wrapper vvs ;;
+ (*) echo "Syntax: /vvs [ORIGIN DESTINATION]" ; return ;;
+ esac
+esac
diff --git a/modules/noise/modules/wall b/modules/noise/modules/wall
new file mode 100755
index 00000000..c73744ea
--- /dev/null
+++ b/modules/noise/modules/wall
@@ -0,0 +1,8 @@
+#! /bin/sh
+case "$1" in
+ (--help) : ;;
+ (?*)
+ for linefeed in /tmp/noise/*/linefeed ; do
+ echo /echo "$*" >$linefeed
+ done
+esac
diff --git a/modules/noise/modules/zeit b/modules/noise/modules/zeit
new file mode 100755
index 00000000..9fbc33e4
--- /dev/null
+++ b/modules/noise/modules/zeit
@@ -0,0 +1,19 @@
+#! /bin/sh
+
+case "$1" in
+ (--help)
+ echo "say current time" ;;
+ (*)
+ exec >>$NOISE_linefeed
+ k=`date +%k|sed 's/^[[:space:]]*1[[:space:]]*$/ein/'`
+ M=`date +%M|sed 's/0*//'`
+ echo /set pitch 10
+ case "$lang" in
+ (de|'') echo "/espeak Es ist $k Uhr $M" ;;
+ (en|*-en)
+ test -z "$M" || M="and $M minutes"
+ echo "/espeak It is $k o clock $M" ;;
+ (*) echo "Error: unsupported lang = $lang" >&2
+ esac
+ echo /set pitch ${noise_pitch-100}
+esac 2>&1
diff --git a/modules/noise/noise b/modules/noise/noise
new file mode 100755
index 00000000..bd6b17c8
--- /dev/null
+++ b/modules/noise/noise
@@ -0,0 +1,182 @@
+#! /bin/sh
+
+noise_set() { # set a variable
+ case "$1" in
+ (-q|--quiet) echo=: ; shift ;;
+ (*) echo=echo ;;
+ esac
+ case $# in
+ (0) ## print all noise variables
+ env | sed -rn '
+ s/^noise_([[:alnum:]_]+)=(.*)$/\1 = \2/p
+ ' | sort
+ ;;
+ (1) ## print value the specified variable
+ eval "echo \"$1 = \$noise_$1\""
+ ;;
+ (*) ## set the specified variable
+ if echo "$1" | grep -q '[^[:alnum:]_]' ; then
+ fail invalid variable name "$1"
+ return 23
+ fi
+ eval "old=\"\$noise_$1\""
+ if test "x$old" = "x$2" ; then
+ eval "$echo \"$1 is already $2\""
+ elif test -z "$old" ; then
+ eval "export noise_$1='$2' ; $echo \
+\"$1 set to $2\""
+ else
+ eval "export noise_$1='$2' ; $echo \
+\"$1 changed from $old to $2\""
+ fi
+ ## write variable to $env
+ if grep -q "^$1=" "$env" ; then
+ sed -ri "s'^($1)=(.*)\$'\1=\'$2\''" $env
+ else
+ echo "$1='$2'" >>$env
+ fi
+ ;;
+ esac
+}
+
+noise_unset() { # unset a variable
+ case "$1" in
+ (-q|--quiet) echo=: ; shift ;;
+ (*) echo=echo ;;
+ esac
+ case $# in
+ (1) ##
+ unset "noise_$1"
+ sed -ni "/^$1=/!p" $env
+ ;;
+ (*)
+ fail "broken commandline: $@"
+ ;;
+ esac
+}
+
+noise_quit() { # exit
+ echo "Good bye!"
+ exit
+}
+
+fail() {
+ echo "FAIL: $*"
+ return 23
+}
+
+cleanup() {
+ kill $jobs
+ rm -f $linefeed $env
+ rmdir /tmp/noise/$$ 2>/dev/null
+ rmdir /tmp/noise 2>/dev/null
+}
+
+exec 2>&1
+qname="`readlink -f "$0"`"
+dirname="`dirname "$qname"`"
+export HOME='/home/noise'
+if test -d "$dirname/modules" ; then
+ export NOISE_PATH="${NOISE_PATH+$NOISE_PATH:}$dirname/modules"
+ export NOISE_PATH="${NOISE_PATH+$NOISE_PATH:}$HOME/noise/modules"
+fi
+mkdir -p /tmp/noise/$$
+linefeed="/tmp/noise/$$/linefeed"
+env="/tmp/noise/$$/environment"
+trap cleanup EXIT
+mkfifo $linefeed
+touch $env
+##
+##
+##
+readline() {
+ { read REPLY && echo "$REPLY" ; } | sed -rn "
+ s/[']//g
+ s/~%/\n/g
+ s/([^\\])([#<>])/\1\\\\\2/g
+ s:^/([a-z_]+)([[:space:]]+(.*))?$:command=\1; args='\3';:p;t
+ s@^([[:alnum:]_/+-]+):[[:space:]]*(.*)@command=lang; args='\1 \2';@p;t
+ s@^\![[:space:]]*(.*)@command=play; args='\1';@p;t
+ s:.*:command='$noise_default_command'; args='&';:p;t
+ "
+}
+##
+##
+##
+while echo -n "$noise_prompt" && eval "`readline`" ; do
+ ## modcall
+ for dir in `echo "$NOISE_PATH" | tr : \ ` ; do
+ module="$dir/$command"
+ if test -x "$module" ; then
+#echo foo $module:$@:
+ #shift
+ eval 'NOISE="$0" NOISE_pid="$$" NOISE_linefeed="$linefeed" "$module"' "$args"
+ continue 2
+ fi
+ done
+ ## funcall
+ if type noise_$command | grep -q function ; then
+ eval 'noise_$command' "$args"
+ continue
+ fi
+ ##
+ fail unknown command "$command"
+done <$linefeed &
+jobs="${jobs+$jobs }`jobs -p`"
+##
+##
+##
+cat<<EOF
+Welcome to 23.shack version 0.9 beta 4 \
+commit `
+ cd $dirname &&
+ git log -n 1 | head -n 1 | cut -d\ -f 2 | dd count=23 bs=1 2>/dev/null
+`...
+
+## Motto Of The Day\
+
+Join the 23.shack-dev-team, we've got `
+ sloccount $dirname/* |
+ sed -rn '
+ s/.*\(SLOC\)[[:space:]]*=[[:space:]]*([0-9]+)$/\1/p
+ '` SLOC, `
+ {
+ ls $dirname/modules/
+ test -d ~noise/modules && ls ~noise/modules/
+ } | sort | uniq | wc -l
+ ` mods,
+`grep ^- $dirname/TODO | wc -l`+ TODOs and drive the irregular Hackathon @shackspace.
+Follow http://twitter.com/shackspam FTW!
+
+## Hints\
+
+Start your telnet session with rlwrap for MAXIMUM profit.
+Get online-help with /help.
+
+EOF
+# TODO: MOTD-candidates:
+#twitter: #shackspam
+#mail: shockspasm@googlemail.com
+#irc: freenode/#shackspace
+#afk: @shackspace
+##
+##
+##
+exec >>$linefeed
+##
+##
+##
+echo '/set -q default_command espeak'
+echo '/set -q prompt "READY.~%"'
+##
+##
+##
+while read REPLY; do
+ case $REPLY in
+ (/quit) echo /quit ; exit ;;
+ (*) tr \; \\n | grep . ;;
+ esac<<EOF
+$REPLY
+EOF
+done
+#### end of file.
diff --git a/modules/noise/noise-as-user b/modules/noise/noise-as-user
new file mode 100755
index 00000000..21e4102f
--- /dev/null
+++ b/modules/noise/noise-as-user
@@ -0,0 +1,4 @@
+#! /bin/sh
+qname="`readlink -f "$0"`"
+dirname="`dirname "$qname"`"
+exec su noise -c "env -i TCPREMOTEIP='$TCPREMOTEIP' '$dirname/noise'"
diff --git a/modules/noise/noise-server b/modules/noise/noise-server
new file mode 100755
index 00000000..0df803b1
--- /dev/null
+++ b/modules/noise/noise-server
@@ -0,0 +1,4 @@
+#! /bin/sh
+qname="`readlink -f "$0"`"
+dirname="`dirname "$qname"`"
+exec tcpserver -c 423 -t 2 -D 0.0.0.0 23 "$dirname/noise-as-user"
diff --git a/modules/people/Makefile b/modules/people/Makefile
new file mode 100644
index 00000000..2c6c1c03
--- /dev/null
+++ b/modules/people/Makefile
@@ -0,0 +1,6 @@
+.phony: all
+
+all: arping.py arping_users.py
+ echo "call python ./arping_users.py v"
+install:
+ apt-get install python-scapy
diff --git a/modules/people/README.md b/modules/people/README.md
new file mode 100644
index 00000000..e45d39c1
--- /dev/null
+++ b/modules/people/README.md
@@ -0,0 +1,13 @@
+ARPING Users
+==========
+
+This is a simplified python script which checks the available subnet for computers online and returns a list of users which are online based on their mac-address
+
+
+arping_users.py:
+ call `python arping_users.py v` for verbose output -> print all discovered hosts
+
+SNMPWALK Command
+===============
+
+snmpwalk -c shammunity 10.42.0.1 1.3.6.1.2.1.3.1.1.2
diff --git a/modules/people/TODO.md b/modules/people/TODO.md
new file mode 100644
index 00000000..daacfd58
--- /dev/null
+++ b/modules/people/TODO.md
@@ -0,0 +1,3 @@
+BUGS
+=====
+
diff --git a/modules/people/VERSION b/modules/people/VERSION
new file mode 100644
index 00000000..6c50e659
--- /dev/null
+++ b/modules/people/VERSION
@@ -0,0 +1 @@
++++++++[>+++++++>+++++++<<-]>.>---.<-.
diff --git a/modules/people/arping.py b/modules/people/arping.py
new file mode 100755
index 00000000..1b51ab1b
--- /dev/null
+++ b/modules/people/arping.py
@@ -0,0 +1,37 @@
+#!/usr/bin/python
+
+import logging
+log = logging.getLogger('arpingy')
+logging.disable(logging.WARNING)
+
+import os,sys
+try:
+ if (os.geteuid() != 0):
+ raise Exception('no root permissions')
+ from scapy.all import * #might throws "no such module"
+
+ def arpingy(iprange="10.42.1.0/24",iface='eth0'):
+ log.debug("pinging "+ str(iprange))
+ """Arping function takes IP Address or Network, returns nested mac/ip list"""
+ try:
+ conf.verb=0
+ ans,unans=arping(iprange,iface=iface,timeout=1,retry=3)
+
+ collection = []
+ for snd, rcv in ans:
+ result = rcv.sprintf(r"%ARP.psrc% %Ether.src%").split()
+ log.debug(result)
+ return result # take just the first arp reply
+ except Exception as e:
+ print ("something went wrong while arpinging " + str(e))
+ return []
+
+except Exception as e:
+ log.error("Cannot load arping functions!" + str(e))
+ def arpingy(iprange='',iface=''):
+ raise Exception ('arping not available')
+
+
+if __name__ =='__main__':
+ logging.basicConfig(level=logging.DEBUG)
+ arpingy(sys.argv[1],sys.argv[2])
diff --git a/modules/people/arping_users.py b/modules/people/arping_users.py
new file mode 100755
index 00000000..c576e4f3
--- /dev/null
+++ b/modules/people/arping_users.py
@@ -0,0 +1,54 @@
+#!/usr/bin/python
+import subprocess,re,logging,sys
+
+from arping import arpingy
+from multiprocessing import Pool
+DEV='eth0'
+MAC_NAMES='mac_names.lst'
+data = []
+ret = {}
+verb = False
+
+if len(sys.argv) > 1 and sys.argv[1] == 'v':
+ verb = True
+def get_own_addr():
+ data = subprocess.Popen(['/sbin/ifconfig',DEV],
+ stdout=subprocess.PIPE).communicate()[0].replace('\n','')
+ return re.sub(r'.*HWaddr ([0-9A-Fa-f:]*).*inet addr:([0-9.]*).*' ,
+ r'\1 \2',data).split()
+
+def load_names(MAC_NAMES):
+ names = {}
+ f = open(MAC_NAMES)
+ for l in f:
+ mac,name = l.split()
+ names[mac] = name.replace('\n','')
+ f.close()
+ return names
+
+def arping_helper(dic):
+ return arpingy(**dic)
+
+for first in range(4):
+ for second in range(255):
+ data.append({'iprange':'10.42.'+str(first)+'.'+str(second),'iface':DEV})
+
+names = load_names(MAC_NAMES)
+try:
+ p = Pool(20)
+ ret = filter(lambda x:x , p.map(arping_helper, data))
+ myip,mymac = get_own_addr()
+ ret.append([mymac,myip])
+ p.terminate()
+except Exception as e:
+ print 'you fail '+str(e)
+
+
+
+for p in ret:
+ if verb:
+ print p[0] + " => " + p[1]
+ if p[1] in names:
+ print names[p[1]]+ " is online"
+
+
diff --git a/modules/people/mac_names.lst b/modules/people/mac_names.lst
new file mode 100644
index 00000000..dcd3c2b0
--- /dev/null
+++ b/modules/people/mac_names.lst
@@ -0,0 +1 @@
+00:40:63:c8:b5:a0 krebs
diff --git a/modules/retiolum/Makefile b/modules/retiolum/Makefile
new file mode 100644
index 00000000..0d99ee70
--- /dev/null
+++ b/modules/retiolum/Makefile
@@ -0,0 +1,15 @@
+.phony: update it all so install
+
+all: select-target
+
+it: so
+so: it
+
+/etc/tinc/retiolum/hosts:
+ cd $(dir $@) && git clone https://github.com/krebscode/hosts
+
+update: /etc/tinc/retiolum/hosts
+ cd $< && git pull
+
+install:
+ scripts/tinc_setup/install.sh
diff --git a/modules/retiolum/README b/modules/retiolum/README
new file mode 100644
index 00000000..9b9725f2
--- /dev/null
+++ b/modules/retiolum/README
@@ -0,0 +1,29 @@
+Retiolum Darknet Module for Krebs
+========================
+
+Enter the darknet with the help of tinc retiolum
+
+Getting Started
+-------------
+to get you started, check out scripts/tinc_setup/README
+
+1. the first step you will need to do is grab a binary copy of tinc via your
+packet manager, build it yourself or place all your hope into the build
+script of your distribution.
+2. after doing that you might want to run the scripts/tinc_setup/install.sh
+script to write all the configuration files and private/public keys.
+This installation is somewhat interactive so be sure not to fuck shit up.
+
+Other cool stuff
+---------------
+in bin/ there are some cool scripts which are partly needed and partly
+totally unnecessary to work with retiolum.
+
+As all the scripts are not too horribly long, be sure to use
+`cat bin/SCRIPTNAME` to get an understanding of what they do
+
+besides that in scripts/ there are 3 more scripts which perform pretty
+sophisticated tasks like finding instances via multicast or writing graphs
+of the current retiolum network. Try them if you dare :)
+
+
diff --git a/modules/retiolum/bin/fillxx b/modules/retiolum/bin/fillxx
new file mode 100755
index 00000000..5e558362
--- /dev/null
+++ b/modules/retiolum/bin/fillxx
@@ -0,0 +1,6 @@
+#! /bin/sh
+while echo $1 | grep -q xx; do
+ xx=`od -An -tx1 -N 1 /dev/urandom | tr -d \ `
+ set -- `echo $1 | sed s/xx/$xx/`
+done
+echo $1
diff --git a/modules/retiolum/bin/hosts b/modules/retiolum/bin/hosts
new file mode 100755
index 00000000..6939f52c
--- /dev/null
+++ b/modules/retiolum/bin/hosts
@@ -0,0 +1,11 @@
+#! /bin/sh
+set -euf
+
+netname=${1-retiolum}
+
+cd /etc/tinc/$netname/hosts
+
+for i in `ls`; do
+ sed -rn 's|^ *Subnet *= *([^ /]*)(/[0-9]*)? *$|\1\t'$i' '$i'.'$netname'|p' $i
+done | sort
+
diff --git a/modules/retiolum/bin/ipv6 b/modules/retiolum/bin/ipv6
new file mode 100755
index 00000000..65a1eaa1
--- /dev/null
+++ b/modules/retiolum/bin/ipv6
@@ -0,0 +1,35 @@
+#! /bin/sh
+#
+# Manage IPv6 of the retiolum interface.
+#
+# usage: ipv6 {start,stop}
+#
+set -euf
+
+if test `id -u` != 0; then
+ echo "we're going sudo..." >&2
+ exec sudo "$0" "$@"
+ exit 23 # go to hell
+fi
+
+file=/etc/tinc/retiolum/hosts/`hostname`
+addr=`sed -rn 's|^Subnet *= *(42:[0-9A-Fa-f:]*/128)|\1|p' $file`
+route=42::/16
+
+start() {
+ stop
+ ip -6 addr add $addr dev retiolum
+ ip -6 route add $route dev retiolum
+}
+
+stop() {
+ ip -6 addr del $addr dev retiolum 2>/dev/null || :
+ ip -6 route del $route dev retiolum 2>/dev/null || :
+}
+
+## dispatch
+case "$1" in
+ (start) start;;
+ (stop) stop;;
+ (*) echo "You're made of stupid" 2>/dev/null; exit 23;;
+esac
diff --git a/modules/retiolum/bin/tinc b/modules/retiolum/bin/tinc
new file mode 100755
index 00000000..ffa1dbee
--- /dev/null
+++ b/modules/retiolum/bin/tinc
@@ -0,0 +1,18 @@
+#! /bin/sh
+#
+set -euf
+
+init() {
+ f=/tmp/retiolum.GraphDumpFile
+ if ! test -f $f; then
+ touch $f &&
+ chown -v tincd: $f
+ fi
+
+ modprobe -v tun
+}
+
+if init; then
+ exec tincd --user=tincd --net=retiolum "$@"
+fi
+
diff --git a/modules/retiolum/bin/update_tinc_hosts b/modules/retiolum/bin/update_tinc_hosts
new file mode 100755
index 00000000..2d5cf957
--- /dev/null
+++ b/modules/retiolum/bin/update_tinc_hosts
@@ -0,0 +1,33 @@
+#! /bin/sh
+set -euf
+
+if test "${nosudo-false}" != true -a `id -u` != 0; then
+ echo "we're going sudo..." >&2
+ exec sudo "$0" "$@"
+ exit 23 # go to hell
+fi
+
+DIRNAME=`dirname $0`
+export PATH="`readlink -f $DIRNAME`:$PATH"
+
+hosts="${hosts-/etc/hosts}"
+
+bs='# BEGIN OF RETIOLUM'
+es='# END OF RETIOLUM'
+
+case "${1-imstupid}" in
+ (start|restart)
+ if grep -q "^$bs$" $hosts && grep -q "^$es$" $hosts; then
+ $0 stop
+ echo "$bs" >> $hosts
+ hosts >> $hosts
+ echo "$es" >> $hosts
+ fi
+ ;;
+ (stop)
+ sed -ie "/^$bs$/,/^$es$/d" $hosts
+ ;;
+ (*)
+ echo 'Error 1: You are made of stupid!' >&2
+ exit 23
+esac
diff --git a/modules/retiolum/scripts/README b/modules/retiolum/scripts/README
new file mode 100644
index 00000000..4dbb42af
--- /dev/null
+++ b/modules/retiolum/scripts/README
@@ -0,0 +1,16 @@
+This Folder contains all the cool scripts created for tinc_retiolum
+
+currently the following functions are deployed:
+
+adv_graphgen/ - makefu
+ this folder contains a script suite which parses the interesting
+ parameters from the syslog file by sending SIGUSR2 to the tinc process
+
+tinc_multicast/ - Miefda,Lassulus
+ A tinc multicast script suite which provides automagic-discovery in a
+ local network by utilizing multicast
+
+tinc_setup/ - makefu (i am so sorry...)
+ A number of scripts which build and configure tinc on a local machine.
+ Core is the install.sh script which actually writes the configuration
+ and creates users as well as private/public keys
diff --git a/modules/retiolum/scripts/adv_graphgen/README b/modules/retiolum/scripts/adv_graphgen/README
new file mode 100644
index 00000000..082e0f2b
--- /dev/null
+++ b/modules/retiolum/scripts/adv_graphgen/README
@@ -0,0 +1,28 @@
+The folder contains a number of scripts which provide a convenient way to
+generate advanced graphs from the SIGUSR2 output of tinc.
+
+it currently contains the following files:
+
+sanitize.sh:
+ wrapper arond parse.py which filters the syslog file for all tinc
+ related lines and removes the status informations:
+ this means that
+ <code>
+ May 19 20:40:44 servarch dnsmasq[5382]: reading /etc/resolv.conf
+ May 19 20:41:38 servarch tinc.retiolum[4780]: Error looking up pa-sharepoint.informatik.ba-stuttgart.de port 655: Name or service not known
+ </code>
+ becomes
+ <code>
+ Error looking up pa-sharepoint.informatik.ba-stuttgart.de port 655: Name or service not known
+ </code>
+ and so on.
+ It also provides a wrapper around graphviz which automagically
+ generates graphs from the produced graph file
+
+parse.py:
+ reads from stdin the sanitized syslog file and prints a valid dot file
+ from the given output.
+ The parser module may also produce any other output (e.g. for dns
+ entries and so on) you will need to actually read and modify the source
+ in order to be able to do this. ~May the source be with you~
+
diff --git a/modules/retiolum/scripts/adv_graphgen/parse.py b/modules/retiolum/scripts/adv_graphgen/parse.py
new file mode 100755
index 00000000..04b42c33
--- /dev/null
+++ b/modules/retiolum/scripts/adv_graphgen/parse.py
@@ -0,0 +1,91 @@
+#!/usr/bin/python2
+# -*- coding: utf8 -*-
+
+import sys
+""" TODO: Refactoring needed to pull the edges out of the node structures again,
+it should be easier to handle both structures"""
+
+def write_digraph(nodes):
+ """
+ writes the complete digraph in dot format
+ """
+ print ('digraph retiolum {')
+ print (' node[shape=box,style=filled,fillcolor=grey]')
+ generate_stats(nodes)
+ merge_edges(nodes)
+ for k,v in nodes.iteritems():
+ write_node(k,v)
+ print ('}')
+def generate_stats(nodes):
+ """ Generates some statistics of the network and nodes
+ """
+ for k,v in nodes.iteritems():
+ v['num_conns'] = len(v.get('to',[]))
+
+def merge_edges(nodes):
+ """ merge back and forth edges into one
+ DESTRUCTS the current structure by deleting "connections" in the nodes
+
+ """
+ for k,v in nodes.iteritems():
+ for con in v.get('to',[]):
+ for i,secon in enumerate(nodes[con['name']].get('to',[])):
+ if k == secon['name']:
+ del (nodes[con['name']]['to'][i])
+ con['bidirectional'] = True
+
+
+def write_node(k,v):
+ """ writes a single node and its edges
+ edges are weightet with the informations inside the nodes provided by
+ tinc
+ """
+ node = " "+k+"[label=\""
+ node += k+"\\l"
+ node += "external:"+v['external-ip']+":"+v['external-port']+"\\l"
+ if v.has_key('num_conns'):
+ node += "Num Connects:"+str(v['num_conns'])+"\\l"
+
+ node += "internal:"+v.get('internal-ip','¯\\\\(°_o)/¯')+"\\l\""
+ if v['external-ip'] == "MYSELF":
+ node += ",fillcolor=steelblue1"
+ node += "]"
+ print (node)
+ for con in v.get('to',[]):
+ edge = " "+k+ " -> " +con['name'] + "[weight="+str(float(con['weight']))
+ if con.get('bidirectional',False):
+ edge += ",dir=both"
+ edge += "]"
+ print edge
+
+def parse_input():
+ nodes={}
+ for line in sys.stdin:
+ line = line.replace('\n','')
+ if line == 'Nodes:':
+ nodes={}
+ for line in sys.stdin:
+ if line == 'End of nodes.\n':
+ break
+ l = line.replace('\n','').split() #TODO unhack me
+ nodes[l[0]]= { 'external-ip': l[2], 'external-port' : l[4] }
+ if line == 'Subnet list:':
+ for line in sys.stdin:
+ if line == 'End of subnet list.\n':
+ break
+ l = line.replace('\n','').split()
+ nodes[l[2]]['internal-ip'] = l[0].split('#')[0]
+ if line == 'Edges:':
+ edges = {}
+ for line in sys.stdin:
+ if line == 'End of edges.\n':
+ break
+ l = line.replace('\n','').split()
+
+ if not nodes[l[0]].has_key('to') :
+ nodes[l[0]]['to'] = []
+ nodes[l[0]]['to'].append(
+ {'name':l[2],'addr':l[4],'port':l[6],'weight' : l[10] })
+ return nodes
+nodes = parse_input()
+write_digraph(nodes)
diff --git a/modules/retiolum/scripts/adv_graphgen/sanitize.sh b/modules/retiolum/scripts/adv_graphgen/sanitize.sh
new file mode 100755
index 00000000..88591b67
--- /dev/null
+++ b/modules/retiolum/scripts/adv_graphgen/sanitize.sh
@@ -0,0 +1,13 @@
+GRAPH_SETTER1=dot
+GRAPH_SETTER2=circo
+LOG_FILE=/var/log/everything.log
+OPENER=/bin/true
+
+sudo pkill -USR2 tincd
+sudo sed -n '/tinc.retiolum/{s/.*tinc.retiolum\[[0-9]*\]: //gp}' $LOG_FILE |\
+ ./parse.py > retiolum.dot
+
+$GRAPH_SETTER1 -Tpng -o $1retiolum_1.png retiolum.dot
+$GRAPH_SETTER2 -Tpng -o $1retiolum_2.png retiolum.dot
+$OPENER retiolum_1.png &>/dev/null
+rm retiolum.dot
diff --git a/modules/retiolum/scripts/autostart/Makefile b/modules/retiolum/scripts/autostart/Makefile
new file mode 100644
index 00000000..7ca589e1
--- /dev/null
+++ b/modules/retiolum/scripts/autostart/Makefile
@@ -0,0 +1,8 @@
+INIT_FOLDER=/etc/init.d
+.phony: all
+all:
+ #TODO change the tinc file before writing
+ cp tinc $(INIT_FOLDER)/tinc
+ chmod +x $(INIT_FOLDER)/tinc
+ echo "retiolum" > /etc/tinc/nets.boot
+ update-rc.d tinc defaults
diff --git a/modules/retiolum/scripts/autostart/tinc b/modules/retiolum/scripts/autostart/tinc
new file mode 100755
index 00000000..12e77d6a
--- /dev/null
+++ b/modules/retiolum/scripts/autostart/tinc
@@ -0,0 +1,94 @@
+#! /bin/sh
+#
+### BEGIN INIT INFO
+# Provides: tinc
+# Required-Start: $remote_fs $network
+# Required-Stop: $remote_fs $network
+# Should-Start: $syslog $named
+# Should-Stop: $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Start tinc daemons
+# Description: Create a file $NETSFILE (/etc/tinc/nets.boot),
+# and put all the names of the networks in there.
+# These names must be valid directory names under
+# $TCONF (/etc/tinc). Lines starting with a # will be
+# ignored in this file.
+### END INIT INFO
+#
+# Based on Lubomir Bulej's Redhat init script.
+
+DAEMON="/usr/sbin/tincd"
+NAME="tinc"
+DESC="tinc daemons"
+TCONF="/etc/tinc"
+NETSFILE="$TCONF/nets.boot"
+NETS=""
+
+modprobe tun
+
+test -f $DAEMON || exit 0
+
+[ -r /etc/default/tinc ] && . /etc/default/tinc
+
+# foreach_net "what-to-say" action [arguments...]
+foreach_net() {
+ if [ ! -f $NETSFILE ] ; then
+ echo "Please create $NETSFILE."
+ exit 0
+ fi
+ echo -n "$1"
+ shift
+ egrep '^[ ]*[a-zA-Z0-9_-]+' $NETSFILE | while read net args; do
+ echo -n " $net"
+ "$@" $net $args
+ done
+ echo "."
+}
+
+start() {
+ $DAEMON $EXTRA -n "$@"
+}
+stop() {
+ $DAEMON -n $1 -k
+}
+reload() {
+ $DAEMON -n $1 -kHUP
+}
+restart() {
+ stop "$@"
+ sleep 0.5
+ i=0;
+ while [ -f /var/run/tinc.$1.pid ] ; do
+ if [ $i = '10' ] ; then
+ break
+ else
+ echo -n "."
+ sleep 0.5
+ i=$(($i+1))
+ fi
+ done
+ start "$@"
+}
+
+case "$1" in
+ start)
+ foreach_net "Starting $DESC:" start
+ ;;
+ stop)
+ foreach_net "Stopping $DESC:" stop
+ ;;
+ reload|force-reload)
+ foreach_net "Reloading $DESC configuration:" reload
+ ;;
+ restart)
+ foreach_net "Restarting $DESC:" restart
+ ;;
+ *)
+ echo "Usage: /etc/init.d/$NAME {start|stop|reload|restart|force-reload}"
+ exit 1
+ ;;
+esac
+
+exit 0
+
diff --git a/modules/retiolum/scripts/tinc_multicast/retiolum b/modules/retiolum/scripts/tinc_multicast/retiolum
new file mode 100755
index 00000000..1d6b775f
--- /dev/null
+++ b/modules/retiolum/scripts/tinc_multicast/retiolum
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+
+TINCNAME='retiolum'
+case "$1" in
+ start)
+ stat_busy "Starting retiolum Daemon"
+ success=0
+ /home/death/git/retiolum/.scripts/tinc_multicast/retiolum.py -n retiolum -T &
+ sleep 2
+ if [ $success -eq 0 ]; then
+ add_daemon retiolum
+ stat_done
+ else
+ stat_fail
+ fi
+ ;;
+ stop)
+ stat_busy "Stopping retiolum Daemon"
+ kill `cat /var/lock/retiolum.retiolum`
+ rm_daemon retiolum
+ stat_done
+ ;;
+ restart)
+ $0 stop
+ sleep 4
+ $0 start
+ ;;
+ *)
+ echo "usage $0 {start¦stop¦restart}"
+esac
+exit 0
diff --git a/modules/retiolum/scripts/tinc_multicast/retiolum.py b/modules/retiolum/scripts/tinc_multicast/retiolum.py
new file mode 100755
index 00000000..8cf57471
--- /dev/null
+++ b/modules/retiolum/scripts/tinc_multicast/retiolum.py
@@ -0,0 +1,349 @@
+#!/usr/bin/python2
+import sys, os, time, signal, socket, subprocess, thread, random, Queue, binascii, logging, hashlib, urllib2 #these should all be in the stdlib
+from optparse import OptionParser
+
+def pub_encrypt(hostname_t, text): #encrypt data with public key
+ logging.debug("encrypt: " + text)
+ if hostname_t.find("`") != -1: return(-1)
+ try:
+ enc_text = subprocess.os.popen("echo '" + text + "' | openssl rsautl -pubin -inkey /etc/tinc/" + netname + "/hosts/.pubkeys/" + hostname_t + " -encrypt | base64 -w0")
+ return(enc_text.read())
+ except:
+ return(-1)
+
+def priv_decrypt(enc_data): #decrypt data with private key
+ if enc_data.find("`") != -1: return(-1)
+ dec_text = subprocess.os.popen("echo '" + enc_data + "' | base64 -d | openssl rsautl -inkey /etc/tinc/" + netname + "/rsa_key.priv -decrypt")
+ return(dec_text.read())
+
+def address2hostfile(hostname, address): #adds address to hostsfile or restores it if address is empty
+ hostfile = "/etc/tinc/" + netname + "/hosts/" + hostname
+ addr_file = open(hostfile, "r")
+ addr_cache = addr_file.readlines()
+ addr_file.close()
+ if address != "":
+ addr_cache.insert(0, "Address = " + address + "\n")
+ addr_file = open(hostfile, "w")
+ addr_file.writelines(addr_cache)
+ addr_file.close
+ logging.info("sending SIGHUP to tinc deamon!")
+ tincd_ALRM = subprocess.call(["tincd -n " + netname + " --kill=HUP" ],shell=True)
+ else:
+ recover = subprocess.os.popen("tar xzf /etc/tinc/" + netname + "/hosts/hosts.tar.gz -C /etc/tinc/" + netname + "/hosts/ " + hostname)
+
+def findhostinlist(hostslist, hostname, ip): #finds host + ip in list
+ for line in xrange(len(hostslist)):
+ if hostname == hostslist[line][0] and ip == hostslist[line][1]:
+ return line
+ return -1 #nothing found
+
+def getHostname(netname):
+ tconf = open("/etc/tinc/" + netname + "/tinc.conf", "r")
+ feld = tconf.readlines()
+ tconf.close()
+ for x in feld:
+ if x.startswith("Name"):
+ return str(x.partition("=")[2].lstrip().rstrip("\n"))
+
+ print("hostname not found!")
+ return -1 #nothing found
+
+def get_hostfiles(url_files, url_md5sum):
+ try:
+ get_hosts_tar = urllib2.urlopen(url_files)
+ get_hosts_md5 = urllib2.urlopen(url_md5sum)
+ hosts_tar = get_hosts_tar.read()
+ hosts_md5 = get_hosts_md5.read()
+
+ if str(hosts_md5) == str(hashlib.md5(hosts_tar).hexdigest() + " hosts.tar.gz\n"):
+ hosts = open("/etc/tinc/" + netname + "/hosts/hosts.tar.gz", "w")
+ hosts.write(hosts_tar)
+ hosts.close()
+ else:
+ logging.error("hosts.tar.gz md5sum check failed!")
+ except:
+ logging.error("hosts file download failed!")
+
+
+####Thread functions
+
+
+def sendthread(sendfifo, ghostmode): #send to multicast, sends keep alive packets
+ while True:
+ try:
+ #{socket init start
+ ANY = "0.0.0.0"
+ SENDPORT = 23542
+ MCAST_ADDR = "224.168.2.9"
+ MCAST_PORT = 1600
+
+ sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) #initalize socket with udp
+ sock.bind((ANY,SENDPORT)) #now bound to Interface and Port
+ sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 255) #activate multicast
+ #}socket init end
+
+ if ghostmode == 0:
+
+ i = 9
+
+ while True:
+ i += 1
+ if not sendfifo.empty():
+ sock.sendto(sendfifo.get(), (MCAST_ADDR,MCAST_PORT) )
+ logging.info("send: sending sendfifo")
+ else:
+ time.sleep(1)
+ if i == 10:
+ sock.sendto("#Stage1#" + netname + "#" + hostname + "#", (MCAST_ADDR,MCAST_PORT) )
+ logging.debug("send: sending keep alive")
+ i = 0
+ else:
+ while True:
+ if not sendfifo.empty():
+ sock.sendto(sendfifo.get(), (MCAST_ADDR,MCAST_PORT) )
+ logging.info("send: sending sendfifo")
+ else:
+ time.sleep(1)
+
+ except:
+ logging.error("send: socket init failed")
+ time.sleep(10)
+
+
+
+def recvthread(timeoutfifo, authfifo): #recieves input from multicast, send them to timeout or auth
+ while True:
+ try:
+ ANY = "0.0.0.0"
+ MCAST_ADDR = "224.168.2.9"
+ MCAST_PORT = 1600
+
+ sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) #create a UDP socket
+ sock.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1) #allow multiple sockets to use the same PORT number
+ sock.bind((ANY,MCAST_PORT)) #Bind to the port that we know will receive multicast data
+ sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 255) #tell the kernel that we are a multicast socket
+
+
+ status = sock.setsockopt(socket.IPPROTO_IP,
+ socket.IP_ADD_MEMBERSHIP, #Tell the kernel that we want to add ourselves to a multicast group
+ socket.inet_aton(MCAST_ADDR) + socket.inet_aton(ANY)); #The address for the multicast group is the third param
+
+ while True:
+ while True:
+
+ try:
+ data, addr = sock.recvfrom(1024)
+ ip, port = addr
+ break
+ except socket.error, e:
+ pass
+
+ logging.debug("recv: got data")
+ dataval = data.split("#")
+ if dataval[0] == "":
+ if dataval[2] == netname:
+ if dataval[1] == "Stage1":
+ if dataval[3] != hostname:
+ timeoutfifo.put(["tst", dataval[3], ip])
+ logging.info("recv: got Stage1: writing data to timeout")
+ logging.debug("recv: ;tst;" + dataval[3] + ";" + ip)
+ if dataval[1] == "Stage2":
+ if dataval[3] == hostname:
+ authfifo.put([dataval[1], dataval[3], ip, dataval[4]])
+ logging.info("recv: got Stage2: writing data to auth")
+ logging.debug("recv: ;" + dataval[1] + ";" + dataval[3] + ";" + ip + ";" + dataval[4])
+ if dataval[1] == "Stage3":
+ if dataval[3] != hostname:
+ authfifo.put([dataval[1], dataval[3], ip, dataval[4]])
+ logging.info("recv: got Stage3: writing data to auth")
+ logging.debug("recv: ;" + dataval[1] + ";" + dataval[3] + ";" + ip + ";" + dataval[4])
+ except:
+ logging.error("recv: socket init failed")
+ time.sleep(10)
+
+def timeoutthread(timeoutfifo, authfifo): #checks if the hostname is already in the list, deletes timeouted nodes
+# hostslist = [] #hostname, ip, timestamp
+
+ while True:
+ if not timeoutfifo.empty():
+ curhost = timeoutfifo.get()
+ if curhost[0] == "add":
+ with hostslock:
+ hostslist.append([curhost[1], curhost[2], time.time()])
+ address2hostfile(curhost[1], curhost[2])
+ logging.info("adding host to hostslist")
+ elif curhost[0] == "tst":
+ with hostslock:
+ line = findhostinlist(hostslist, curhost[1], curhost[2])
+ if line != -1:
+ hostslist[line][2] = time.time()
+ logging.debug("timeout: refreshing timestamp of " + hostslist[line][0])
+ else:
+ authfifo.put(["Stage1", curhost[1], curhost[2]])
+ logging.info("timeout: writing to auth")
+
+ else:
+ i = 0
+ with hostslock:
+ while i < len(hostslist):
+ if time.time() - hostslist[i][2] > 60:
+ address2hostfile(hostslist[i][0], "")
+ hostslist.remove(hostslist[i])
+ logging.info("timeout: deleting dead host")
+ else:
+ i += 1
+ time.sleep(2)
+
+def auththread(authfifo, sendfifo, timeoutfifo): #manages authentication with clients (bruteforce sensitve, should be fixed)
+ authlist = [] #hostname, ip, Challenge, timestamp
+
+
+ while True:
+ try:
+ if not authfifo.empty():
+ logging.debug("auth: authfifo is not empty")
+ curauth = authfifo.get()
+ if curauth[0] == "Stage1":
+ line = findhostinlist(authlist, curauth[1], curauth[2])
+ if line == -1:
+ challengenum = random.randint(0,65536)
+ encrypted_message = pub_encrypt(curauth[1], "#" + hostname + "#" + str(challengenum) + "#")
+ authlist.append([curauth[1], curauth[2], challengenum, time.time()])
+ else:
+ encrypted_message = pub_encrypt(authlist[line][0], "#" + hostname + "#" + str(authlist[line][2]) + "#")
+ if encrypted_message == -1:
+ logging.info("auth: RSA Encryption Error")
+ else:
+ sendtext = "#Stage2#" + netname + "#" + curauth[1] + "#" + encrypted_message + "#"
+ sendfifo.put(sendtext)
+ logging.info("auth: got Stage1 sending now Stage2")
+ logging.debug("auth: " + sendtext)
+
+ if curauth[0] == "Stage2":
+ dec_message = priv_decrypt(curauth[3])
+ splitmes = dec_message.split("#")
+ if splitmes[0] == "":
+ encrypted_message = pub_encrypt(splitmes[1], "#" + splitmes[2] + "#")
+ if encrypted_message == -1:
+ logging.error("auth: RSA Encryption Error")
+ else:
+ sendtext = "#Stage3#" + netname + "#" + curauth[1] + "#" + encrypted_message + "#"
+ sendfifo.put(sendtext)
+ logging.info("auth: got Stage2 sending now Stage3")
+ logging.debug("auth: " + sendtext)
+
+ if curauth[0] == "Stage3":
+ line = findhostinlist(authlist, curauth[1], curauth[2])
+ if line != -1:
+ dec_message = priv_decrypt(curauth[3])
+ splitmes = dec_message.split("#")
+ logging.info("auth: checking challenge")
+ if splitmes[0] == "":
+ if splitmes[1] == str(authlist[line][2]):
+ timeoutfifo.put(["add", curauth[1], curauth[2]])
+ del authlist[line]
+ logging.info("auth: Stage3 checked, sending now to timeout")
+ else: logging.error("auth: challenge checking failed")
+ else: logging.error("auth: decryption failed")
+
+ else:
+ i = 0
+ while i < len(authlist):
+ if time.time() - authlist[i][3] > 120:
+ del authlist[i]
+ logging.info("auth: deleting timeoutet auth")
+ else:
+ i += 1
+ time.sleep(1)
+ except:
+ logging.error("auth: thread crashed")
+
+def process_start(): #starting of the process
+ #download and untar hostfile
+ logging.info("downloading hostfiles")
+ get_hostfiles("http://vpn.miefda.org/hosts.tar.gz", "http://vpn.miefda.org/hosts.md5") #Currently Hardcoded, should be editable by config or parameter
+ tar = subprocess.call(["tar -xzf /etc/tinc/" + netname + "/hosts/hosts.tar.gz -C /etc/tinc/" + netname + "/hosts/"], shell=True)
+
+ #initialize fifos
+ sendfifo = Queue.Queue() #sendtext
+ authfifo = Queue.Queue() #Stage{1, 2, 3} hostname ip enc_data
+ timeoutfifo = Queue.Queue() #State{tst, add} hostname ip
+
+ #start threads
+ thread_recv = thread.start_new_thread(recvthread, (timeoutfifo, authfifo))
+ thread_send = thread.start_new_thread(sendthread, (sendfifo, option.ghost))
+ thread_timeout = thread.start_new_thread(timeoutthread, (timeoutfifo, authfifo))
+ thread_auth = thread.start_new_thread(auththread, (authfifo, sendfifo, timeoutfifo))
+
+def process_restart(signum, frame):
+ logging.error("root: restarting process")
+ with hostslock:
+ del hostslist[:]
+ #download and untar hostfile
+ logging.info("downloading hostfiles")
+ get_hostfiles("http://vpn.miefda.org/hosts.tar.gz", "http://vpn.miefda.org/hosts.md5") #Currently Hardcoded, should be editable by config or parameter
+ tar = subprocess.call(["tar -xzf /etc/tinc/" + netname + "/hosts/hosts.tar.gz -C /etc/tinc/" + netname + "/hosts/"], shell=True)
+
+ logging.info("sending SIGHUP")
+ tincd_ALRM = subprocess.call(["tincd -n " + netname + " --kill=HUP" ],shell=True)
+
+def kill_process(signum, frame):
+ logging.error("got SIGINT/SIGTERM exiting now")
+ os.remove("/var/lock/retiolum." + netname)
+ if option.tinc != False:
+ stop_tincd = subprocess.call(["tincd -n " + netname + " -k"],shell=True)
+ sys.exit(0)
+
+#Program starts here!
+
+parser = OptionParser()
+parser.add_option("-n", "--netname", dest="netname", help="the netname of the tinc network")
+parser.add_option("-H", "--hostname", dest="hostname", default="default", help="your nodename, if not given, it will try too read it from tinc.conf")
+parser.add_option("-t", "--timeout", dest="timeout", default=65536, help="timeout after retiolum gets restartet, default is 65536")
+parser.add_option("-d", "--debug", dest="debug", default="0", help="debug level: 0,1,2,3 if empty debug level=0")
+parser.add_option("-g", "--ghost", action="store_true", dest="ghost", default=False, help="deactivates active sending, keeps you anonymous in the public network")
+parser.add_option("-T", "--Tinc", action="store_true", dest="tinc", default=False, help="starts tinc with this script")
+(option, args) = parser.parse_args()
+
+if option.netname == None:
+ parser.error("Netname is required, use -h for help!")
+if option.hostname == "default":
+ option.hostname = getHostname(option.netname)
+
+hostname = option.hostname
+netname = option.netname
+hostslist = []
+hostslock = thread.allocate_lock()
+
+#set process name
+if not os.path.exists("/var/lock/retiolum." + netname):
+ pidfile = open("/var/lock/retiolum." + netname, "w")
+ pidfile.write(str(os.getpid()))
+ pidfile.close()
+else:
+ logging.error("pidfile already exists")
+ sys.exit(0)
+
+#Logging stuff
+LEVELS = {'3' : logging.DEBUG,
+ '2' : logging.INFO,
+ '1' : logging.ERROR,
+ '0' : logging.CRITICAL}
+
+level_name = option.debug
+level = LEVELS.get(level_name, logging.NOTSET)
+logging.basicConfig(level=level)
+
+#normally tinc doesnt start with retiolum
+if option.tinc != False:
+ start_tincd = subprocess.call(["tincd -n " + netname ],shell=True)
+
+process_start()
+
+signal.signal(signal.SIGTERM, kill_process)
+signal.signal(signal.SIGINT, kill_process)
+signal.signal(signal.SIGUSR1, process_restart)
+
+while True:
+ time.sleep(float(option.timeout))
+ process_restart(0, 0)
diff --git a/modules/retiolum/scripts/tinc_setup/README b/modules/retiolum/scripts/tinc_setup/README
new file mode 100644
index 00000000..11d6f6e9
--- /dev/null
+++ b/modules/retiolum/scripts/tinc_setup/README
@@ -0,0 +1,18 @@
+This directory contains the build and install scripts for shack-retiolum
+
+1. build_arch
+ arch linux build script
+2. build_debian
+ debian build script
+3. build_debian_clean
+ debian script which builds a clean tinc daemon
+4. build_ec2
+ Amazon ec2 base instance build script
+5. install.sh
+ configures the tinc daemon
+ $1 is the nickname
+ $2 is the ip-address
+ also writes a python file inside the tinc/retiolum folder which posts
+ the public key into the IRC:freenode/#tincspasm
+6. build_no.de
+ nonfunct no.de smartmachine build script
diff --git a/modules/retiolum/scripts/tinc_setup/bootstrap.sh b/modules/retiolum/scripts/tinc_setup/bootstrap.sh
new file mode 100644
index 00000000..32919e7d
--- /dev/null
+++ b/modules/retiolum/scripts/tinc_setup/bootstrap.sh
@@ -0,0 +1,11 @@
+if [ ! `id -u` -eq "0" ]
+then
+ echo "not root, trying sudo"
+ exec sudo "$0" "$@"
+fi
+
+mkdir -p /etc/tinc/retiolum/
+git clone git://github.com/miefda/retiolum.git /etc/tinc/retiolum/hosts
+cd /etc/tinc/retiolum/hosts/.scripts
+
+echo "use the build script of your choice from /etc/tinc/retiolum/hosts/.scripts"
diff --git a/modules/retiolum/scripts/tinc_setup/build_arch.sh b/modules/retiolum/scripts/tinc_setup/build_arch.sh
new file mode 100755
index 00000000..5ef5d765
--- /dev/null
+++ b/modules/retiolum/scripts/tinc_setup/build_arch.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+set -e
+sudo pacman -S openssl gcc lzo
+curl http://www.tinc-vpn.org/packages/tinc-1.0.13.tar.gz | tar xz
+cd tinc-1.0.13
+./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var
+make
+sudo make install
+cd ..
+
+echo "overwriting python to python2"
+sed 's/\/usr\/bin\/python/\/usr\/bin\/python2/g' install.sh >install2.sh
+mv install2.sh install.sh
+
diff --git a/modules/retiolum/scripts/tinc_setup/build_debian.sh b/modules/retiolum/scripts/tinc_setup/build_debian.sh
new file mode 100755
index 00000000..52e61390
--- /dev/null
+++ b/modules/retiolum/scripts/tinc_setup/build_debian.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+set -x
+if [ ! "$MYIP" ]
+then
+ MYIP=10.0.7.7.55
+fi
+if [ ! "$MYHOSTNAME" ]
+then
+ MYHOSTNAME="penis"
+fi
+
+if [ "$MYHOSTNAME" = "penis" ];
+then
+ read -n1 -p "name is penis, are u sure? [yN]"
+ if [[ "$REPLY" != [yY] ]]
+ then
+ echo "then better RTFC"
+ echo "bailing out"
+ exit 0
+ fi
+fi
+apt-get install tinc git curl python
+
+./install.sh "$MYHOSTNAME" "$MYIP"
+
+# for autostart
+sed -i '/retiolum/d' /etc/tinc/nets.boot
+echo "retiolum" >> /etc/tinc/nets.boot
+sed -i '/EXTRA/d' /etc/tinc/nets.boot
+echo "EXTRA=\"\"" >> /etc/default/tinc
+
+/etc/init.d/tinc start
diff --git a/modules/retiolum/scripts/tinc_setup/build_debian_clean.sh b/modules/retiolum/scripts/tinc_setup/build_debian_clean.sh
new file mode 100755
index 00000000..a7332f4e
--- /dev/null
+++ b/modules/retiolum/scripts/tinc_setup/build_debian_clean.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+set -xe
+MYIP=10.0.7.7.55
+
+apt-get install tinc git curl gcc gcc-dev build-essential libssl-dev python
+
+git clone https://github.com/makefu/shack-retiolum.git
+
+mkdir build
+cd build
+curl http://www.oberhumer.com/opensource/lzo/download/lzo-2.04.tar.gz | tar
+xz
+cd lzo-2.04
+./configure --prefix=/usr
+make
+sudo make install
+cd ..
+curl http://www.tinc-vpn.org/packages/tinc-1.0.13.tar.gz | tar xz
+cd tinc-1.0.13
+./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var
+make
+sudo make install
+cd ../..
+
+cd shack-retiolum
+./install.sh `hostname` $MYIP
+
+rm shack-retiolum
+# for autostart
+echo "retiolum" >> /etc/tinc/nets.boot
+echo "EXTRA=\"--user=tincd --chroot\"" >> /etc/default/tinc
diff --git a/modules/retiolum/scripts/tinc_setup/build_ec2.sh b/modules/retiolum/scripts/tinc_setup/build_ec2.sh
new file mode 100755
index 00000000..79f2af28
--- /dev/null
+++ b/modules/retiolum/scripts/tinc_setup/build_ec2.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+set -e
+sudo yum install -y gcc openssl-devel
+mkdir build
+cd build
+curl http://www.oberhumer.com/opensource/lzo/download/lzo-2.04.tar.gz | tar xz
+cd lzo-2.04
+./configure --prefix=/usr
+make
+sudo make install
+cd ..
+curl http://www.tinc-vpn.org/packages/tinc-1.0.13.tar.gz | tar xz
+cd tinc-1.0.13
+./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var
+make
+sudo make install
diff --git a/modules/retiolum/scripts/tinc_setup/build_no.de.sh b/modules/retiolum/scripts/tinc_setup/build_no.de.sh
new file mode 100644
index 00000000..2976d3a2
--- /dev/null
+++ b/modules/retiolum/scripts/tinc_setup/build_no.de.sh
@@ -0,0 +1 @@
+pkgin in lzo gcc-tools gcc-compiler gcc34
diff --git a/modules/retiolum/scripts/tinc_setup/install.sh b/modules/retiolum/scripts/tinc_setup/install.sh
new file mode 100755
index 00000000..de7d2225
--- /dev/null
+++ b/modules/retiolum/scripts/tinc_setup/install.sh
@@ -0,0 +1,72 @@
+#! /bin/sh
+# USE WITH GREAT CAUTION
+
+make -C ../../ update
+set -e
+
+CURR=`dirname "$0"`
+MYBIN=../../bin
+netname=retiolum
+# create configuration directory for $netname
+mkdir -p /etc/tinc/$netname/hosts
+cd /etc/tinc/$netname
+
+echo "added known hosts:"
+ls -1 hosts | LC_ALL=C sort
+echo "delete the nodes you do not trust!"
+
+myname="${1:-}"
+if [ ! "$myname" ]
+then
+ echo "select username: "
+ read myname
+fi
+if [ ! -e "hosts/$myname" ]
+then
+ myipv4="${2:-}"
+ mynet4=10.7.7.0
+
+ if [ ! "$myipv4" ]
+ then
+ echo "select v4 subnet ip (1-255) :"
+ read v4num
+ if [ "$v4num" -gt 0 -a "$v4num" -lt "256" ];
+ then
+ echo "check"
+ else
+ echo "you are made of stupid. bailing out"
+ exit 1
+ fi
+ myipv4=10.7.7.$v4num
+ fi
+ echo "Subnet = $myipv4" > hosts/$myname
+
+ myipv6=`${CURR}/../../bin/fillxx 42:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx`/128
+ echo "Subnet = $myipv6" >> hosts/$myname
+else
+ echo "own host file already exists! will not write again!"
+fi
+
+cp $CURR/tinc-up .
+
+cat>tinc.conf<<EOF
+Name = $myname
+ConnectTo = supernode
+ConnectTo = kaah
+ConnectTo = pa_sharepoint
+Device = /dev/net/tun
+EOF
+
+if [ ! -e rsa_key.priv ]
+then
+ echo "creating new keys"
+ tincd -n $netname -K
+ python ${CURR}/write_channel.py || \
+ echo "cannot write public key to IRC, you are on your own. Good Luck"
+else
+ echo "key files already exist, skipping"
+ echo "if you know what you are doing, remove rsa_key.priv"
+fi
+# add user tincd
+# this is what the setup scripts for the distribution has to do
+#useradd tincd
diff --git a/modules/retiolum/scripts/tinc_setup/tinc-up b/modules/retiolum/scripts/tinc_setup/tinc-up
new file mode 100755
index 00000000..9e6148da
--- /dev/null
+++ b/modules/retiolum/scripts/tinc_setup/tinc-up
@@ -0,0 +1,20 @@
+# source: krebscode/painload/modules/retiolum/scripts/tinc_setup/tinc-up
+
+dirname="`dirname "$0"`"
+
+conf=$dirname/tinc.conf
+
+name=`sed -rn 's|^ *Name *= *([^ ]*) *$|\1|p' $conf`
+
+host=$dirname/hosts/$name
+
+route4=10.7.7.0/24
+addr4=`sed -rn 's|^ *Subnet *= *(10\.[^ ]*) *$|\1|p' $host`
+
+route6=42::/16
+addr6=`sed -rn 's|^ *Subnet *= *(42:[^ ]*) *$|\1|p' $host`
+
+ifconfig $INTERFACE up $addr4
+route add -net $route4 dev $INTERFACE
+ip -6 addr add $addr6 dev $INTERFACE
+ip -6 route add $route6 dev $INTERFACE
diff --git a/modules/retiolum/scripts/tinc_setup/write_channel.py b/modules/retiolum/scripts/tinc_setup/write_channel.py
new file mode 100644
index 00000000..a11d4605
--- /dev/null
+++ b/modules/retiolum/scripts/tinc_setup/write_channel.py
@@ -0,0 +1,26 @@
+#!/usr/bin/python
+import random, sys, time, socket
+try:
+ myname=sys.argv[1]
+except:
+ print "you are made of stupid"
+ exit (23)
+
+CHANNEL = '#tincspasm'
+HOST='irc.freenode.net'
+FILE="/etc/tinc/retiolum/hosts/"+myname
+PORT=6667
+NICK= myname+"_"+str(random.randint(23,666))
+
+sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
+sock.connect((HOST,PORT))
+print NICK
+sock.send("NICK %s\r\n" % NICK)
+sock.send("USER %s %s bla : %s\r\n" %(NICK,HOST,NICK))
+sock.send("JOIN %s\r\n" % CHANNEL)
+time.sleep(23)
+f = open(FILE,'r')
+a = [ sock.send("PRIVMSG %s : %s" % ( CHANNEL,line)) for line in f]
+time.sleep(5) #because irc is so lazy
+print "closing socket"
+sock.close()
diff --git a/modules/streams/Makefile b/modules/streams/Makefile
new file mode 100644
index 00000000..9f3076c0
--- /dev/null
+++ b/modules/streams/Makefile
@@ -0,0 +1,10 @@
+INITD = /etc/init.d/
+streams = groove deepmix radiotux
+.PHONY: all
+.PHONY: $(streams)
+
+all: $(streams)
+ update-rc.d groove defaults
+
+$(streams):
+ cp $@ $(INITD)$@
diff --git a/modules/streams/README b/modules/streams/README
new file mode 100644
index 00000000..82300c24
--- /dev/null
+++ b/modules/streams/README
@@ -0,0 +1,10 @@
+streams done right
+
+deepmix,groovesalad and radiotux are now init.d scrips which can be
+started and stopped.
+
+scripts are dumped into /etc/init.d and groovesalad will be set as
+default via update-rc.d
+
+mplayer will be started in a tmux session either by creating a new
+session or starting a new window inside the first existing one
diff --git a/modules/streams/deepmix b/modules/streams/deepmix
new file mode 100755
index 00000000..8b13bed6
--- /dev/null
+++ b/modules/streams/deepmix
@@ -0,0 +1,27 @@
+#! /bin/bash
+set -euf
+CMD="while :; do mplayer http://deepmix.ru/deepmix128.pls; done"
+function start() {
+ stop
+ tmux list-sessions &&
+ tmux new-window "$CMD" ||
+ tmux new-session "$CMD"
+}
+function stop() {
+ pkill mplayer || :
+}
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ stop
+ start
+ ;;
+ *)
+ echo "aidsballs"
+ ;;
+esac
diff --git a/modules/streams/groove b/modules/streams/groove
new file mode 100755
index 00000000..2d4a3e28
--- /dev/null
+++ b/modules/streams/groove
@@ -0,0 +1,29 @@
+#! /bin/bash
+set -euf
+function stop()
+{
+ pkill mplayer || true
+}
+
+CMD="while true; do exec mplayer http://somafm.com/groovesalad.pls; sleep 1;done"
+case "$1" in
+ start)
+ stop
+ if tmux list-sessions;
+ then
+ tmux new-window "$CMD" &
+ else
+ tmux new-session "$CMD" &
+ fi
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ stop
+ start
+ ;;
+ *)
+ echo "aidsballs"
+ ;;
+esac
diff --git a/modules/streams/radiotux b/modules/streams/radiotux
new file mode 100755
index 00000000..9d671493
--- /dev/null
+++ b/modules/streams/radiotux
@@ -0,0 +1,29 @@
+#! /bin/bash
+set -euf
+function stop()
+{
+ pkill mplayer || true
+}
+
+CMD="while true; do exec mplayer http://streams.xenim.de/radiotux.ogg; sleep 1;done"
+case "$1" in
+ start)
+ stop
+ if tmux list-sessions;
+ then
+ tmux new-window "$CMD" &
+ else
+ tmux new-session "$CMD" &
+ fi
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ stop
+ start
+ ;;
+ *)
+ echo "aidsballs"
+ ;;
+esac
diff --git a/modules/temper/.gitignore b/modules/temper/.gitignore
new file mode 100644
index 00000000..7e50641a
--- /dev/null
+++ b/modules/temper/.gitignore
@@ -0,0 +1 @@
+temper
diff --git a/modules/temper/99-tempsensor.rules b/modules/temper/99-tempsensor.rules
new file mode 100644
index 00000000..441a469e
--- /dev/null
+++ b/modules/temper/99-tempsensor.rules
@@ -0,0 +1 @@
+SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="1130", ATTRS{idProduct}=="660c", MODE="666"
diff --git a/modules/temper/Makefile b/modules/temper/Makefile
new file mode 100644
index 00000000..3ada08de
--- /dev/null
+++ b/modules/temper/Makefile
@@ -0,0 +1,14 @@
+
+all: infest
+infest: temper
+CFLAGS = -O2 -Wall
+
+temper: temper.c
+ ${CC} -DUNIT_TEST -o $@ $^ -lusb
+ chmod +s temper
+
+clean:
+ rm -f temper *.o
+
+rules-install: # must be superuser to do this
+ cp 99-tempsensor.rules /etc/udev/rules.d
diff --git a/modules/temper/temper.c b/modules/temper/temper.c
new file mode 100644
index 00000000..390f9056
--- /dev/null
+++ b/modules/temper/temper.c
@@ -0,0 +1,277 @@
+#include <stdio.h>
+#include <string.h>
+#include <usb.h>
+#include <errno.h>
+
+/*
+ * 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 0
+#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/modules/temper/temper.h b/modules/temper/temper.h
new file mode 100644
index 00000000..7ea6280a
--- /dev/null
+++ b/modules/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
diff --git a/modules/webcams/cam1.sh b/modules/webcams/cam1.sh
new file mode 100755
index 00000000..9cf709e6
--- /dev/null
+++ b/modules/webcams/cam1.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+mplayer tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0
diff --git a/modules/zoneminder/Makefile b/modules/zoneminder/Makefile
new file mode 100644
index 00000000..27302715
--- /dev/null
+++ b/modules/zoneminder/Makefile
@@ -0,0 +1,14 @@
+
+.PHONY: fix it so hard
+it: so
+so: it hard fix
+ apt-get install --yes zoneminder libv4l-0
+
+hard: /etc/sysctl.d/zoneminder.conf
+/etc/sysctl.d/zoneminder.conf: zoneminder.conf
+ cp $< $@
+ sysctl -p $@
+
+fix: zmdc.pl-LD_PRELOAD.patch
+ (cd /usr/bin && patch -N) < $< || :
+
diff --git a/modules/zoneminder/zmdc.pl-LD_PRELOAD.patch b/modules/zoneminder/zmdc.pl-LD_PRELOAD.patch
new file mode 100644
index 00000000..b00fc673
--- /dev/null
+++ b/modules/zoneminder/zmdc.pl-LD_PRELOAD.patch
@@ -0,0 +1,10 @@
+--- /usr/bin/zmdc.pl 2011-05-23 22:28:57.505247793 +0200
++++ /usr/bin/zmdc.pl 2011-05-23 22:29:45.597248242 +0200
+@@ -62,6 +62,7 @@
+ $ENV{SHELL} = '/bin/sh' if exists $ENV{SHELL};
+ delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
+
++$ENV{LD_PRELOAD} = '/usr/lib/libv4l/v4l2convert.so';
+ my @daemons = (
+ 'zmc',
+ 'zma',
diff --git a/modules/zoneminder/zoneminder.conf b/modules/zoneminder/zoneminder.conf
new file mode 100644
index 00000000..1eec6fd9
--- /dev/null
+++ b/modules/zoneminder/zoneminder.conf
@@ -0,0 +1,2 @@
+kernel.shmall = 134217728
+kernel.shmmax = 134217728
[cgit] Unable to lock slot /tmp/cgit/83100000.lock: No such file or directory (2)