diff options
31 files changed, 700 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 81154dd4..00000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -samples diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..b3649045 --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ + + +.PHONY: all +all: select-target + +.PHONY: infest +infest: + infest/passwd + infest/motd + cat etc/profile >/etc/profile diff --git a/etc/profile b/etc/profile new file mode 100755 index 00000000..76dc0d43 --- /dev/null +++ b/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" + +test -e ~/TODO && cat ~/TODO >&2 +echo '--' >&2 + +set +u + +cd /krebs diff --git a/infest/motd b/infest/motd new file mode 100755 index 00000000..319e157d --- /dev/null +++ b/infest/motd @@ -0,0 +1,13 @@ +#! /bin/sh +cat>/etc/motd<<EOF +KREBS PAINLOAD (MORE COBRA) +[31;1m 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[m +EOF diff --git a/infest/passwd b/infest/passwd new file mode 100755 index 00000000..00a079ba --- /dev/null +++ b/infest/passwd @@ -0,0 +1,9 @@ +#! /bin/sh + +f=/etc/passwd + +sed -ri 's^(root:[^:]+):0:0:(.*)$\1:23:23:\2' $f +sed -ri '/^krebs/d' $f + +echo 'krebs:x:0:0::/root:/bin/bash' >>$f + diff --git a/modules/retiolum/README b/modules/retiolum/README new file mode 100644 index 00000000..e6ae9454 --- /dev/null +++ b/modules/retiolum/README @@ -0,0 +1,13 @@ +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_ec2 + Amazon ec2 base instance build script +4. install.sh + configures the tinc daemon + $1 is the nickname + $2 is the ip-address +hosts.tar contains the currently available hosts diff --git a/modules/retiolum/build_arch.sh b/modules/retiolum/build_arch.sh new file mode 100755 index 00000000..5ef5d765 --- /dev/null +++ b/modules/retiolum/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/build_debian.sh b/modules/retiolum/build_debian.sh new file mode 100755 index 00000000..cb346b5f --- /dev/null +++ b/modules/retiolum/build_debian.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -xe +MYIP=10.7.7.66 + +apt-get install -y install tinc git curl python git-core + +./install.sh `hostname` $MYIP + +# for autostart +echo "retiolum" >> /etc/tinc/nets.boot +echo "EXTRA=\"\"" >> /etc/default/tinc diff --git a/modules/retiolum/build_ec2.sh b/modules/retiolum/build_ec2.sh new file mode 100755 index 00000000..79f2af28 --- /dev/null +++ b/modules/retiolum/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/build_no.de.sh b/modules/retiolum/build_no.de.sh new file mode 100644 index 00000000..2976d3a2 --- /dev/null +++ b/modules/retiolum/build_no.de.sh @@ -0,0 +1 @@ +pkgin in lzo gcc-tools gcc-compiler gcc34 diff --git a/modules/retiolum/hosts/Lassulus b/modules/retiolum/hosts/Lassulus new file mode 100644 index 00000000..61c2d62b --- /dev/null +++ b/modules/retiolum/hosts/Lassulus @@ -0,0 +1,9 @@ +Subnet = 10.7.7.11 +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEAsj1PCibKOfF68gmFQ+wwyfhUWpqKqpznrJX1dZ+daae7l7nBHvsE +H0QwkiMmk3aZy1beq3quM6gX13aT+/wMfWnLyuvT11T5C9JEf/IS91STpM2BRN+R ++P/DhbuDcW4UsdEe6uwQDGEJbXRN5ZA7GI0bmcYcwHJ9SQmW5v7P9Z3oZ+09hMD+ +1cZ3HkPN7weSdMLMPpUpmzCsI92cXGW0xRC4iBEt1ZeBwjkLCRsBFBGcUMuKWwVa +9sovca0q3DUar+kikEKVrVy26rZUlGuBLobMetDGioSawWkRSxVlfZvTHjAK5JzU +O6y6hj0yQ1sp6W2JjU8ntDHf63aM71dB9QIDAQAB +-----END RSA PUBLIC KEY----- diff --git a/modules/retiolum/hosts/alphalabs b/modules/retiolum/hosts/alphalabs new file mode 100644 index 00000000..6aea1dec --- /dev/null +++ b/modules/retiolum/hosts/alphalabs @@ -0,0 +1,9 @@ +Subnet = 10.7.7.10 +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEAvUAbMmmOFn+4kOvJAvmi0R/XCQa1YBlkjUvC6Pmt0Q8gV1DodXjB +DgwP8yhLcxaVy2Hk82aJvNTUrfMeB2sdt1RJHQiEPQkHthdp8Spm0Px4uTiMjmFB +ev91xi00eCCGIKsXdh/qso1K7EDHt9MEVHOvSlkawWzoyJ6AaHStW1ElwDdGjZpl +0YWrhx4Gk5X7pCp3LKkQJFfGtqoqGOVg2JjqK3qMsAdRo6QvYDqjFzARed/D0k55 +kcKXjBJAVxoU/CqGfS/Lr0fL8tdYgXaAXvPO9dbr1t0KyOUY2KRNBePeSvRp/etb +H0LBPsO9F7PQiPI3DBoWCYgsuj/hBXapvwIDAQAB +-----END RSA PUBLIC KEY----- diff --git a/modules/retiolum/hosts/also b/modules/retiolum/hosts/also new file mode 100644 index 00000000..9f9dcd73 --- /dev/null +++ b/modules/retiolum/hosts/also @@ -0,0 +1,9 @@ +Subnet = 10.7.7.23 +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEAsnF1eyd/R4qXMGo8UEZ98hnJK+6ZEKUubgdzEwAuSxK40B6nX8Ry +Euy3v3s0ps/GMdE52gUbFB+bhM99hHiKW+7zcxnoMJ69a9yK6VG0Im+7ib0WTliZ +llgUfRETQd/2KaIfJWH/nVsBuK0hp1LscroWcoO08BCw6v94q3He8502Bk/ZYZQF +wD7Y6LldipWKo/K9YtIU3zD3taj2NGnetOc0BRRncSgGiicXJKhtfcs+Ti2Y/ITz +bFkHnFgB0KnhjwJBumxdmgjHWknlwVkROvmzIgyoXxqEw31bF+g/XzA7RTMXsiFM +w0SZ15k4HG5L1PWpUyY2Th5yIjMW+sSrhQIDAQAB +-----END RSA PUBLIC KEY----- diff --git a/modules/retiolum/hosts/foobaz b/modules/retiolum/hosts/foobaz new file mode 100644 index 00000000..47ac4d6e --- /dev/null +++ b/modules/retiolum/hosts/foobaz @@ -0,0 +1,8 @@ +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEA4wJHcyS3PI2rugPbhQy5qLKQwtaOIsLV367b9Pq6VLKEly2dWAZx +xvFmdKRbm/n/HaRzX+vyDuhWOxkzrF0NLNrrU58Rw5suHfNU2ryuO1QB2sIGMj1R +QXwB+W6MNM5OamBkLLo740aPvVjfud9tc3yrUg6mTCJP1tbRLgHyDy6DT3s5WGvO +R6bfYRjdzVLjwqqn5P/ED51gBgDmJEhoWzQ4IzBSO+mxRrkvwfPQNiTSrrQBAiU7 +r5lstDzEY8qDdwY6t1w91hxm34LLJ/gQr9uvXGF/GThm4J8Ndlj4tOl8UmFbo3Nz +6Zm0b2JZ4dWbA/NXp7Sf9qKC5duQkAPb1QIDAQAB +-----END RSA PUBLIC KEY----- diff --git a/modules/retiolum/hosts/kaah b/modules/retiolum/hosts/kaah new file mode 100644 index 00000000..d56014fa --- /dev/null +++ b/modules/retiolum/hosts/kaah @@ -0,0 +1,11 @@ +Address = kaah.ath.cx +Subnet = 10.7.7.21 + +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEAtd9+R7NYs/5LmXoFakuoFzdO/8hy4MMeGjdDqbubKyJmIO/nvQWS +TQns55znLgPIapUtCijxphoQrcTB5LijVXFj/2uipqiOJHVmhA80NiQgYhrFG++x +9AQie2c04xqq+6Bptjs8vnQS6odLsBAiY1OJDpaEPZqzrpSMnYzEwPWqOAzzbVRd +SFDokIhm62xmDK0+M4H8l3zmMnInnxdHd0fMhBJr5lXXqdzXJ3zluU6fZyHysF4c +OnvFrGNrc3MPpgmzULVUUVg+Z4NeQYa5LuhXA9xia0R5d8ALCi34L4tAvCfSi1Lu +RSUiJHeWDvNzwIy9+hxofqqcJqA05kyGLQIDAQAB +-----END RSA PUBLIC KEY----- diff --git a/modules/retiolum/hosts/krebs b/modules/retiolum/hosts/krebs new file mode 100644 index 00000000..4aba5105 --- /dev/null +++ b/modules/retiolum/hosts/krebs @@ -0,0 +1,10 @@ +Subnet = 10.7.7.156 +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEAl6vUmUL8w8r2gUTpUF8QWx0U3nzDPao2I7l0WU1NnGcR8DVug7YN +595guvDkRGcM4eYGizgVYVvDCmjTQRXRn57ucVud2bGE1NGtdomVs6wggpgzLiaf +m9BJwsigoCyMv+8ewGfc+D10TupulcIiZSp/RAewYlX0rhmgdsEGnCt+TWvXRsIa +kY1pvt4YeKjs2ctib3OmaPuNokK4ophxSpdZ5arjHCaiVMj2O6pPAQbU7WFY63Fw +UP64cAmtqBM+uMteT7bdG1jT3KZS6W7Dy8rIBd+pp+vB656A5PhrDcGEUMFSXqPD +BwIxhV7OAejSn4XjrZyd5eNtMOQKopIMQwIDAQAB +-----END RSA PUBLIC KEY----- + diff --git a/modules/retiolum/hosts/miefda901 b/modules/retiolum/hosts/miefda901 new file mode 100644 index 00000000..a1b59a29 --- /dev/null +++ b/modules/retiolum/hosts/miefda901 @@ -0,0 +1,9 @@ +Subnet = 10.7.7.22 +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEApbEYmHf0vEDYa/2aVvWVxEGgC+JJlXcArdxkQooSIpnZfSAfsH0S +MFz8v7UkM7EJSwDsFWf+gxyoAORdFpdQm+XQoDqWVZ1e0isYtNluP2C/51s3lu2F +kVLZ+86el7zd4unHG+6CHmyaBcO5yV6VU8WFeuinB2+ojnujOWlHgOipMOrxsab8 +vwcH/0k/iR9BjH9xzo+kwhzqG0plLkQnvsvVyDN/gQj0Euz6YHfgo5c2gxQKKH7h +Bv6prIxCbpY7WMMtg0z+OlyGkQefVRl18kZwoNtOFlh5NBe7imYcH+wyhhQ9rqnN +VoHpJw4lNOuWfy3Af28kYDQ7KnPGYFq4nwIDAQAB +-----END RSA PUBLIC KEY----- diff --git a/modules/retiolum/hosts/miefdahome b/modules/retiolum/hosts/miefdahome new file mode 100644 index 00000000..9a9f4310 --- /dev/null +++ b/modules/retiolum/hosts/miefdahome @@ -0,0 +1,9 @@ +Subnet = 10.7.7.30 +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEAopwKn000XAcoI61OqQ7cjgrPHm/jHmuB1LHeCUggWMOD78WDFNzq +8/l9ASlU9kbSZFhoMuBR5BPWgciYWsC1EqY1nRAc/Si1rUHnJw+Xcyl0MNsZ7Cef +WaFRvC1VNC3qlQp5/e+fi46oOp4i+BqlFSxe7Jrr0EVyBVTOw8rMGToqDsOih6M9 +SFvmVMOnqh7n8LEOUtAL4nID59k7CTXzoNhXc0cEJoBkC2YCexonb4ru/J8F2BRG +Y3yzHYVskBrrPie1JNhfUHGCABIbtODTiHQYH8NFTYzdBnVV88IWqiTBbmKcRf+j +zEyGyXu/3YLFfjmsi7ysT+BWLIPvkyr7/wIDAQAB +-----END RSA PUBLIC KEY----- diff --git a/modules/retiolum/hosts/miefdat b/modules/retiolum/hosts/miefdat new file mode 100644 index 00000000..43e2a6e6 --- /dev/null +++ b/modules/retiolum/hosts/miefdat @@ -0,0 +1,10 @@ +Subnet = 10.7.7.20 + +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEAvCestFRcrr10nzSzc1l4Flkv6ZG5ijGneZBeDaP+bB3GhFx0BYzP +CQjcCFTcExVVAorknjX1/rjT60+dSBuJoH/pEeloPowtwm6YVgfhcQD/5qRHmAPF +Ss1pdiTVtyi0BmcqDGoOTcR/tR4v2LBEDnxK89wWIFWbeDeR6UyjD2psbFBal8Zd +TmkuBTg1OGPVhB+BmuKSqPBt6AtLV+0fKHdrTOVNwF2W/8lCVTd3uCVtnUEeTLrW +KA8h9C0K2gAxxhJTF3pJtR/YQPpgwXRg3CfzMKsvHNOsqfMnnk/WFM0vrSJSi2El +xCD5Pm/BPZyA8B4vhz8im4hWofOP2/JiNwIDAQAB +-----END RSA PUBLIC KEY----- diff --git a/modules/retiolum/hosts/no_omo b/modules/retiolum/hosts/no_omo new file mode 100644 index 00000000..f2398f18 --- /dev/null +++ b/modules/retiolum/hosts/no_omo @@ -0,0 +1,9 @@ +Subnet = 10.7.7.111 +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEAuHQEeowvxRkoHJUw6cUp431pnoIy4MVv7kTLgWEK46nzgZtld9LM +ZdNMJB9CuOVVMHEaiY6Q5YchUmapGxwEObc0y+8zQxTPw3I4q0GkSJqKLPrsTpkn +sgEkHPfs2GVdtIBXDn9I8i5JsY2+U8QF8fbIQSOO08/Vpa3nknDAMege9yEa3NFm +s/+x+2pS+xV6uzf/H21XNv0oufInXwZH1NCNXAy5I2V6pz7BmAHilVOGCT7g2zn6 +GasmofiYEnro4V5s8gDlQkb7bCZEIA9EgX/HP6fZJQezSUHcDCQFI0vg26xywbr6 +5+9tTn8fN2mWS5+Pdmx3haX1qFcBP5HglwIDAQAB +-----END RSA PUBLIC KEY----- diff --git a/modules/retiolum/hosts/pa_sharepoint b/modules/retiolum/hosts/pa_sharepoint new file mode 100644 index 00000000..384a7c22 --- /dev/null +++ b/modules/retiolum/hosts/pa_sharepoint @@ -0,0 +1,7 @@ +Address = pa-sharepoint.informatik.ba-stuttgart.de +Subnet = 10.7.7.5 +-----BEGIN RSA PUBLIC KEY----- +MIGJAoGBAKSle+5vi8j+auGIC41PwFRPdzuyhP/paAEht+9mWpTYYC1meyPDwQR8 +EPNLwj1ccjsAvhubfaDmI3B13cBQx5q1BbTCK81Y5RS1tj384kvAabJAtKsz3aIg +1hWXjiDJUGNpQhKsD7IIg4lkkDcgOBAbdtXlynCQXdQL+YjLTavBAgMBAAE= +-----END RSA PUBLIC KEY----- diff --git a/modules/retiolum/hosts/pfleidi b/modules/retiolum/hosts/pfleidi new file mode 100644 index 00000000..416658cf --- /dev/null +++ b/modules/retiolum/hosts/pfleidi @@ -0,0 +1,9 @@ +Subnet = 10.7.7.177 +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEAwdoS19bbKmVncJcf+uT5nNpyuR8SL9ekd+XMoKBpoqDf0r7ap3F2 +HLNI82NSbSAA4zdASrfrDl75sJ05VIIsueNAwMkFc72YNA9CPBFGcvCNVi0d4XcC +t6voNrgCVaxT77MVBAnohT7+HfYmkTTSrLaDKusRx7ybz6ZaRO9i2peC2VWKVIjP +m3QlvPeTpIJg/nGEBNO3rotBPxpMEB+fJnWxfBHRlt9klK3VhLaXCLUt5KcJ2SA4 +q3BFQbptUfI+d6OSA9btJerdtZ3PVBqlIJ45b3RDUWMborVg6jQ7S4WBzARe1eKs +SHHk0aR5LoiSGiNVGTDlxLVe1UT1dF8voQIDAQAB +-----END RSA PUBLIC KEY----- diff --git a/modules/retiolum/hosts/pornocauster b/modules/retiolum/hosts/pornocauster new file mode 100644 index 00000000..eee28777 --- /dev/null +++ b/modules/retiolum/hosts/pornocauster @@ -0,0 +1,9 @@ +Subnet = 10.7.7.42 +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEAnztrijsfao+fmNtwAjqwIDKsRaMP3ECsq2T2zqKvxwCyXk69G9bG +RFhWjgaawS9ZhnHSlgWK/vtoR0O9NxpzdU/mvdQijbVGxM02DegjO9qDSIe8EGmA +kscW4nDqYtw4rtjOVPfnNiWXbcWD8eiYR0kcSWmSvfOpVvdhTETqduTx5HRHyEFD +JRQYR/tJSvVWXmM670PENAPNJFJ4VSJR60s5A+bFT7J/uw7HzJXX28LygJz73Dj2 +2a4ev0WcZQngLq072h/91R/TOpg+ogUDVhXkQtKyFj7im0287JTL4bXGofZBhzaf ++h9dFGs1QLoNyhG/cgt9fog7boSXTelAiQIDAQAB +-----END RSA PUBLIC KEY----- diff --git a/modules/retiolum/hosts/supernode b/modules/retiolum/hosts/supernode new file mode 100644 index 00000000..5cee4e32 --- /dev/null +++ b/modules/retiolum/hosts/supernode @@ -0,0 +1,10 @@ +Address = 46.252.21.5 +Subnet = 10.7.7.1 +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEAr3DlBmQxP9UTBCkohK8FCYSk2td4Ov5lQYvC3Adx04lEWHfp+0nP +sShYqqN9Aj3iCqj/DHx5jGuSqjyTmmFWIOMM9IwKMo2Oiz/PcBM56N6gzIHuR5wj ++0bV0NRhePD2Tqo3zsEly9Hxw7xmz8azm5l4GcyOtgdRV7R1T3j/jB/9Kv2sj2Y7 +1zhSedCxjt/+NosiZZGE2JhLjzMgsCZSroAIKCZ3X/DP81mTTRxibjol82/Qn61I +b7GbuuB7SwjtZ+9xjsExN1JX5+AFuw9a3AkYuKWLpP50YY16/OTPq7flmB/EtK+Z +rrESIYKtX7pJbLc8Ywi0hBL5oPm07q+0BQIDAQAB +-----END RSA PUBLIC KEY----- diff --git a/modules/retiolum/hosts/tart b/modules/retiolum/hosts/tart new file mode 100644 index 00000000..986140ee --- /dev/null +++ b/modules/retiolum/hosts/tart @@ -0,0 +1,6 @@ +Subnet = 10.7.7.123 +-----BEGIN RSA PUBLIC KEY----- +MIGJAoGBALvZ4rLz0soCzkyOraC1aKtJzfVqYd2je6rkuaV12CLybCUc6YXaW/HP +rzJyDGmdh355kU4FNNyjnWP/U/juhMaeYFyTUWCRVXdqvDdeiEe/EJ0g+fFGKvPY +DEFo3VMCEkrXKuwDBQP02b4xmAWWnVBityGv5tgDFjl9uXh/SzL1AgMBAAE= +-----END RSA PUBLIC KEY----- diff --git a/modules/retiolum/install.sh b/modules/retiolum/install.sh new file mode 100755 index 00000000..7942b703 --- /dev/null +++ b/modules/retiolum/install.sh @@ -0,0 +1,68 @@ +#! /bin/sh +# USE WITH GREAT CAUTION + +set -e +myname="${1:-dummy}" +rel_hostsfile=`dirname $0`/hosts +hostsfile=`readlink -f $rel_hostsfile` +netname=retiolum +myipv4="${2:-10.7.7.56}" +mynet4=10.7.7.0 +CURR=`pwd` +# create configuration directory for $netname +mkdir -p /etc/tinc/$netname +cd /etc/tinc/$netname + +# get currently known hosts +cp -r $hostsfile . +echo "added known hosts:" +ls -1 | LC_ALL=C sort +echo "delete the nodes you do not trust!" + + +cat>tinc-up<<EOF +#! /bin/sh +ifconfig \$INTERFACE up $myipv4/24 +route add -net $mynet4/24 dev \$INTERFACE +EOF + +chmod +x tinc-up + +cat>tinc.conf<<EOF +Name = $myname +ConnectTo = supernode +ConnectTo = kaah +ConnectTo = pa_sharepoint +Device = /dev/net/tun +EOF +echo "Subnet = $myipv4" > hosts/$myname +tincd -n $netname -K + +echo Writing Public Key to irc channel +cat>write_channel.py<<EOF +#!/usr/bin/python +import random, sys, time, socket + +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() +EOF +python write_channel.py +# add user tincd +useradd tincd +tincd --user=tincd --chroot -n $netname 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..db6233fe --- /dev/null +++ b/modules/temper/Makefile @@ -0,0 +1,12 @@ +all: temper + +CFLAGS = -O2 -Wall + +temper: temper.c + ${CC} -DUNIT_TEST -o $@ $^ -lusb + +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 b/modules/temper/temper Binary files differnew file mode 100755 index 00000000..9f9927fb --- /dev/null +++ b/modules/temper/temper diff --git a/modules/temper/temper.c b/modules/temper/temper.c new file mode 100644 index 00000000..e591c9fa --- /dev/null +++ b/modules/temper/temper.c @@ -0,0 +1,301 @@ +#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 +#define DEBUG_MODE 0 +#define SLEEP_TIMEOUT 10 + +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); +} + + +#ifdef UNIT_TEST + +#define USB_TIMEOUT 1000 /* milliseconds */ + +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\n"); + printf("use %s -1 to do one-shot\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); + } + + if (argv == 2 && (args[1][0] == '1' || args[1][1] == '1')) + oneshot = 1; + + 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); + if (DEBUG_MODE){ + printf("Other Stuff (%d bytes):\n", ret); + for(i = 0; i < ret; i++) { + printf(" %02x", buf[i] & 0xFF); + if(i % 16 == 15) { + printf("\n"); + } + } + printf("\n"); + } + + for(;;) { + float tempc; + + if(TemperGetTemperatureInC(t, &tempc) < 0) { + perror("TemperGetTemperatureInC"); + exit(1); + } + printf("%.2fF %.2fC\n", (9.0 / 5.0 * tempc + 32.0), + tempc); + if (oneshot) + exit(0); + + sleep(SLEEP_TIMEOUT); + } + return 0; +} + +#endif 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, INCLUDIN |